Skip to content
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

export rollout status in the end #37

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
5 changes: 5 additions & 0 deletions cmd/rollout/rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var Cmd = &cobra.Command{
b.ExportExternalUrl(context.PluginArgoCredentials.Host, name)
b.Rollout(rolloutArgs, name, context.PluginArgoCredentials.Token, context.PluginArgoCredentials.Host, context.PluginCodefreshCredentials.Integration, rolloutArgs.SkipWaitRollout)

if rolloutArgs.ExportRolloutStatus {
b.ExportRolloutStatus(rolloutArgs)
}

resultCommands := strings.Join(b.GetLines()[:], "\n")
resultExportCommands := strings.Join(b.GetExportLines()[:], "\n")

Expand Down Expand Up @@ -97,6 +101,7 @@ func init() {
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")
f.BoolVar(&rolloutArgs.ExportRolloutStatus, "export-rollout-status", false, "Export rollout status")

_ = cobra.MarkFlagRequired(f, "k8s-context")
_ = cobra.MarkFlagRequired(f, "rollout-name")
Expand Down
6 changes: 6 additions & 0 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type RolloutArgs struct {
WaitAdditionalFlags string
Debug bool
SkipWaitRollout bool
ExportRolloutStatus bool
}

type Builder interface {
Expand All @@ -34,6 +35,7 @@ type Builder interface {
ExportExternalUrl(host string, name string)
ExportCustomExternalUrl(url string)
Rollout(args *RolloutArgs, name string, authToken string, host string, context string, skip bool)
ExportRolloutStatus(args *RolloutArgs)

GetLines() []string
GetExportLines() []string
Expand Down Expand Up @@ -148,6 +150,10 @@ func (b *builder) ExportCustomExternalUrl(url string) {
b.exportLines = append(b.exportLines, command)
}

func (b *builder) ExportRolloutStatus(args *RolloutArgs) {
b.lines = append(b.lines, fmt.Sprintf("kubectl argo rollouts status \"%s\" -n \"%s\" | { read status; echo rollout_status=$status >> /meta/env_vars_to_export; }", args.RolloutName, args.RolloutNamespace))
}

func getHostDomain(host string) (*string, error) {
u, err := url.Parse(host)
if err != nil {
Expand Down