Skip to content

Commit 3eaa196

Browse files
authored
Fix most commands to not require auth (#409)
1 parent 9de7e73 commit 3eaa196

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

cmd/lekko/feature.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"github.com/lekkodev/cli/pkg/logging"
3737
"github.com/lekkodev/cli/pkg/metadata"
3838
"github.com/lekkodev/cli/pkg/repo"
39-
"github.com/lekkodev/cli/pkg/secrets"
4039
"github.com/lekkodev/cli/pkg/star/static"
4140
"github.com/lekkodev/go-sdk/pkg/eval"
4241
"github.com/pkg/errors"
@@ -68,7 +67,7 @@ func featureList() *cobra.Command {
6867
Use: "list",
6968
Short: "list all configs",
7069
RunE: func(cmd *cobra.Command, args []string) error {
71-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
70+
r, err := repo.NewLocal(wd, nil)
7271
if err != nil {
7372
return err
7473
}
@@ -109,7 +108,7 @@ func featureAdd() *cobra.Command {
109108
Use: "add",
110109
Short: "add config",
111110
RunE: func(cmd *cobra.Command, args []string) error {
112-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
111+
r, err := repo.NewLocal(wd, nil)
113112
if err != nil {
114113
return err
115114
}
@@ -211,7 +210,7 @@ func featureRemove() *cobra.Command {
211210
Use: "remove",
212211
Short: "remove config",
213212
RunE: func(cmd *cobra.Command, args []string) error {
214-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
213+
r, err := repo.NewLocal(wd, nil)
215214
if err != nil {
216215
return err
217216
}
@@ -249,7 +248,7 @@ func featureEval() *cobra.Command {
249248
Use: "eval",
250249
Short: "evaluate config",
251250
RunE: func(cmd *cobra.Command, args []string) error {
252-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
251+
r, err := repo.NewLocal(wd, nil)
253252
if err != nil {
254253
return err
255254
}
@@ -338,7 +337,7 @@ func configGroup() *cobra.Command {
338337
Use: "group",
339338
Short: "group multiple configs into 1 config",
340339
RunE: func(cmd *cobra.Command, args []string) error {
341-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
340+
r, err := repo.NewLocal(wd, nil)
342341
if err != nil {
343342
return err
344343
}
@@ -723,7 +722,7 @@ var nsList = &cobra.Command{
723722
if err != nil {
724723
return err
725724
}
726-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
725+
r, err := repo.NewLocal(wd, nil)
727726
if err != nil {
728727
return err
729728
}
@@ -747,7 +746,7 @@ func nsAdd() *cobra.Command {
747746
Use: "add",
748747
Short: "add namespace",
749748
RunE: func(cmd *cobra.Command, args []string) error {
750-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
749+
r, err := repo.NewLocal(wd, nil)
751750
if err != nil {
752751
return err
753752
}
@@ -776,7 +775,7 @@ func nsRemove() *cobra.Command {
776775
Use: "remove",
777776
Short: "remove namespace",
778777
RunE: func(cmd *cobra.Command, args []string) error {
779-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
778+
r, err := repo.NewLocal(wd, nil)
780779
if err != nil {
781780
return err
782781
}

cmd/lekko/main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ func formatCmd() *cobra.Command {
154154
Use: "format",
155155
Short: "format star files",
156156
RunE: func(cmd *cobra.Command, args []string) error {
157-
rs := secrets.NewSecretsOrFail()
158-
r, err := repo.NewLocal(wd, rs)
157+
r, err := repo.NewLocal(wd, nil)
159158
if err != nil {
160159
return errors.Wrap(err, "new repo")
161160
}
@@ -225,8 +224,7 @@ func verifyCmd() *cobra.Command {
225224
Use: "verify [namespace[/config]]",
226225
Short: "verifies configs based on individual definitions",
227226
RunE: func(cmd *cobra.Command, args []string) error {
228-
rs := secrets.NewSecretsOrFail()
229-
r, err := repo.NewLocal(wd, rs)
227+
r, err := repo.NewLocal(wd, nil)
230228
if err != nil {
231229
return err
232230
}
@@ -264,7 +262,7 @@ func parseCmd() *cobra.Command {
264262
Use: "parse",
265263
Short: "parse a feature file using static analysis, and rewrite the starlark",
266264
RunE: func(cmd *cobra.Command, args []string) error {
267-
r, err := repo.NewLocal(wd, secrets.NewSecretsOrFail())
265+
r, err := repo.NewLocal(wd, nil)
268266
if err != nil {
269267
return errors.Wrap(err, "new repo")
270268
}

pkg/repo/repo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ func (r *repository) storeDefaultBranchName(ap AuthProvider) error {
269269
}
270270
// The local filesystem does not have enough info to deduce the
271271
// default branch name. Query remote, and save the result
272+
if ap == nil || credentialsExist(ap) != nil {
273+
return errors.New("missing git credentials, run lekko auth login")
274+
}
272275
remote, err := r.repo.Remote(RemoteName)
273276
if err != nil {
274277
if err == git.ErrRemoteNotFound {

0 commit comments

Comments
 (0)