argocd-autopilot
argocd-autopilot copied to clipboard
Cannot create project on private gitlab instance because of wrong provider
I bootstrap a new repository on a private gitlab instance:
argocd-autopilot repo bootstrap --repo https://git.example.com/rgocd-autopilot-test --provider gitlab --namespace argopilot
Now I want to create a new project:
> argocd-autopilot project create test-customer-1 --repo https://git.example.com/argocd-autopilot-test
INFO cloning git repository: https://git.example.com/argocd-autopilot-test.git
WARNING --provider not specified, assuming provider from url: git.example.com
FATAL failed cloning the repository: git provider 'git.example.com not supported
The --provider
flag does not seem to exist for the project subcommand:
> argocd-autopilot project create test-customer-1 --repo https://git.example.com/argocd-autopilot-test --provider gitlab
FATA[0000] unknown flag: --provider
Am I doing something wrong?
I have the same issue. The version of argocd-autopilot
CLI I used: v0.3.5
Same on my side, but for github enterprise. I could bootstrap the repo with github-enterprise by using --provider=github
, but I cannot create a project.
My workaround:
diff --git a/pkg/git/repository.go b/pkg/git/repository.go
index 425ee73..0788599 100644
--- a/pkg/git/repository.go
+++ b/pkg/git/repository.go
@@ -158,9 +158,9 @@ func AddFlags(cmd *cobra.Command, opts *AddFlagsOptions) *CloneOptions {
cmd.Flag("git-user").Shorthand = "u"
}
- if opts.CreateIfNotExist {
- cmd.PersistentFlags().StringVar(&co.Provider, opts.Prefix+"provider", "", fmt.Sprintf("The git provider, one of: %v", strings.Join(Providers(), "|")))
- }
+ //if opts.CreateIfNotExist {
+ cmd.PersistentFlags().StringVar(&co.Provider, opts.Prefix+"provider", "", fmt.Sprintf("The git provider, one of: %v", strings.Join(Providers(), "|")))
+ //}
if opts.CloneForWrite {
cmd.PersistentFlags().BoolVarP(&co.UpsertBranch, opts.Prefix+"upsert-branch", "b", false, "If true will try to checkout the specified branch and create it if it doesn't exist")
Our workaround was to run the bootstrap command :
argocd-autopilot repo bootstrap --repo ** --provider github
Then add in the project YAML and app JSON manually. ArgoCD then picks up the file and creates a project + app.
Afte rusing my workaround, the same problem happens when creating an app cloned from a private gitlab instance:
> ~/dev/argocd-autopilot/dist/argocd-autopilot-linux-amd64 app create mvp -p test-customer-1 --repo https://git.example.com/mvp/argocd-autopilot-test --provider gitlab --app https://git.example.com/mvp
/kustomize-manifests
INFO cloning git repository: https://git.example.com/mvp/argocd-autopilot-test.git
Enumerating objects: 23, done.
Counting objects: 100% (23/23), done.
Compressing objects: 100% (19/19), done.
Total 23 (delta 2), reused 0 (delta 0), pack-reused 0
INFO using revision: "", installation path: "/"
INFO cloning repo: 'https://git.example.com/mvp/kustomize-manifests.git', to infer app type from path ''
WARNING --provider not specified, assuming provider from url: git.example.com
FATAL git provider 'git.example.com' not supported
``
Same problem for argocd-autpilot repo uninstall
Same here, I exported my repo with GIT_REPO=my.gitlab-private-instance.com/namespace/argocd-test.git
, it worked for bootstrap by providing --provider gitlab
but for project creation, it doesn't work.
Without provider:
❱ argocd-autopilot project create test-local
INFO cloning git repository: https://my.gitlab-private-instance.com/namespace/argocd-test.git
WARNING --provider not specified, assuming provider from url: my.gitlab-private-instance
FATAL failed cloning the repository: git provider 'my.gitlab-private-instance' not supported
Giving provider:
❱ argocd-autopilot project create test-local --provider gitlab
FATA[0000] unknown flag: --provider
Commenting on this to raise the issue. If the other command accepts already --provider
I suspect making this work on the missing commands won't be that hard right? This issue can be a big blocker for many companies running their own git servers.
Would be cool if this could be resolved anytime soon 😅
fyi, project create
worked for me with gitlab and argocd-autopilot version 0.4.7
$ GIT_REPO="https://myrepo.com:1234/argocd/applications.git?ref=main" GIT_TOKEN=redacted-value argocd-autopilot project create my-project-name --provider gitlab
INFO cloning git repository: https://myrepo.com:1234/argocd/applications.git
Enumerating objects: 23, done.
Counting objects: 100% (23/23), done.
Compressing objects: 100% (18/18), done.
Total 23 (delta 1), reused 0 (delta 0), pack-reused 0
INFO using revision: "main", installation path: "/"
INFO pushing new project manifest to repo
INFO project created: 'my-project-name'
Yep, looks like this is working now!
the original issue was a bug not because the --provider
was not being used for project creation, but because the code for checking for the provider when it shouldn't.
generally, the code only cares about the provider when creating a new repository (which is a provider-specific api call). for the rest of the operations, it is only clone-change-commit-push - nothing is provider specific. i think it works as expected right now, and there is no need to expose the --provider
option for anything other than repo bootstrap
command.
am i missing anything?
i am closing the issue right now, due to the reasons i expressed in my previous comment. please re-open it if you think it still requires a different solution.