diff --git a/go.mod b/go.mod index d4d11bd8..1cda4a30 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( code.gitea.io/sdk/gitea v0.15.1 github.com/argoproj/argo-cd/v2 v2.5.9 github.com/argoproj/gitops-engine v0.7.1-0.20221004132320-98ccd3d43fd9 - github.com/beaconsoftwarellc/gadget v1.3.8 github.com/briandowns/spinner v1.18.1 github.com/ghodss/yaml v1.0.0 github.com/go-git/go-billy/v5 v5.3.1 diff --git a/go.sum b/go.sum index 5b87894d..ccb7c471 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,6 @@ github.com/aws/aws-sdk-go v1.33.16/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZve github.com/aws/aws-sdk-go v1.35.24/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= github.com/aws/aws-sdk-go v1.38.49/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/beaconsoftwarellc/gadget v1.3.8 h1:B9E4VyUeZhg6WwDhEkDOF07dQ9ds1J7oke/0o2kwbBo= -github.com/beaconsoftwarellc/gadget v1.3.8/go.mod h1:VjsazzjXTA2Aibxhh9b4oouC4/Qk0MQHyq89gO13/6s= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/pkg/git/repository.go b/pkg/git/repository.go index f7c571af..e8a1cbb7 100644 --- a/pkg/git/repository.go +++ b/pkg/git/repository.go @@ -15,7 +15,6 @@ import ( "github.com/argoproj-labs/argocd-autopilot/pkg/log" "github.com/argoproj-labs/argocd-autopilot/pkg/store" "github.com/argoproj-labs/argocd-autopilot/pkg/util" - "github.com/beaconsoftwarellc/gadget/stringutil" billy "github.com/go-git/go-billy/v5" gg "github.com/go-git/go-git/v5" @@ -506,8 +505,10 @@ var createRepo = func(ctx context.Context, opts *CloneOptions) (defaultBranch st } _, orgRepo, _, _, _, _, _ := util.ParseGitUrl(opts.Repo) + // It depends on the provider, but org repo strucure should at least contain org and repo name - if len(stringutil.CleanWhiteSpace(strings.Split(orgRepo, "/"))) < 2 { + slc := util.CleanSliceWhiteSpaces(strings.Split(orgRepo, "/")) + if len(slc) < 2 { return "", errors.New("repo name can't be empty") } diff --git a/pkg/util/util.go b/pkg/util/util.go index 259f7cf5..d6db38f9 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -170,3 +170,14 @@ func StealFlags(cmd *cobra.Command, exceptFor []string) (*pflag.FlagSet, error) return fs, nil } + +func CleanSliceWhiteSpaces(slc []string) []string { + var res []string + for i := range slc { + if slc[i] != "" { + res = append(res, slc[i]) + } + } + + return res +} diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go new file mode 100644 index 00000000..e69de29b