diff --git a/Dockerfile b/Dockerfile index 25f5850..a488949 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,17 @@ WORKDIR /app COPY ./ ./ RUN go build -o ./cf-argo-plugin -FROM alpine -RUN apk --update add curl bash -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 +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 \ + && 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 \ + && 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 \ + && 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 diff --git a/VERSION b/VERSION index 0c62199..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +1.1.1 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") } 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/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") } 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/root/root.go b/cmd/root/root.go index 876a287..8124b1c 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,9 +51,11 @@ 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") + 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) @@ -83,8 +87,13 @@ 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 + return nil } diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index ae8a5cb..a20fbd5 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -19,15 +19,21 @@ var Cmd = &cobra.Command{ name := args[0] b := builder.New() - if context.PluginArgoCredentials.Token == "" { + 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 } } - b.ExportExternalUrl(context.PluginArgoCredentials.Host, name) - b.Sync(syncArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration) + 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") resultExportCommands := strings.Join(b.GetExportLines()[:], "\n") @@ -89,5 +95,6 @@ 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") + f.BoolVar(&syncArgs.Rollback, "rollback", false, "Specify whether to wait for sync to run rollback after sync") } diff --git a/codefresh.yaml b/codefresh.yaml index 816fbfd..f67b485 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" @@ -45,10 +37,7 @@ steps: dockerfile: "Dockerfile" stage: "build" - - - -PushingToRegistries_with_tag: + PushingToRegistries_with_tag: title: Pushing to Registry type: push candidate: ${{build}} @@ -64,26 +53,23 @@ PushingToRegistries_with_tag: registry: cfpluginmgr-quay image_name: codefreshplugins/cf-argo-plugin - PushingToRegistries: - title: Pushing to Registry + title: Pushing to Registry only master type: push candidate: ${{build}} tags: - ${{VERSION}} + - latest when: branch: 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 - - - + registry: cf-quay + image_name: codefresh/cf-argo-plugin diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index e296587..e9dd9b8 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 @@ -14,6 +15,7 @@ type SyncArgs struct { AdditionalFlags string Revision string WaitAdditionalFlags string + SkipWaitRollout bool } type RolloutArgs struct { @@ -23,13 +25,15 @@ 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) + ExportCustomExternalUrl(url string) + Rollout(args *RolloutArgs, name string, authToken string, host string, context string, skip bool) GetLines() []string GetExportLines() []string @@ -64,12 +68,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 { @@ -88,6 +92,7 @@ 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" @@ -96,12 +101,18 @@ func (b *builder) Sync(args *SyncArgs, name string, authToken string, host strin `, 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)) } } -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 +120,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)) @@ -131,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/builder/builder_test.go b/pkg/builder/builder_test.go index fba1190..4b3f414 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,13 @@ func TestSyncWithWaitHealthy(t *testing.T) { WaitAdditionalFlags: "", Debug: false, Sync: true, - }, "test", "token", "host", "context") + Rollback: true, + }, "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", @@ -122,6 +123,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" @@ -137,3 +139,61 @@ func TestSyncWithWaitHealthy(t *testing.T) { } } + +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", + ` + { + 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) + 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`, + } + + lines := builder.GetLines() + + if !reflect.DeepEqual(expectedLines, lines) { + t.Error("Sync commands is incorrect") + } + +} + +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") + } +} diff --git a/pkg/builder/commands_factory.go b/pkg/builder/commands_factory.go index 657ddd6..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 a2f27eb..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") } diff --git a/pkg/codefresh/api.go b/pkg/codefresh/api.go index 522a2c2..d78dec0 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" @@ -52,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 { @@ -95,10 +97,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}, } } diff --git a/pkg/context/argo.go b/pkg/context/argo.go index 8b89015..de62948 100644 --- a/pkg/context/argo.go +++ b/pkg/context/argo.go @@ -1,15 +1,17 @@ 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 { CommandsFile string ExportOutUrlCommand string + CustomOutputUrl string } var PluginArgoCredentials = &ArgoCredentials{}