Skip to content

Commit

Permalink
Merge pull request #1809 from facchettos/password
Browse files Browse the repository at this point in the history
removed dep on loftctl for reset
  • Loading branch information
lizardruss authored May 29, 2024
2 parents 076e531 + 938c98b commit a8c1745
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/vclusterctl/cmd/platform/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
},
Expand All @@ -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",
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/platform/random/random.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit a8c1745

Please sign in to comment.