From c4e2af263b1d2ecd56e09a1a7bfb3f9bc8b8581d Mon Sep 17 00:00:00 2001 From: codefresh Date: Tue, 20 Jul 2021 19:49:33 +0300 Subject: [PATCH 01/43] bad indentation --- codefresh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh.yaml b/codefresh.yaml index 816fbfd..ad2725c 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -65,7 +65,7 @@ PushingToRegistries_with_tag: image_name: codefreshplugins/cf-argo-plugin - PushingToRegistries: +PushingToRegistries: title: Pushing to Registry type: push candidate: ${{build}} From 05367f62b813d69808ce786b92b1bb3e5a3ac5a9 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Fri, 24 Sep 2021 14:12:02 +0300 Subject: [PATCH 02/43] add insecure mode --- pkg/codefresh/api.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/codefresh/api.go b/pkg/codefresh/api.go index 522a2c2..f9c9d5e 100644 --- a/pkg/codefresh/api.go +++ b/pkg/codefresh/api.go @@ -2,6 +2,7 @@ package codefresh import ( "bytes" + "crypto/tls" "encoding/json" "fmt" "net/http" @@ -95,10 +96,13 @@ type codefresh struct { } func New(opt *ClientOptions) Codefresh { + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } return &codefresh{ host: opt.Host, token: opt.Token, - client: &http.Client{}, + client: &http.Client{Transport: tr}, } } From 6dd4c1cb62744113e448364630b45d2de17ff957 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Fri, 24 Sep 2021 20:37:00 +0300 Subject: [PATCH 03/43] fix yaml --- codefresh.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index ad2725c..0a720cd 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -48,7 +48,7 @@ steps: -PushingToRegistries_with_tag: + PushingToRegistries_with_tag: title: Pushing to Registry type: push candidate: ${{build}} @@ -65,7 +65,7 @@ PushingToRegistries_with_tag: image_name: codefreshplugins/cf-argo-plugin -PushingToRegistries: + PushingToRegistries: title: Pushing to Registry type: push candidate: ${{build}} From 4e0bc127bfa0cb750b6237da21a7037c7ddd5cb8 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Fri, 24 Sep 2021 20:39:20 +0300 Subject: [PATCH 04/43] rename --- codefresh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh.yaml b/codefresh.yaml index 0a720cd..bed2256 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -66,7 +66,7 @@ steps: PushingToRegistries: - title: Pushing to Registry + title: Pushing to Registry only master type: push candidate: ${{build}} tags: From eb3eaea1e3ac536f5e724062922dc8e6c86304db Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Fri, 24 Sep 2021 20:40:28 +0300 Subject: [PATCH 05/43] rename --- codefresh.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index bed2256..37cc909 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -76,11 +76,11 @@ steps: only: - master scale: - PushingToDockerHubRegistry: + PushingToDockerHubRegistry2: title: Pushing To DockerHub Registry registry: dockerhub image_name: codefresh/cf-argo-plugin - PushingToQuayRegistry: + PushingToQuayRegistry2: title: Pushing To Quay Registry registry: cfpluginmgr-quay image_name: codefreshplugins/cf-argo-plugin From 61a79677308681b970879d6e1a76a6acc0b0e9d9 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Fri, 24 Sep 2021 20:45:37 +0300 Subject: [PATCH 06/43] rename --- codefresh.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index 37cc909..335da7b 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -59,11 +59,6 @@ steps: title: Pushing To DockerHub Registry registry: dockerhub image_name: codefresh/cf-argo-plugin - PushingToQuayRegistry: - title: Pushing To Quay Registry - registry: cfpluginmgr-quay - image_name: codefreshplugins/cf-argo-plugin - PushingToRegistries: title: Pushing to Registry only master @@ -80,10 +75,3 @@ steps: title: Pushing To DockerHub Registry registry: dockerhub image_name: codefresh/cf-argo-plugin - PushingToQuayRegistry2: - title: Pushing To Quay Registry - registry: cfpluginmgr-quay - image_name: codefreshplugins/cf-argo-plugin - - - From b7ab1b5f31c89160c0a6fe5d032b0e0a0ee3e4e8 Mon Sep 17 00:00:00 2001 From: olegz Date: Mon, 18 Oct 2021 17:53:15 +0300 Subject: [PATCH 07/43] CR-7137 --- VERSION | 2 +- pkg/builder/commands_factory.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 0c62199..ee1372d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 diff --git a/pkg/builder/commands_factory.go b/pkg/builder/commands_factory.go index 657ddd6..1db83fa 100644 --- a/pkg/builder/commands_factory.go +++ b/pkg/builder/commands_factory.go @@ -11,7 +11,7 @@ func GetCommandsFactory() *CommandsFactory { func (cf *CommandsFactory) CreateWaitRolloutCMD(name string, integration string) string { return fmt.Sprintf(` - cf-argo-plugin wait-rollout %s --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=%s --pipeline-id=$CF_PIPELINE_NAME --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout %s --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=%s --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s `, name, integration) } From 0cd0da9c4770943307348c9ca01bf6c8097a4f14 Mon Sep 17 00:00:00 2001 From: olegz Date: Mon, 18 Oct 2021 18:15:42 +0300 Subject: [PATCH 08/43] CR-7137 --- pkg/builder/builder_test.go | 4 ++-- pkg/builder/commands_factory_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index fba1190..166d2e2 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -63,7 +63,7 @@ func TestRolloutWithWaitHealthy(t *testing.T) { "kubectl config use-context \"kube-ctx\"", "kubectl argo rollouts promote \"app\" -n \"default\"", ` - cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id=$CF_PIPELINE_NAME --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s `, "argocd app wait test --auth-token token --server --insecure", @@ -111,7 +111,7 @@ func TestSyncWithWaitHealthy(t *testing.T) { expectedLines := []string{ "#!/bin/bash -e", ` - cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id=$CF_PIPELINE_NAME --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s `, "argocd app sync test --auth-token token --server --insecure", diff --git a/pkg/builder/commands_factory_test.go b/pkg/builder/commands_factory_test.go index a2f27eb..fafb005 100644 --- a/pkg/builder/commands_factory_test.go +++ b/pkg/builder/commands_factory_test.go @@ -6,7 +6,7 @@ import ( func TestCreateWaitRolloutCMD(t *testing.T) { expectedCMD := ` - cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id=$CF_PIPELINE_NAME --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s ` cmd := GetCommandsFactory().CreateWaitRolloutCMD("test", "context") From 80d72ebf848203ad9cd52e0d3e9574d49b9098b5 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Tue, 19 Oct 2021 15:00:34 +0300 Subject: [PATCH 09/43] push to quay --- codefresh.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codefresh.yaml b/codefresh.yaml index 335da7b..69b8ed3 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -59,6 +59,10 @@ steps: title: Pushing To DockerHub Registry registry: dockerhub image_name: codefresh/cf-argo-plugin + PushingToQuayRegistry: + title: Pushing To Quay Registry + registry: cfpluginmgr-quay + image_name: codefreshplugins/cf-argo-plugin PushingToRegistries: title: Pushing to Registry only master @@ -75,3 +79,7 @@ steps: title: Pushing To DockerHub Registry registry: dockerhub image_name: codefresh/cf-argo-plugin + PushingToQuayRegistry2: + title: Pushing To Quay Registry + registry: cfpluginmgr-quay + image_name: codefreshplugins/cf-argo-plugin From e86b46dbe81a01185dde6dd5b9c01fd3c5b4433d Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 17 Nov 2021 18:49:50 +0200 Subject: [PATCH 10/43] add skip flag --- cmd/processResult/wait_rollout.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/processResult/wait_rollout.go b/cmd/processResult/wait_rollout.go index a538ccc..ed606fc 100644 --- a/cmd/processResult/wait_rollout.go +++ b/cmd/processResult/wait_rollout.go @@ -8,6 +8,7 @@ import ( var waitRolloutArgsOptions struct { PipelineId string BuildId string + Skip bool } var WaitRolloutCmd = &cobra.Command{ @@ -18,6 +19,9 @@ var WaitRolloutCmd = &cobra.Command{ fmt.Println("Wrong amount of arguments") return nil } + if waitRolloutArgsOptions.Skip { + return nil + } return GetWaitRolloutHandler().Handle(args[0]) }, } @@ -26,4 +30,5 @@ func init() { f := WaitRolloutCmd.Flags() f.StringVar(&waitRolloutArgsOptions.PipelineId, "pipeline-id", "", "Pipeline id where argo sync was executed") f.StringVar(&waitRolloutArgsOptions.BuildId, "build-id", "", "Build id where argo sync was executed") + f.BoolVar(&waitRolloutArgsOptions.Skip, "skip", false, "Skip wait rollout step") } From a342e4ca363174c44ae492b1cf1c12d81fa0949e Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 17 Nov 2021 19:16:32 +0200 Subject: [PATCH 11/43] add skip flag --- cmd/rollout/rollout.go | 3 +- cmd/sync/sync.go | 4 +-- pkg/builder/builder.go | 14 ++++---- pkg/builder/builder_test.go | 51 ++++++++++++++++++++++++---- pkg/builder/commands_factory.go | 11 ++++-- pkg/builder/commands_factory_test.go | 4 +-- 6 files changed, 67 insertions(+), 20 deletions(-) diff --git a/cmd/rollout/rollout.go b/cmd/rollout/rollout.go index 4dfce41..538f383 100644 --- a/cmd/rollout/rollout.go +++ b/cmd/rollout/rollout.go @@ -36,7 +36,7 @@ var Cmd = &cobra.Command{ } } b.ExportExternalUrl(context.PluginArgoCredentials.Host, name) - b.Rollout(rolloutArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration) + b.Rollout(rolloutArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration, rolloutArgs.SkipWaitRollout) resultCommands := strings.Join(b.GetLines()[:], "\n") resultExportCommands := strings.Join(b.GetExportLines()[:], "\n") @@ -96,6 +96,7 @@ func init() { f.BoolVar(&rolloutArgs.WaitHealthy, "wait-healthy", true, "Specify whether to wait for sync to be completed (in canary consider wait for suspended status)") f.StringVar(&rolloutArgs.WaitAdditionalFlags, "wait-additional-flags", "", "Specify additional flags for wait command, like --timeout , so on") f.BoolVar(&rolloutArgs.Debug, "debug", false, "Debug argocd command ( print commands to output )") + f.BoolVar(&rolloutArgs.SkipWaitRollout, "skip", false, "Skip wait rollout") _ = cobra.MarkFlagRequired(f, "k8s-context") _ = cobra.MarkFlagRequired(f, "rollout-name") diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index ae8a5cb..f01eccd 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -27,7 +27,7 @@ var Cmd = &cobra.Command{ } b.ExportExternalUrl(context.PluginArgoCredentials.Host, name) - b.Sync(syncArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration) + b.Sync(syncArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration, syncArgs.SkipWaitRollout) resultCommands := strings.Join(b.GetLines()[:], "\n") resultExportCommands := strings.Join(b.GetExportLines()[:], "\n") @@ -89,5 +89,5 @@ func init() { f.StringVar(&syncArgs.AdditionalFlags, "additional-flags", "", "Specify additional flags , like --grpc-web , so on") f.StringVar(&syncArgs.WaitAdditionalFlags, "wait-additional-flags", "", "Specify additional flags for wait command, like --timeout , so on") f.StringVar(&syncArgs.Revision, "revision", "", "Sync to a specific revision. Preserves parameter overrides") - + f.BoolVar(&syncArgs.SkipWaitRollout, "skip", false, "Skip wait rollout") } diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index e296587..d7159ce 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -14,6 +14,7 @@ type SyncArgs struct { AdditionalFlags string Revision string WaitAdditionalFlags string + SkipWaitRollout bool } type RolloutArgs struct { @@ -23,13 +24,14 @@ type RolloutArgs struct { WaitHealthy bool WaitAdditionalFlags string Debug bool + SkipWaitRollout bool } type Builder interface { Auth(host string, username string, password string) error - Sync(args *SyncArgs, name string, authToken string, host string, context string) + Sync(args *SyncArgs, name string, authToken string, host string, context string, skip bool) ExportExternalUrl(host string, name string) - Rollout(args *RolloutArgs, name string, authToken string, host string, context string) + Rollout(args *RolloutArgs, name string, authToken string, host string, context string, skip bool) GetLines() []string GetExportLines() []string @@ -64,12 +66,12 @@ func buildTokenFlags(authToken string, host string, prune bool) string { return cmd } -func (b *builder) Sync(args *SyncArgs, name string, authToken string, host string, context string) { +func (b *builder) Sync(args *SyncArgs, name string, authToken string, host string, context string, skip bool) { hostDomain, _ := getHostDomain(host) tokenFlags := buildTokenFlags(authToken, *hostDomain, args.Prune) tokenFlagsWithoutPrune := buildTokenFlags(authToken, *hostDomain, false) if args.WaitHealthy || args.WaitForSuspend { - b.lines = append(b.lines, GetCommandsFactory().CreateWaitRolloutCMD(name, context)) + b.lines = append(b.lines, GetCommandsFactory().CreateWaitRolloutCMD(name, context, skip)) } if args.Sync { @@ -101,7 +103,7 @@ func (b *builder) Sync(args *SyncArgs, name string, authToken string, host strin } } -func (b *builder) Rollout(args *RolloutArgs, name string, authToken string, host string, context string) { +func (b *builder) Rollout(args *RolloutArgs, name string, authToken string, host string, context string, skip bool) { hostDomain, _ := getHostDomain(host) b.lines = append(b.lines, "kubectl config get-contexts") b.lines = append(b.lines, fmt.Sprintf("kubectl config use-context \"%s\"", args.KubernetesContext)) @@ -109,7 +111,7 @@ func (b *builder) Rollout(args *RolloutArgs, name string, authToken string, host if args.WaitHealthy { if context != "" { - b.lines = append(b.lines, GetCommandsFactory().CreateWaitRolloutCMD(name, context)) + b.lines = append(b.lines, GetCommandsFactory().CreateWaitRolloutCMD(name, context, skip)) } tokenFlags := buildTokenFlags(authToken, *hostDomain, false) b.lines = append(b.lines, fmt.Sprintf("argocd app wait %s %s %s", name, args.WaitAdditionalFlags, tokenFlags)) diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index 166d2e2..8a964c7 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -29,7 +29,7 @@ func TestRolloutWithoutWaitHealthy(t *testing.T) { WaitHealthy: false, WaitAdditionalFlags: "", Debug: false, - }, "test", "token", "host", "context") + }, "test", "token", "host", "context", false) expectedLines := []string{ "#!/bin/bash -e", @@ -55,7 +55,7 @@ func TestRolloutWithWaitHealthy(t *testing.T) { WaitHealthy: true, WaitAdditionalFlags: "", Debug: false, - }, "test", "token", "host", "context") + }, "test", "token", "host", "context", false) expectedLines := []string{ "#!/bin/bash -e", @@ -63,7 +63,7 @@ func TestRolloutWithWaitHealthy(t *testing.T) { "kubectl config use-context \"kube-ctx\"", "kubectl argo rollouts promote \"app\" -n \"default\"", ` - cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s `, "argocd app wait test --auth-token token --server --insecure", @@ -84,7 +84,7 @@ func TestSyncWithoutWaitHealthy(t *testing.T) { WaitAdditionalFlags: "", Debug: false, Sync: true, - }, "test", "token", "host", "context") + }, "test", "token", "host", "context", false) expectedLines := []string{ "#!/bin/bash -e", @@ -106,12 +106,51 @@ func TestSyncWithWaitHealthy(t *testing.T) { WaitAdditionalFlags: "", Debug: false, Sync: true, - }, "test", "token", "host", "context") + }, "test", "token", "host", "context", false) expectedLines := []string{ "#!/bin/bash -e", ` - cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & + sleep 5s + `, + "argocd app sync test --auth-token token --server --insecure", + ` + { + set +e + argocd app wait test --auth-token token --server --insecure 2> /codefresh/volume/sync_error.log + } + if [[ $? -ne 0 ]]; then + ARGO_SYNC_ERROR=$(cat /codefresh/volume/sync_error.log | grep -i fatal) + fi + echo ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" + cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" + + wait + `, + } + + lines := builder.GetLines() + + if !reflect.DeepEqual(expectedLines, lines) { + t.Error("Sync commands is incorrect") + } + +} + +func TestSyncWithWaitHealthyAndSkip(t *testing.T) { + builder := New() + builder.Sync(&SyncArgs{ + WaitHealthy: true, + WaitAdditionalFlags: "", + Debug: false, + Sync: true, + }, "test", "token", "host", "context", true) + + expectedLines := []string{ + "#!/bin/bash -e", + ` + cf-argo-plugin wait-rollout test --skip --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s `, "argocd app sync test --auth-token token --server --insecure", diff --git a/pkg/builder/commands_factory.go b/pkg/builder/commands_factory.go index 1db83fa..36a52fa 100644 --- a/pkg/builder/commands_factory.go +++ b/pkg/builder/commands_factory.go @@ -9,9 +9,14 @@ func GetCommandsFactory() *CommandsFactory { return &CommandsFactory{} } -func (cf *CommandsFactory) CreateWaitRolloutCMD(name string, integration string) string { +func (cf *CommandsFactory) CreateWaitRolloutCMD(name string, integration string, skip bool) string { + skipFlag := "" + if skip { + skipFlag = "--skip" + } + return fmt.Sprintf(` - cf-argo-plugin wait-rollout %s --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=%s --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout %s %s --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=%s --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s - `, name, integration) + `, name, skipFlag, integration) } diff --git a/pkg/builder/commands_factory_test.go b/pkg/builder/commands_factory_test.go index fafb005..144bc5d 100644 --- a/pkg/builder/commands_factory_test.go +++ b/pkg/builder/commands_factory_test.go @@ -6,10 +6,10 @@ import ( func TestCreateWaitRolloutCMD(t *testing.T) { expectedCMD := ` - cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & + cf-argo-plugin wait-rollout test --cf-host=$CF_URL --cf-token=$CF_API_KEY --cf-integration=context --pipeline-id="$CF_PIPELINE_NAME" --build-id=$CF_BUILD_ID & sleep 5s ` - cmd := GetCommandsFactory().CreateWaitRolloutCMD("test", "context") + cmd := GetCommandsFactory().CreateWaitRolloutCMD("test", "context", false) if cmd != expectedCMD { t.Error("Wait rollout cmd is wrong") } From 34f11e360ecd9f4057cfafc55ca0072fdd25dd04 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 11 May 2022 12:37:34 +0300 Subject: [PATCH 12/43] pass integration as part of gitops tab --- VERSION | 2 +- cmd/processResult/wait_rollout_handler.go | 5 +++-- pkg/codefresh/api.go | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index ee1372d..7179039 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.2 +0.2.3 diff --git a/cmd/processResult/wait_rollout_handler.go b/cmd/processResult/wait_rollout_handler.go index 4c9491f..7c06ffa 100644 --- a/cmd/processResult/wait_rollout_handler.go +++ b/cmd/processResult/wait_rollout_handler.go @@ -33,7 +33,7 @@ func GetWaitRolloutHandler() *WaitRolloutHandler { })} } -func (waitRolloutHandler *WaitRolloutHandler) processNewHistoryId(historyId int64, name string) error { +func (waitRolloutHandler *WaitRolloutHandler) processNewHistoryId(historyId int64, name string, integration string) error { fmt.Println(fmt.Sprintf("Found new history id %v", historyId)) // wait before activity on codefresh will be created @@ -45,6 +45,7 @@ func (waitRolloutHandler *WaitRolloutHandler) processNewHistoryId(historyId int6 BuildId: waitRolloutArgsOptions.BuildId, HistoryId: historyId, ApplicationName: name, + Integration: integration, }) if updatedActivities != nil { @@ -73,7 +74,7 @@ func (waitRolloutHandler *WaitRolloutHandler) Handle(name string) error { currentHistoryId, _ := waitRolloutHandler.argo.GetLatestHistoryId(name) // we identify new rollout if currentHistoryId > historyId { - err := waitRolloutHandler.processNewHistoryId(currentHistoryId, name) + err := waitRolloutHandler.processNewHistoryId(currentHistoryId, name, context.PluginCodefreshCredentials.Integration) if err == nil { return nil } diff --git a/pkg/codefresh/api.go b/pkg/codefresh/api.go index f9c9d5e..d78dec0 100644 --- a/pkg/codefresh/api.go +++ b/pkg/codefresh/api.go @@ -53,6 +53,7 @@ type ArgoApplicationMetadata struct { BuildId string `json:"buildId"` HistoryId int64 `json:"historyId"` ApplicationName string `json:"name"` + Integration string `json:"integration"` } type Rollback struct { From 03d0f62d98fb50c8ce38c102ccf876df670a9d68 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Wed, 11 May 2022 12:45:20 +0300 Subject: [PATCH 13/43] fix test --- cmd/processResult/wait_rollout_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/processResult/wait_rollout_test.go b/cmd/processResult/wait_rollout_test.go index 092c13a..826bc0a 100644 --- a/cmd/processResult/wait_rollout_test.go +++ b/cmd/processResult/wait_rollout_test.go @@ -37,7 +37,7 @@ func (a *MockArgo) GetLatestHistoryId(application string) (int64, error) { func TestHandleWaitRollout(t *testing.T) { handler := &WaitRolloutHandler{codefresh: &MockCodefresh{}, argo: &MockArgo{}} - e := handler.processNewHistoryId(123, "test") + e := handler.processNewHistoryId(123, "test", "123") if e == nil { t.Error("Should fail with error") } From 609913c8e923677fc4ee803b109d49da13f4052d Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Thu, 21 Jul 2022 23:44:09 +0300 Subject: [PATCH 14/43] basic auth --- VERSION | 2 +- cmd/root/root.go | 5 +++++ cmd/sync/sync.go | 2 +- pkg/context/argo.go | 9 +++++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 7179039..abd4105 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.3 +0.2.4 diff --git a/cmd/root/root.go b/cmd/root/root.go index 876a287..f4e2dd3 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -21,6 +21,8 @@ type authContext struct { ArgoPassword string ArgoHost string ArgoToken string + + BasicAuth bool } var pluginAuthContext = &authContext{} @@ -49,6 +51,7 @@ func init() { pf.StringVar(&pluginAuthContext.ArgoPassword, "argo-password", "", "Password for argo cd, use only if you not provide integration") pf.StringVar(&pluginAuthContext.ArgoToken, "argo-token", "", "Token for argo cd, use only if you not provide integration") pf.StringVar(&pluginAuthContext.ArgoHost, "argo-host", "", "Host for argo cd, use only if you not provide integration") + pf.BoolVar(&pluginAuthContext.BasicAuth, "basic-auth", false, "Use ArgoCD username/password as primary credentials") pf.StringVar(&context.PluginOutConfig.CommandsFile, "out-commands-file", "", "Write main commands to file") pf.StringVar(&context.PluginOutConfig.ExportOutUrlCommand, "out-export-file", "", "Write export commands to file") @@ -85,6 +88,8 @@ func fetchArgoCredentials(cmd *cobra.Command, args []string) error { context.PluginArgoCredentials.Token = integration.Data.Token } + context.PluginArgoCredentials.BasicAuth = pluginAuthContext.BasicAuth + return nil } diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index f01eccd..b97e4a8 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -19,7 +19,7 @@ var Cmd = &cobra.Command{ name := args[0] b := builder.New() - if context.PluginArgoCredentials.Token == "" { + if context.PluginArgoCredentials.Token == "" || context.PluginArgoCredentials.BasicAuth { err := b.Auth(context.PluginArgoCredentials.Host, context.PluginArgoCredentials.Username, context.PluginArgoCredentials.Password) if err != nil { return err diff --git a/pkg/context/argo.go b/pkg/context/argo.go index 8b89015..5a23ad3 100644 --- a/pkg/context/argo.go +++ b/pkg/context/argo.go @@ -1,10 +1,11 @@ package context type ArgoCredentials struct { - Username string - Password string - Host string - Token string + Username string + Password string + Host string + Token string + BasicAuth bool } type OutConfig struct { From 56ff0fb437faf15c1581ac16e7732d684a0dcd31 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Fri, 22 Jul 2022 14:45:21 +0300 Subject: [PATCH 15/43] basic auth --- cmd/sync/sync.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index b97e4a8..8f6db44 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -20,6 +20,7 @@ var Cmd = &cobra.Command{ b := builder.New() if context.PluginArgoCredentials.Token == "" || context.PluginArgoCredentials.BasicAuth { + fmt.Println("Generate token use basic auth") err := b.Auth(context.PluginArgoCredentials.Host, context.PluginArgoCredentials.Username, context.PluginArgoCredentials.Password) if err != nil { return err From 7fee15f97ec64bf3b9f8b673720b4e8eea5fe5ac Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 4 Aug 2022 14:48:25 +0300 Subject: [PATCH 16/43] CR-9696 argocd-sync step finishes successfully when app is in Degraded state --- VERSION | 2 +- pkg/builder/builder.go | 5 ++++- pkg/builder/builder_test.go | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index abd4105..3a4036f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.4 +0.2.5 diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index d7159ce..7f47373 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -90,11 +90,14 @@ func (b *builder) Sync(args *SyncArgs, name string, authToken string, host strin } if [[ $? -ne 0 ]]; then ARGO_SYNC_ERROR=$(cat /codefresh/volume/sync_error.log | grep -i fatal) + ARGO_SYNC_FAILED=1 fi echo ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" - wait + if [[ -v ARGO_SYNC_FAILED ]]; then + exit 1 + fi `, name, args.WaitAdditionalFlags, tokenFlagsWithoutPrune) b.lines = append(b.lines, cmd) } diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index 8a964c7..900e81f 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -127,6 +127,9 @@ func TestSyncWithWaitHealthy(t *testing.T) { cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" wait + if [[ -v ARGO_SYNC_FAILED ]]; then + exit 1 + fi `, } @@ -166,6 +169,9 @@ func TestSyncWithWaitHealthyAndSkip(t *testing.T) { cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" wait + if [[ -v ARGO_SYNC_FAILED ]]; then + exit 1 + fi `, } From 3041c1575f1a82e472951952f13ba55d0d7a2741 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 4 Aug 2022 15:30:56 +0300 Subject: [PATCH 17/43] CR-9696 argocd-sync step finishes successfully when app is in Degraded state --- codefresh.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index 69b8ed3..f124a2a 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -20,16 +20,8 @@ steps: working_directory: ${{main_clone}} image: golang:1.14.2 commands: - - go get -u github.com/mcubik/goverreport - go test ./... -coverpkg=./... -race -coverprofile=coverage.out -covermode=atomic - codecov-report: - stage: "prepare" - title: Codecov report - type: codecov-reporter - arguments: - codecov_integration: cf-argo-plugin - fetch_envs: stage: prepare title: "Fetch envs" From 89e5189c91d5d855efd2de69866324e43e0cd467 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 4 Aug 2022 15:37:18 +0300 Subject: [PATCH 18/43] CR-9696 argocd-sync step finishes successfully when app is in Degraded state --- codefresh.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/codefresh.yaml b/codefresh.yaml index f124a2a..4aeca40 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -39,7 +39,6 @@ steps: - PushingToRegistries_with_tag: title: Pushing to Registry type: push From 85f18ead905d4d909fc1a8835fe8a33c641d1e83 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 4 Aug 2022 15:51:38 +0300 Subject: [PATCH 19/43] CR-9696 argocd-sync step finishes successfully when app is in Degraded state --- codefresh.yaml | 1 + pkg/builder/builder.go | 1 + pkg/builder/builder_test.go | 2 ++ 3 files changed, 4 insertions(+) diff --git a/codefresh.yaml b/codefresh.yaml index 4aeca40..f124a2a 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -39,6 +39,7 @@ steps: + PushingToRegistries_with_tag: title: Pushing to Registry type: push diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index 7f47373..7138b98 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -94,6 +94,7 @@ func (b *builder) Sync(args *SyncArgs, name string, authToken string, host strin fi echo ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" + wait if [[ -v ARGO_SYNC_FAILED ]]; then exit 1 diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index 900e81f..7b67a94 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -122,6 +122,7 @@ func TestSyncWithWaitHealthy(t *testing.T) { } if [[ $? -ne 0 ]]; then ARGO_SYNC_ERROR=$(cat /codefresh/volume/sync_error.log | grep -i fatal) + ARGO_SYNC_FAILED=1 fi echo ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" @@ -164,6 +165,7 @@ func TestSyncWithWaitHealthyAndSkip(t *testing.T) { } if [[ $? -ne 0 ]]; then ARGO_SYNC_ERROR=$(cat /codefresh/volume/sync_error.log | grep -i fatal) + ARGO_SYNC_FAILED=1 fi echo ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" From b983a858a7d2113ace8811d083326886f2128a6d Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 4 Aug 2022 20:58:22 +0300 Subject: [PATCH 20/43] CR-9696 argocd-sync step finishes successfully when app is in Degraded state --- VERSION | 2 +- cmd/sync/sync.go | 1 + pkg/builder/builder.go | 10 +++++++--- pkg/builder/builder_test.go | 10 ++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 3a4036f..53a75d6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.5 +0.2.6 diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index 8f6db44..1cded42 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -91,4 +91,5 @@ func init() { f.StringVar(&syncArgs.WaitAdditionalFlags, "wait-additional-flags", "", "Specify additional flags for wait command, like --timeout , so on") f.StringVar(&syncArgs.Revision, "revision", "", "Sync to a specific revision. Preserves parameter overrides") f.BoolVar(&syncArgs.SkipWaitRollout, "skip", false, "Skip wait rollout") + f.BoolVar(&syncArgs.Rollback, "rollback", false, "Specify whether to wait for sync to run rollback after sync") } diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index 7138b98..3691375 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -7,6 +7,7 @@ import ( type SyncArgs struct { Sync bool + Rollback bool WaitHealthy bool WaitForSuspend bool Debug bool @@ -96,12 +97,15 @@ func (b *builder) Sync(args *SyncArgs, name string, authToken string, host strin cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" wait - if [[ -v ARGO_SYNC_FAILED ]]; then - exit 1 - fi `, name, args.WaitAdditionalFlags, tokenFlagsWithoutPrune) b.lines = append(b.lines, cmd) } + if args.WaitHealthy && args.Rollback != true { + failedSyncCmd := fmt.Sprintf(` if [[ -v ARGO_SYNC_FAILED ]]; then + exit 1 + fi`) + b.lines = append(b.lines, failedSyncCmd) + } if args.WaitForSuspend { b.lines = append(b.lines, fmt.Sprintf("argocd app wait %s %s --suspended", name, tokenFlagsWithoutPrune)) } diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index 7b67a94..33dbcae 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -106,6 +106,7 @@ func TestSyncWithWaitHealthy(t *testing.T) { WaitAdditionalFlags: "", Debug: false, Sync: true, + Rollback: true, }, "test", "token", "host", "context", false) expectedLines := []string{ @@ -128,9 +129,6 @@ func TestSyncWithWaitHealthy(t *testing.T) { cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" wait - if [[ -v ARGO_SYNC_FAILED ]]; then - exit 1 - fi `, } @@ -171,10 +169,10 @@ func TestSyncWithWaitHealthyAndSkip(t *testing.T) { cf_export ARGO_SYNC_ERROR="$ARGO_SYNC_ERROR" wait - if [[ -v ARGO_SYNC_FAILED ]]; then - exit 1 - fi `, + ` if [[ -v ARGO_SYNC_FAILED ]]; then + exit 1 + fi`, } lines := builder.GetLines() From 81870b067e0a3e1671289a6b5c5888b1a09e25d6 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 17 Nov 2022 17:15:46 +0200 Subject: [PATCH 21/43] CR-15384 alpine to debian - official steps --- Dockerfile | 4 ++-- VERSION | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25f5850..8a06413 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,8 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM alpine -RUN apk --update add curl bash +FROM debian:bookworm-20221114 +RUN apt-get update -y && apt-get install curl bash -y RUN curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts RUN chmod +x /usr/local/bin/kubectl-argo-rollouts diff --git a/VERSION b/VERSION index 53a75d6..b003284 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.6 +0.2.7 From f51ac11dbcd0564ebc887245e7ffd099d4ef52e2 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Thu, 17 Nov 2022 17:37:03 +0200 Subject: [PATCH 22/43] CR-15384 alpine to debian - official steps --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8a06413..e0abea1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM debian:bookworm-20221114 +FROM ubuntu:jammy-20221101 RUN apt-get update -y && apt-get install curl bash -y RUN curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts RUN chmod +x /usr/local/bin/kubectl-argo-rollouts From ee2a941df32aa5433a23955cd539088757af50c9 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Fri, 18 Nov 2022 11:36:05 +0200 Subject: [PATCH 23/43] CR-15384 upgrade to debian bookworm --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e0abea1..8a06413 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM ubuntu:jammy-20221101 +FROM debian:bookworm-20221114 RUN apt-get update -y && apt-get install curl bash -y RUN curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts RUN chmod +x /usr/local/bin/kubectl-argo-rollouts From 220203766e812e0fdb8de5c91704692d1dc9185b Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Fri, 18 Nov 2022 12:38:53 +0200 Subject: [PATCH 24/43] CR-15384 upgrade to debian bookworm slim --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8a06413..7321b9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM debian:bookworm-20221114 +FROM debian:bookworm-20221114-slim RUN apt-get update -y && apt-get install curl bash -y RUN curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts RUN chmod +x /usr/local/bin/kubectl-argo-rollouts From 1bbc232844f55f95c7c12e67a939e743a0c4a5a4 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Fri, 18 Nov 2022 18:25:34 +0200 Subject: [PATCH 25/43] CR-15384 optimize layers --- Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7321b9a..0bc15d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,15 +10,15 @@ COPY ./ ./ RUN go build -o ./cf-argo-plugin FROM debian:bookworm-20221114-slim -RUN apt-get update -y && apt-get install curl bash -y -RUN curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts -RUN chmod +x /usr/local/bin/kubectl-argo-rollouts - -RUN curl -L https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl -RUN chmod +x /usr/local/bin/kubectl - -RUN curl -sSL https://github.com/argoproj/argo-cd/releases/download/v1.8.5/argocd-linux-amd64 -o /usr/local/bin/argocd -RUN chmod +x /usr/local/bin/argocd +RUN apt-get update -y && apt-get install curl bash -y \ + && curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ + && chmod +x /usr/local/bin/kubectl-argo-rollouts \ + && curl -L https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ + && chmod +x /usr/local/bin/kubectl \ + && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v1.8.5/argocd-linux-amd64 -o /usr/local/bin/argocd \ + && chmod +x /usr/local/bin/argocd \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* COPY --from=build /app/cf-argo-plugin /usr/local/bin/cf-argo-plugin ENTRYPOINT /bin/bash \ No newline at end of file From 86268e0d53bc32059c1aff3a72babbb0a7b1748f Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Mon, 21 Nov 2022 17:35:12 +0200 Subject: [PATCH 26/43] CR-15384 add symlink [[ --- Dockerfile | 1 + VERSION | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0bc15d3..a5b9068 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN apt-get update -y && apt-get install curl bash -y \ && chmod +x /usr/local/bin/kubectl \ && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v1.8.5/argocd-linux-amd64 -o /usr/local/bin/argocd \ && chmod +x /usr/local/bin/argocd \ + && apt-get install busybox -y && ln -s /bin/busybox /usr/bin/[[ \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/VERSION b/VERSION index b003284..a45be46 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.7 +0.2.8 From 81a0ebd4901ee66d3bb6d682dc8a03c85244cab6 Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Tue, 22 Nov 2022 16:26:20 +0200 Subject: [PATCH 27/43] CR-15384 fix image --- Dockerfile | 2 +- VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a5b9068..926f7e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM debian:bookworm-20221114-slim +FROM debian:bullseye-20221114-slim RUN apt-get update -y && apt-get install curl bash -y \ && curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ diff --git a/VERSION b/VERSION index a45be46..1866a36 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.8 +0.2.9 From cfdff0c6c15f4b59a0dfe1f79e323b3a2780dc5d Mon Sep 17 00:00:00 2001 From: Vadim Kharin Date: Tue, 22 Nov 2022 16:58:28 +0200 Subject: [PATCH 28/43] CR-15384 fix image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 926f7e0..07b2c6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM debian:bullseye-20221114-slim +FROM debian:bullseye-slim RUN apt-get update -y && apt-get install curl bash -y \ && curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ From 07b57633d531dcef49c362c4adbd601809c7affa Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Sat, 17 Dec 2022 18:51:33 +0200 Subject: [PATCH 29/43] token support --- VERSION | 2 +- cmd/root/root.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1866a36..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.9 +0.3.0 diff --git a/cmd/root/root.go b/cmd/root/root.go index f4e2dd3..c2011cd 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -86,6 +86,9 @@ func fetchArgoCredentials(cmd *cobra.Command, args []string) error { context.PluginArgoCredentials.Username = integration.Data.Username context.PluginArgoCredentials.Password = integration.Data.Password context.PluginArgoCredentials.Token = integration.Data.Token + } else if pluginAuthContext.ArgoToken != "" && pluginAuthContext.ArgoHost != "" { + context.PluginArgoCredentials.Token = pluginAuthContext.ArgoToken + context.PluginArgoCredentials.Host = pluginAuthContext.ArgoHost } context.PluginArgoCredentials.BasicAuth = pluginAuthContext.BasicAuth From 9d4ae730abe181d72380f31668cf24da00878cb0 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Sat, 17 Dec 2022 20:15:29 +0200 Subject: [PATCH 30/43] 2.4.8 argocd cli --- Dockerfile | 2 +- VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07b2c6e..59e24d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN apt-get update -y && apt-get install curl bash -y \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ && curl -L https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ && chmod +x /usr/local/bin/kubectl \ - && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v1.8.5/argocd-linux-amd64 -o /usr/local/bin/argocd \ + && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v2.4.8/argocd-linux-amd64 -o /usr/local/bin/argocd \ && chmod +x /usr/local/bin/argocd \ && apt-get install busybox -y && ln -s /bin/busybox /usr/bin/[[ \ && apt-get clean \ diff --git a/VERSION b/VERSION index 0d91a54..9e11b32 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 +0.3.1 From 33aa710ad78d0921c6be4d847f199df84bbccc89 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Mon, 16 Jan 2023 21:58:23 +0200 Subject: [PATCH 31/43] custom output url --- VERSION | 2 +- cmd/root/root.go | 1 + cmd/sync/sync.go | 7 ++++++- pkg/builder/builder.go | 7 +++++++ pkg/context/argo.go | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 0d91a54..9e11b32 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 +0.3.1 diff --git a/cmd/root/root.go b/cmd/root/root.go index c2011cd..8124b1c 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -55,6 +55,7 @@ func init() { pf.StringVar(&context.PluginOutConfig.CommandsFile, "out-commands-file", "", "Write main commands to file") pf.StringVar(&context.PluginOutConfig.ExportOutUrlCommand, "out-export-file", "", "Write export commands to file") + pf.StringVar(&context.PluginOutConfig.CustomOutputUrl, "custom-external-link", "", "Custom link that Codefresh is showing inside build view") rootCmd.AddCommand(sync.Cmd) rootCmd.AddCommand(rollout.Cmd) diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index 1cded42..a20fbd5 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -27,7 +27,12 @@ var Cmd = &cobra.Command{ } } - b.ExportExternalUrl(context.PluginArgoCredentials.Host, name) + if context.PluginOutConfig.CustomOutputUrl == "" { + b.ExportExternalUrl(context.PluginArgoCredentials.Host, name) + } else { + b.ExportCustomExternalUrl(context.PluginOutConfig.CustomOutputUrl) + } + b.Sync(syncArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration, syncArgs.SkipWaitRollout) resultCommands := strings.Join(b.GetLines()[:], "\n") diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index 3691375..e9dd9b8 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -32,6 +32,7 @@ type Builder interface { Auth(host string, username string, password string) error Sync(args *SyncArgs, name string, authToken string, host string, context string, skip bool) ExportExternalUrl(host string, name string) + ExportCustomExternalUrl(url string) Rollout(args *RolloutArgs, name string, authToken string, host string, context string, skip bool) GetLines() []string @@ -141,6 +142,12 @@ func (b *builder) ExportExternalUrl(host string, name string) { b.exportLines = append(b.exportLines, command) } +func (b *builder) ExportCustomExternalUrl(url string) { + command := fmt.Sprintf("cf_export runArgoCd_CF_OUTPUT_URL=\"%s\"", url) + b.lines = append(b.lines, command) + b.exportLines = append(b.exportLines, command) +} + func getHostDomain(host string) (*string, error) { u, err := url.Parse(host) if err != nil { diff --git a/pkg/context/argo.go b/pkg/context/argo.go index 5a23ad3..de62948 100644 --- a/pkg/context/argo.go +++ b/pkg/context/argo.go @@ -11,6 +11,7 @@ type ArgoCredentials struct { type OutConfig struct { CommandsFile string ExportOutUrlCommand string + CustomOutputUrl string } var PluginArgoCredentials = &ArgoCredentials{} From 7169b8240ebf5bb3ff5d0bd6791b57b0a8df6e95 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Mon, 16 Jan 2023 22:07:24 +0200 Subject: [PATCH 32/43] custom output url --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9e11b32..d15723f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.1 +0.3.2 From e587d6a135174e7dec50e20f25b8e46c7d515bde Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Mon, 16 Jan 2023 22:29:03 +0200 Subject: [PATCH 33/43] custom output url --- pkg/builder/builder_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/builder/builder_test.go b/pkg/builder/builder_test.go index 33dbcae..4b3f414 100644 --- a/pkg/builder/builder_test.go +++ b/pkg/builder/builder_test.go @@ -182,3 +182,18 @@ func TestSyncWithWaitHealthyAndSkip(t *testing.T) { } } + +func TestBuildExportCustomExternalUrl(t *testing.T) { + builder := New() + builder.ExportCustomExternalUrl("http://google.com") + lines := builder.GetExportLines() + + expectedLines := []string{ + "#!/bin/bash -e", + "cf_export runArgoCd_CF_OUTPUT_URL=\"http://google.com\"", + } + + if !reflect.DeepEqual(expectedLines, lines) { + t.Error("external url command is incorrect") + } +} From 7effef93fe998048db7df8eb2b0922dd1fcdd62a Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Tue, 17 Jan 2023 14:04:12 +0200 Subject: [PATCH 34/43] also build latest --- codefresh.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/codefresh.yaml b/codefresh.yaml index f124a2a..45c203d 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -62,6 +62,7 @@ steps: candidate: ${{build}} tags: - ${{VERSION}} + - latest when: branch: only: From f5611fb6e796b7f0cb86a633f59855c917354124 Mon Sep 17 00:00:00 2001 From: pashavictorovich Date: Tue, 17 Jan 2023 16:00:00 +0200 Subject: [PATCH 35/43] bump argo and rollouts --- Dockerfile | 4 ++-- VERSION | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 59e24d2..8f2680a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,11 +11,11 @@ RUN go build -o ./cf-argo-plugin FROM debian:bullseye-slim RUN apt-get update -y && apt-get install curl bash -y \ - && curl -L https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ + && curl -L https://github.com/argoproj/argo-rollouts/releases/download/v1.4.0/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ && curl -L https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ && chmod +x /usr/local/bin/kubectl \ - && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v2.4.8/argocd-linux-amd64 -o /usr/local/bin/argocd \ + && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v2.5.6/argocd-linux-amd64 -o /usr/local/bin/argocd \ && chmod +x /usr/local/bin/argocd \ && apt-get install busybox -y && ln -s /bin/busybox /usr/bin/[[ \ && apt-get clean \ diff --git a/VERSION b/VERSION index d15723f..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.2 +1.0.0 From 1ef96da0abdf0fe5c52c8d021b65042a67d6ff6a Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Thu, 9 Mar 2023 13:43:48 +0200 Subject: [PATCH 36/43] change quay --- codefresh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh.yaml b/codefresh.yaml index 45c203d..ad997ef 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -75,4 +75,4 @@ steps: PushingToQuayRegistry2: title: Pushing To Quay Registry registry: cfpluginmgr-quay - image_name: codefreshplugins/cf-argo-plugin + image_name: codefresh/cf-argo-plugin From acc959db6d2b4c4d264ed5dac56f86d0daa2bd17 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Thu, 9 Mar 2023 13:48:08 +0200 Subject: [PATCH 37/43] change quay --- codefresh.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codefresh.yaml b/codefresh.yaml index ad997ef..b783644 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -74,5 +74,5 @@ steps: image_name: codefresh/cf-argo-plugin PushingToQuayRegistry2: title: Pushing To Quay Registry - registry: cfpluginmgr-quay + registry: cf-quay image_name: codefresh/cf-argo-plugin From 9535a94fd3be8897be8a159a90724419b1bfd7a2 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 19 May 2023 12:27:08 +0300 Subject: [PATCH 38/43] sec: update base docker image and rollouts with argosync steps --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f2680a..e9759ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,13 +9,13 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM debian:bullseye-slim +FROM debian:bullseye-20230502-slim RUN apt-get update -y && apt-get install curl bash -y \ - && curl -L https://github.com/argoproj/argo-rollouts/releases/download/v1.4.0/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ + && curl -L https://github.com/argoproj/argo-rollouts/releases/download/v1.5.0/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ && curl -L https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ && chmod +x /usr/local/bin/kubectl \ - && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v2.5.6/argocd-linux-amd64 -o /usr/local/bin/argocd \ + && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v2.7.1/argocd-linux-amd64 -o /usr/local/bin/argocd \ && chmod +x /usr/local/bin/argocd \ && apt-get install busybox -y && ln -s /bin/busybox /usr/bin/[[ \ && apt-get clean \ From dbf7b931f237cea53bd732ec3432fded1d48f7f4 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 19 May 2023 13:20:19 +0300 Subject: [PATCH 39/43] sec: move from curl to wget --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e9759ea..76f8f70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,12 +10,12 @@ COPY ./ ./ RUN go build -o ./cf-argo-plugin FROM debian:bullseye-20230502-slim -RUN apt-get update -y && apt-get install curl bash -y \ - && curl -L https://github.com/argoproj/argo-rollouts/releases/download/v1.5.0/kubectl-argo-rollouts-linux-amd64 -o /usr/local/bin/kubectl-argo-rollouts \ +RUN apt-get update -y && apt-get install wget bash -y \ + && wget -O /usr/local/bin/kubectl-argo-rollouts https://github.com/argoproj/argo-rollouts/releases/download/v1.5.0/kubectl-argo-rollouts-linux-amd64 \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ - && curl -L https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ + && wget -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.17.4/bin/linux/amd64/kubectl \ && chmod +x /usr/local/bin/kubectl \ - && curl -sSL https://github.com/argoproj/argo-cd/releases/download/v2.7.1/argocd-linux-amd64 -o /usr/local/bin/argocd \ + && wget -O /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/v2.7.1/argocd-linux-amd64 \ && chmod +x /usr/local/bin/argocd \ && apt-get install busybox -y && ln -s /bin/busybox /usr/bin/[[ \ && apt-get clean \ From ea5a3d78bf7637ad9007e62fb6f6f56d8111e09c Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 19 May 2023 13:26:38 +0300 Subject: [PATCH 40/43] update VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3eefcb9..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 From 64da54bad755c185645cf7876e59f88c5ce10bd8 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 19 May 2023 13:31:30 +0300 Subject: [PATCH 41/43] change image version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 76f8f70..a488949 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM debian:bullseye-20230502-slim +FROM debian:11-slim RUN apt-get update -y && apt-get install wget bash -y \ && wget -O /usr/local/bin/kubectl-argo-rollouts https://github.com/argoproj/argo-rollouts/releases/download/v1.5.0/kubectl-argo-rollouts-linux-amd64 \ && chmod +x /usr/local/bin/kubectl-argo-rollouts \ From b4e9afa4490ad28e985e6be6d6d796cc968cf722 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Mon, 14 Aug 2023 18:16:46 +0300 Subject: [PATCH 42/43] trigger commit --- codefresh.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/codefresh.yaml b/codefresh.yaml index b783644..f67b485 100644 --- a/codefresh.yaml +++ b/codefresh.yaml @@ -37,9 +37,6 @@ steps: dockerfile: "Dockerfile" stage: "build" - - - PushingToRegistries_with_tag: title: Pushing to Registry type: push From cea1e07027e910cfa0a137cd9aab42cf845edfa6 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Mon, 14 Aug 2023 18:31:31 +0300 Subject: [PATCH 43/43] version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1