Skip to content

Commit 64ee1a3

Browse files
authored
CR-15471-insecure-git-providers (#640)
* send certFile to autopilot + git api calls * updated autopilot dependency removed applicationset dependency (it's inside argocd) * increase lint timeout to 10m
1 parent 22311fd commit 64ee1a3

14 files changed

+224
-194
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.1.8
1+
VERSION=v0.1.9
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")
@@ -122,7 +122,7 @@ $(OUT_DIR)/$(CLI_NAME).image: $(CLI_SRCS)
122122
.PHONY: lint
123123
lint: $(GOBIN)/golangci-lint tidy
124124
@echo linting go code...
125-
@golangci-lint run --fix --timeout 6m
125+
@golangci-lint run --fix --timeout 10m
126126

127127
.PHONY: test
128128
test:

cmd/commands/git-source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func NewGitSourceCreateCommand() *cobra.Command {
200200
insCloneOpts.Parse()
201201
gsCloneOpts.Parse()
202202

203-
gitProvider, err = cfgit.GetProvider(cfgit.ProviderType(gsCloneOpts.Provider), gsCloneOpts.Repo)
203+
gitProvider, err = cfgit.GetProvider(cfgit.ProviderType(gsCloneOpts.Provider), gsCloneOpts.Repo, gsCloneOpts.Auth.CertFile)
204204
if err != nil {
205205
log.G(ctx).Fatal("failed to infer git provider for git-source")
206206
}

cmd/commands/runtime.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import (
4343
apgit "github.com/argoproj-labs/argocd-autopilot/pkg/git"
4444
"github.com/argoproj-labs/argocd-autopilot/pkg/kube"
4545
apstore "github.com/argoproj-labs/argocd-autopilot/pkg/store"
46-
appset "github.com/argoproj/applicationset/api/v1alpha1"
4746
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
4847
argocdv1alpha1cs "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned"
4948
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
@@ -1063,9 +1062,9 @@ func downloadFile(response *http.Response, fullFilename string) error {
10631062
return err
10641063
}
10651064

1066-
var getProjectInfoFromFile = func(repofs fs.FS, name string) (*argocdv1alpha1.AppProject, *appset.ApplicationSet, error) {
1065+
var getProjectInfoFromFile = func(repofs fs.FS, name string) (*argocdv1alpha1.AppProject, *argocdv1alpha1.ApplicationSet, error) {
10671066
proj := &argocdv1alpha1.AppProject{}
1068-
appSet := &appset.ApplicationSet{}
1067+
appSet := &argocdv1alpha1.ApplicationSet{}
10691068
if err := repofs.ReadYamls(name, proj, appSet); err != nil {
10701069
return nil, nil, err
10711070
}

cmd/commands/runtime_install.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ import (
5151
"github.com/argoproj-labs/argocd-autopilot/pkg/kube"
5252
apstore "github.com/argoproj-labs/argocd-autopilot/pkg/store"
5353
aputil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
54-
appset "github.com/argoproj/applicationset/api/v1alpha1"
55-
argocd "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
54+
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
5655
aev1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1"
5756
"github.com/codefresh-io/go-sdk/pkg/codefresh"
5857
platmodel "github.com/codefresh-io/go-sdk/pkg/codefresh/model"
@@ -410,7 +409,7 @@ func ensureGitData(cmd *cobra.Command, opts *RuntimeInstallOptions) error {
410409
}
411410

412411
baseURL, _, _, _, _, _, _ := aputil.ParseGitUrl(opts.InsCloneOpts.Repo)
413-
opts.gitProvider, err = cfgit.GetProvider(cfgit.ProviderType(opts.InsCloneOpts.Provider), baseURL)
412+
opts.gitProvider, err = cfgit.GetProvider(cfgit.ProviderType(opts.InsCloneOpts.Provider), baseURL, opts.InsCloneOpts.Auth.CertFile)
414413
if err != nil {
415414
return err
416415
}
@@ -1740,21 +1739,21 @@ func updateProject(repofs fs.FS, rt *runtime.Runtime) error {
17401739
// adding another gitGenerator to the project's ApplicationSet
17411740
// to support helm applications without adding the support in autopilot (TBD)
17421741
kustGenerator := appSet.Spec.Generators[0].Git
1743-
appSet.Spec.Generators = append(appSet.Spec.Generators, appset.ApplicationSetGenerator{
1744-
Git: &appset.GitGenerator{
1745-
Files: []appset.GitFileGeneratorItem{
1742+
appSet.Spec.Generators = append(appSet.Spec.Generators, argocdv1alpha1.ApplicationSetGenerator{
1743+
Git: &argocdv1alpha1.GitGenerator{
1744+
Files: []argocdv1alpha1.GitFileGeneratorItem{
17461745
{
17471746
Path: strings.Replace(kustGenerator.Files[0].Path, "config.json", "config_helm.json", 1),
17481747
},
17491748
},
17501749
RepoURL: kustGenerator.RepoURL,
17511750
RequeueAfterSeconds: kustGenerator.RequeueAfterSeconds,
17521751
Revision: kustGenerator.Revision,
1753-
Template: appset.ApplicationSetTemplate{
1754-
Spec: argocd.ApplicationSpec{
1755-
Source: argocd.ApplicationSource{
1752+
Template: argocdv1alpha1.ApplicationSetTemplate{
1753+
Spec: argocdv1alpha1.ApplicationSpec{
1754+
Source: argocdv1alpha1.ApplicationSource{
17561755
Chart: "{{ srcChart }}",
1757-
Helm: &argocd.ApplicationSourceHelm{
1756+
Helm: &argocdv1alpha1.ApplicationSourceHelm{
17581757
ReleaseName: fmt.Sprintf("%s-{{ appName }}", rt.Name),
17591758
Values: "{{ values }}",
17601759
},

docs/commands/cli-v2_git-source_create.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ cli-v2 git-source create RUNTIME_NAME GITSOURCE_NAME [flags]
1717
### Options
1818

1919
```
20-
--create-repo If true, will create the specified git-source repo in case it doesn't already exist
21-
--exclude string files to exclude. can be either filenames or a glob
22-
--git-src-git-token string Your git provider api token [GIT_SRC_GIT_TOKEN]
23-
--git-src-git-user string Your git provider user name [GIT_SRC_GIT_USER] (not required in GitHub)
24-
--git-src-repo string Repository URL [GIT_SRC_GIT_REPO]
25-
-t, --git-token string Your git provider api token [GIT_TOKEN]
26-
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
27-
-h, --help help for create
28-
--include string files to include. can be either filenames or a glob
29-
--repo string Repository URL [GIT_REPO]
30-
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
20+
--create-repo If true, will create the specified git-source repo in case it doesn't already exist
21+
--exclude string files to exclude. can be either filenames or a glob
22+
--git-server-crt string Git Server certificate file
23+
--git-src-git-server-crt string Git Server certificate fileGIT_SRC_
24+
--git-src-git-token string Your git provider api token [GIT_SRC_GIT_TOKEN]
25+
--git-src-git-user string Your git provider user name [GIT_SRC_GIT_USER] (not required in GitHub)
26+
--git-src-repo string Repository URL [GIT_SRC_GIT_REPO]
27+
-t, --git-token string Your git provider api token [GIT_TOKEN]
28+
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
29+
-h, --help help for create
30+
--include string files to include. can be either filenames or a glob
31+
--repo string Repository URL [GIT_REPO]
32+
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
3133
```
3234

3335
### Options inherited from parent commands

docs/commands/cli-v2_git-source_delete.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ cli-v2 git-source delete RUNTIME_NAME GITSOURCE_NAME [flags]
1717
### Options
1818

1919
```
20-
-t, --git-token string Your git provider api token [GIT_TOKEN]
21-
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
22-
-h, --help help for delete
23-
--repo string Repository URL [GIT_REPO]
24-
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
20+
--git-server-crt string Git Server certificate file
21+
-t, --git-token string Your git provider api token [GIT_TOKEN]
22+
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
23+
-h, --help help for delete
24+
--repo string Repository URL [GIT_REPO]
25+
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
2526
```
2627

2728
### Options inherited from parent commands

docs/commands/cli-v2_git-source_edit.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ cli-v2 git-source edit RUNTIME_NAME GITSOURCE_NAME [flags]
1717
### Options
1818

1919
```
20-
--exclude string files to exclude. can be either filenames or a glob
21-
--git-src-git-token string Your git provider api token [GIT_SRC_GIT_TOKEN]
22-
--git-src-git-user string Your git provider user name [GIT_SRC_GIT_USER] (not required in GitHub)
23-
--git-src-provider string The git provider, one of: azure|bitbucket|bitbucket-server|gitea|github|gitlab
24-
--git-src-repo string Repository URL [GIT_SRC_GIT_REPO]
25-
-t, --git-token string Your git provider api token [GIT_TOKEN]
26-
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
27-
-h, --help help for edit
28-
--include string files to include. can be either filenames or a glob
29-
--provider string The git provider, one of: azure|bitbucket|bitbucket-server|gitea|github|gitlab
30-
--repo string Repository URL [GIT_REPO]
31-
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
20+
--exclude string files to exclude. can be either filenames or a glob
21+
--git-server-crt string Git Server certificate file
22+
--git-src-git-server-crt string Git Server certificate fileGIT_SRC_
23+
--git-src-git-token string Your git provider api token [GIT_SRC_GIT_TOKEN]
24+
--git-src-git-user string Your git provider user name [GIT_SRC_GIT_USER] (not required in GitHub)
25+
--git-src-provider string The git provider, one of: azure|bitbucket|bitbucket-server|gitea|github|gitlab
26+
--git-src-repo string Repository URL [GIT_SRC_GIT_REPO]
27+
-t, --git-token string Your git provider api token [GIT_TOKEN]
28+
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
29+
-h, --help help for edit
30+
--include string files to include. can be either filenames or a glob
31+
--provider string The git provider, one of: azure|bitbucket|bitbucket-server|gitea|github|gitlab
32+
--repo string Repository URL [GIT_REPO]
33+
-b, --upsert-branch If true will try to checkout the specified branch and create it if it doesn't exist
3234
```
3335

3436
### Options inherited from parent commands

docs/commands/cli-v2_runtime_install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ cli-v2 runtime install [runtime_name] [flags]
3636
--from-repo Installs a runtime from an existing repo. Used for recovery after cluster failure
3737
--gateway-name string The gateway name
3838
--gateway-namespace string The namespace of the gateway
39+
--git-server-crt string Git Server certificate file
3940
-t, --git-token string Your git provider api token [GIT_TOKEN]
4041
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
4142
-h, --help help for install

docs/commands/cli-v2_runtime_uninstall.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ cli-v2 runtime uninstall [RUNTIME_NAME] [flags]
3232
--disable-telemetry If true, will disable the analytics reporting for the uninstall process
3333
--fast-exit If true, will not wait for deletion of cluster resources. This means that full resource deletion will not be verified
3434
--force If true, will guarantee the runtime is removed from the platform, even in case of errors while cleaning the repo and the cluster
35+
--git-server-crt string Git Server certificate file
3536
-t, --git-token string Your git provider api token [GIT_TOKEN]
3637
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
3738
-h, --help help for uninstall

docs/commands/cli-v2_runtime_upgrade.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cli-v2 runtime upgrade [RUNTIME_NAME] [flags]
2929

3030
```
3131
--disable-telemetry If true, will disable analytics reporting for the upgrade process
32+
--git-server-crt string Git Server certificate file
3233
-t, --git-token string Your git provider api token [GIT_TOKEN]
3334
-u, --git-user string Your git provider user name [GIT_USER] (not required in GitHub)
3435
-h, --help help for upgrade

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.8/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.9/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.8/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.9/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

0 commit comments

Comments
 (0)