diff --git a/VERSION b/VERSION index 3eefcb9..7dea76e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.0.1 diff --git a/cmd/rollout/rollout.go b/cmd/rollout/rollout.go index 538f383..3071c47 100644 --- a/cmd/rollout/rollout.go +++ b/cmd/rollout/rollout.go @@ -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") @@ -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") diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index e9dd9b8..2e76aca 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -26,6 +26,7 @@ type RolloutArgs struct { WaitAdditionalFlags string Debug bool SkipWaitRollout bool + ExportRolloutStatus bool } type Builder interface { @@ -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 @@ -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 {