Skip to content

Merge pull request #16 from codefresh-io/move-to-quay #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 62 commits into
base: move-to-quay
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3c8d356
Merge pull request #16 from codefresh-io/move-to-quay
Jul 20, 2021
c4e2af2
bad indentation
Jul 20, 2021
4f0595a
Merge pull request #18 from codefresh-io/move-to-quay2
Jul 20, 2021
05367f6
add insecure mode
pasha-codefresh Sep 24, 2021
7ded731
Merge remote-tracking branch 'origin/master'
pasha-codefresh Sep 24, 2021
6dd4c1c
fix yaml
pasha-codefresh Sep 24, 2021
4e0bc12
rename
pasha-codefresh Sep 24, 2021
eb3eaea
rename
pasha-codefresh Sep 24, 2021
61a7967
rename
pasha-codefresh Sep 24, 2021
b7ab1b5
CR-7137
olegz-codefresh Oct 18, 2021
0cd0da9
CR-7137
olegz-codefresh Oct 18, 2021
38212f3
Merge pull request #19 from codefresh-io/CR-7137
olegz-codefresh Oct 18, 2021
80d72eb
push to quay
pasha-codefresh Oct 19, 2021
aa37322
Merge remote-tracking branch 'origin/master'
pasha-codefresh Oct 19, 2021
e86b46d
add skip flag
pasha-codefresh Nov 17, 2021
a342e4c
add skip flag
pasha-codefresh Nov 17, 2021
34f11e3
pass integration as part of gitops tab
pasha-codefresh May 11, 2022
03d0f62
fix test
pasha-codefresh May 11, 2022
62a1ae4
Merge pull request #23 from codefresh-io/pass-integration
pasha-codefresh May 11, 2022
609913c
basic auth
pasha-codefresh Jul 21, 2022
ecc0a08
Merge pull request #25 from codefresh-io/basic-auth-flag-support
pasha-codefresh Jul 22, 2022
56ff0fb
basic auth
pasha-codefresh Jul 22, 2022
7fee15f
CR-9696 argocd-sync step finishes successfully when app is in Degrade…
vadim-kharin-codefresh Aug 4, 2022
3041c15
CR-9696 argocd-sync step finishes successfully when app is in Degrade…
vadim-kharin-codefresh Aug 4, 2022
89e5189
CR-9696 argocd-sync step finishes successfully when app is in Degrade…
vadim-kharin-codefresh Aug 4, 2022
85f18ea
CR-9696 argocd-sync step finishes successfully when app is in Degrade…
vadim-kharin-codefresh Aug 4, 2022
001fe1c
Merge pull request #26 from codefresh-io/CR-9696
vadim-kharin-codefresh Aug 4, 2022
b983a85
CR-9696 argocd-sync step finishes successfully when app is in Degrade…
vadim-kharin-codefresh Aug 4, 2022
9fdcae6
Merge pull request #27 from codefresh-io/CR-9696-2
vadim-kharin-codefresh Aug 4, 2022
81870b0
CR-15384 alpine to debian - official steps
vadim-kharin-codefresh Nov 17, 2022
f51ac11
CR-15384 alpine to debian - official steps
vadim-kharin-codefresh Nov 17, 2022
ee2a941
CR-15384 upgrade to debian bookworm
vadim-kharin-codefresh Nov 18, 2022
2202037
CR-15384 upgrade to debian bookworm slim
vadim-kharin-codefresh Nov 18, 2022
1bbc232
CR-15384 optimize layers
vadim-kharin-codefresh Nov 18, 2022
18aaf22
Merge pull request #29 from codefresh-io/CR-15384
vadim-kharin-codefresh Nov 21, 2022
86268e0
CR-15384 add symlink [[
vadim-kharin-codefresh Nov 21, 2022
ce536c7
Merge pull request #30 from codefresh-io/CR-15384-symlink-fix
vadim-kharin-codefresh Nov 21, 2022
81a0ebd
CR-15384 fix image
vadim-kharin-codefresh Nov 22, 2022
cfdff0c
CR-15384 fix image
vadim-kharin-codefresh Nov 22, 2022
3305a06
Merge pull request #31 from codefresh-io/CR-15384-image-fix
vadim-kharin-codefresh Dec 1, 2022
07b5763
token support
pasha-codefresh Dec 17, 2022
ef5c558
Merge pull request #32 from codefresh-io/CR-token-support
pasha-codefresh Dec 17, 2022
9d4ae73
2.4.8 argocd cli
pasha-codefresh Dec 17, 2022
3bcf22b
Merge pull request #33 from codefresh-io/CR-2_4-argocd
pasha-codefresh Dec 17, 2022
33aa710
custom output url
pasha-codefresh Jan 16, 2023
7169b82
custom output url
pasha-codefresh Jan 16, 2023
fa77c85
Merge branch 'master' of github.com:codefresh-io/cf-argo-plugin into …
pasha-codefresh Jan 16, 2023
e587d6a
custom output url
pasha-codefresh Jan 16, 2023
6429822
Merge pull request #34 from codefresh-io/CR-custom-output
pasha-codefresh Jan 17, 2023
7effef9
also build latest
pasha-codefresh Jan 17, 2023
f5611fb
bump argo and rollouts
pasha-codefresh Jan 17, 2023
e63b068
Merge pull request #35 from codefresh-io/CR-upgrade-argocd-rollouts
pasha-codefresh Jan 17, 2023
1ef96da
change quay
pasha-codefresh Mar 9, 2023
acc959d
change quay
pasha-codefresh Mar 9, 2023
9535a94
sec: update base docker image and rollouts with argosync steps
pasha-codefresh May 19, 2023
dbf7b93
sec: move from curl to wget
pasha-codefresh May 19, 2023
ea5a3d7
update VERSION
pasha-codefresh May 19, 2023
64da54b
change image version
pasha-codefresh May 19, 2023
86d68d3
Merge pull request #38 from codefresh-io/CR-18664
pasha-codefresh May 19, 2023
b4e9afa
trigger commit
andrii-codefresh Aug 14, 2023
cea1e07
version
andrii-codefresh Aug 14, 2023
25ae4a0
Merge pull request #39 from codefresh-io/CR-19628-snyk
andrii-codefresh Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
1.1.1
5 changes: 5 additions & 0 deletions cmd/processResult/wait_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
var waitRolloutArgsOptions struct {
PipelineId string
BuildId string
Skip bool
}

var WaitRolloutCmd = &cobra.Command{
Expand All @@ -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])
},
}
Expand All @@ -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")
}
5 changes: 3 additions & 2 deletions cmd/processResult/wait_rollout_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,6 +45,7 @@ func (waitRolloutHandler *WaitRolloutHandler) processNewHistoryId(historyId int6
BuildId: waitRolloutArgsOptions.BuildId,
HistoryId: historyId,
ApplicationName: name,
Integration: integration,
})

if updatedActivities != nil {
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/processResult/wait_rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/rollout/rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type authContext struct {
ArgoPassword string
ArgoHost string
ArgoToken string

BasicAuth bool
}

var pluginAuthContext = &authContext{}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
15 changes: 11 additions & 4 deletions cmd/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
}
28 changes: 7 additions & 21 deletions codefresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -45,10 +37,7 @@ steps:
dockerfile: "Dockerfile"
stage: "build"




PushingToRegistries_with_tag:
PushingToRegistries_with_tag:
title: Pushing to Registry
type: push
candidate: ${{build}}
Expand All @@ -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
29 changes: 23 additions & 6 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (

type SyncArgs struct {
Sync bool
Rollback bool
WaitHealthy bool
WaitForSuspend bool
Debug bool
Prune bool
AdditionalFlags string
Revision string
WaitAdditionalFlags string
SkipWaitRollout bool
}

type RolloutArgs struct {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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"
Expand All @@ -96,20 +101,26 @@ 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))
b.lines = append(b.lines, fmt.Sprintf("kubectl argo rollouts promote \"%s\" -n \"%s\"", args.RolloutName, args.RolloutNamespace))

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))
Expand All @@ -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 {
Expand Down
Loading