From d675ecb2cd88ab161265df61a43759dfefec28f7 Mon Sep 17 00:00:00 2001 From: ffilippopoulos Date: Fri, 22 Mar 2024 14:45:38 +0000 Subject: [PATCH 1/2] Do not update repo bases if GitSSHSecretRef is not set --- Dockerfile | 2 +- go.mod | 2 +- run/runner.go | 6 ++++-- testdata/manifests/app-d-kustomize/kustomization.yaml | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4688a325..ba9b4950 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-alpine AS build +FROM golang:1.22-alpine AS build WORKDIR /src diff --git a/go.mod b/go.mod index 8a4211d5..e61b12b8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/utilitywarehouse/kube-applier -go 1.20 +go 1.22 require ( github.com/go-test/deep v1.0.5 diff --git a/run/runner.go b/run/runner.go index f4b32a16..8c74a9b6 100644 --- a/run/runner.go +++ b/run/runner.go @@ -345,8 +345,10 @@ func (r *Runner) setupRepositoryClone(ctx context.Context, waybill *kubeapplierv return "", "", err } // Rewrite repo addresses for those that want to use SSH keys to clone - if err := r.updateRepoBaseAddresses(tmpRepoDir); err != nil { - return "", "", err + if waybill.Spec.GitSSHSecretRef != nil { + if err := r.updateRepoBaseAddresses(tmpRepoDir); err != nil { + return "", "", err + } } return filepath.Join(tmpRepoDir, r.RepoPath), hash, nil } diff --git a/testdata/manifests/app-d-kustomize/kustomization.yaml b/testdata/manifests/app-d-kustomize/kustomization.yaml index 7cbb363c..1ff49b48 100644 --- a/testdata/manifests/app-d-kustomize/kustomization.yaml +++ b/testdata/manifests/app-d-kustomize/kustomization.yaml @@ -1,4 +1,5 @@ bases: + # kube-applier: key_should_be_ignored - ssh://github.com/utilitywarehouse/kube-applier//testdata/bases/simple-deployment?ref=master resources: - 00-namespace.yaml From e3089624483cbb32eb471a48913ce5523caafe2a Mon Sep 17 00:00:00 2001 From: ffilippopoulos Date: Fri, 22 Mar 2024 17:07:45 +0000 Subject: [PATCH 2/2] Fix test error since we are no longer modifying kustomization.yaml --- run/runner_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/runner_test.go b/run/runner_test.go index e56d4e8a..958114fc 100644 --- a/run/runner_test.go +++ b/run/runner_test.go @@ -501,7 +501,7 @@ Some error output has been omitted because it may contain sensitive data Commit: bHeadCommitHash, ErrorMessage: "exit status 1", Finished: metav1.Time{}, - Output: `(?s)Error: accumulating resources:.*'ssh:\/\/deploy_github_com\/utilitywarehouse\/kube-applier\/\/testdata\/bases\/simple-deployment\?ref=master'.*exit status 128`, + Output: `(?s).*Please make sure you have the correct access rights.*exit status 128`, Started: metav1.Time{}, Success: false, Type: PollingRun.String(),