File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,9 @@ func (m *CloudProviderAzure) Init(ctx context.Context, opts config.Opts) {
4747 }
4848
4949 if m .opts .CloudProvider .Config != nil {
50- os .Setenv ("AZURE_AUTH_LOCATION" , * m .opts .CloudProvider .Config )
50+ if err := os .Setenv ("AZURE_AUTH_LOCATION" , * m .opts .CloudProvider .Config ); err != nil {
51+ m .log .Panic (err )
52+ }
5153 }
5254
5355 // environment
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package manager
33import (
44 "bytes"
55 "context"
6+ "crypto/rand"
67 "fmt"
78 "github.com/prometheus/client_golang/prometheus"
89 log "github.com/sirupsen/logrus"
@@ -17,7 +18,7 @@ import (
1718 "k8s.io/client-go/rest"
1819 "k8s.io/client-go/tools/clientcmd"
1920 "k8s.io/client-go/util/retry"
20- "math/rand "
21+ "math/big "
2122 "os"
2223 "text/template"
2324 "time"
5051
5152func (m * KubeBootstrapTokenManager ) Init () {
5253 m .ctx = context .Background ()
53- rand .Seed (time .Now ().UnixNano ())
5454 m .initK8s ()
5555 m .initPrometheus ()
5656 m .initCloudProvider ()
@@ -332,9 +332,13 @@ func (m *KubeBootstrapTokenManager) generateTokenId() string {
332332func (m * KubeBootstrapTokenManager ) generateTokenSecret () string {
333333 b := make ([]rune , m .Opts .BootstrapToken .TokenLength )
334334 runes := []rune (m .Opts .BootstrapToken .TokenRunes )
335- runeLength := len (runes )
335+ runeLength := int64 ( len (runes ) )
336336 for i := range b {
337- b [i ] = runes [rand .Intn (runeLength )]
337+ if val , err := rand .Int (rand .Reader , big .NewInt (runeLength )); err == nil {
338+ b [i ] = runes [val .Uint64 ()]
339+ } else {
340+ log .Panic (err )
341+ }
338342 }
339343 return string (b )
340344}
You can’t perform that action at this time.
0 commit comments