diff --git a/cmd/vclusterctl/cmd/platform/reset.go b/cmd/vclusterctl/cmd/platform/reset.go index e215543fd..370fbeb08 100644 --- a/cmd/vclusterctl/cmd/platform/reset.go +++ b/cmd/vclusterctl/cmd/platform/reset.go @@ -7,11 +7,11 @@ import ( "strings" storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1" - "github.com/loft-sh/loftctl/v4/pkg/random" "github.com/loft-sh/log" "github.com/loft-sh/log/survey" "github.com/loft-sh/vcluster/pkg/cli/flags" "github.com/loft-sh/vcluster/pkg/platform/kube" + "github.com/loft-sh/vcluster/pkg/platform/random" "github.com/pkg/errors" "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" @@ -117,7 +117,7 @@ func (cmd *PasswordCmd) Run() error { "system:masters", }, PasswordRef: &storagev1.SecretRef{ - SecretName: "loft-password-" + random.RandomString(5), + SecretName: "loft-password-" + random.String(5), SecretNamespace: "loft", Key: "password", }, @@ -135,7 +135,7 @@ func (cmd *PasswordCmd) Run() error { } user.Spec.PasswordRef = &storagev1.SecretRef{ - SecretName: "loft-password-" + random.RandomString(5), + SecretName: "loft-password-" + random.String(5), SecretNamespace: "loft", Key: "password", } diff --git a/pkg/platform/random/random.go b/pkg/platform/random/random.go new file mode 100644 index 000000000..cfefb2ffc --- /dev/null +++ b/pkg/platform/random/random.go @@ -0,0 +1,16 @@ +package random + +import ( + "math/rand" +) + +var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz") + +// String creates a new random string with the given length +func String(length int) string { + b := make([]rune, length) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +}