diff --git a/cmd/plural/cd_services.go b/cmd/plural/cd_services.go index 5567bc9e..30115b2d 100644 --- a/cmd/plural/cd_services.go +++ b/cmd/plural/cd_services.go @@ -39,6 +39,7 @@ func (p *Plural) cdServiceCommands() []cli.Command { cli.StringFlag{Name: "git-ref", Usage: "git ref, can be branch, tag or commit sha", Required: true}, cli.StringFlag{Name: "git-folder", Usage: "folder within the source tree where manifests are located", Required: true}, cli.StringFlag{Name: "kustomize-folder", Usage: "folder within the kustomize file is located"}, + cli.BoolFlag{Name: "dry-run", Usage: "dry run mode"}, cli.StringSliceFlag{ Name: "conf", Usage: "config name value", @@ -62,6 +63,7 @@ func (p *Plural) cdServiceCommands() []cli.Command { Name: "conf", Usage: "config name value", }, + cli.BoolFlag{Name: "dry-run", Usage: "dry run mode"}, }, }, { @@ -129,6 +131,7 @@ func (p *Plural) handleCreateClusterService(c *cli.Context) error { repoId := c.String("repo-id") gitRef := c.String("git-ref") gitFolder := c.String("git-folder") + dryRun := c.Bool("dry-run") attributes := gqlclient.ServiceDeploymentAttributes{ Name: name, Namespace: namespace, @@ -139,6 +142,7 @@ func (p *Plural) handleCreateClusterService(c *cli.Context) error { Folder: gitFolder, }, Configuration: []*gqlclient.ConfigAttributes{}, + DryRun: lo.ToPtr(dryRun), } if c.String("kustomize-folder") != "" { @@ -266,6 +270,9 @@ func (p *Plural) handleUpdateClusterService(c *cli.Context) error { }, Configuration: []*gqlclient.ConfigAttributes{}, } + if existing.DryRun != nil { + attributes.DryRun = existing.DryRun + } if existing.Kustomize != nil { attributes.Kustomize = &gqlclient.KustomizeAttributes{ Path: existing.Kustomize.Path, @@ -312,6 +319,11 @@ func (p *Plural) handleUpdateClusterService(c *cli.Context) error { Path: c.String("kustomize-folder"), } } + if c.IsSet("dry-run") { + dryRun := c.Bool("dry-run") + attributes.DryRun = &dryRun + } + sd, err := p.ConsoleClient.UpdateClusterService(serviceId, serviceName, clusterName, attributes) if err != nil { return err diff --git a/go.mod b/go.mod index 881bae37..0d128786 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/packethost/packngo v0.29.0 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pluralsh/cluster-api-migration v0.2.15 - github.com/pluralsh/console-client-go v0.0.70 + github.com/pluralsh/console-client-go v0.0.80 github.com/pluralsh/gqlclient v1.11.0 github.com/pluralsh/plural-operator v0.5.5 github.com/pluralsh/polly v0.1.1 @@ -75,6 +75,7 @@ require ( golang.org/x/mod v0.10.0 golang.org/x/oauth2 v0.8.0 gopkg.in/yaml.v2 v2.4.0 + gopkg.in/yaml.v3 v3.0.1 helm.sh/helm/v3 v3.11.2 k8s.io/api v0.26.4 k8s.io/apimachinery v0.26.4 @@ -284,7 +285,6 @@ require ( gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/cluster-bootstrap v0.25.3 // indirect k8s.io/kops v1.25.2 // indirect k8s.io/kube-aggregator v0.25.2 // indirect diff --git a/go.sum b/go.sum index c83ba757..372734bf 100644 --- a/go.sum +++ b/go.sum @@ -1428,8 +1428,8 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pluralsh/cluster-api-migration v0.2.15 h1:TIfusD+wnhZTGmwNfIlKlKJOT2dE3rUaZawDJw98GjY= github.com/pluralsh/cluster-api-migration v0.2.15/go.mod h1:J6lEvC/70KouikX16mE331cxc3y3sBwtmfHGwZqu06w= -github.com/pluralsh/console-client-go v0.0.70 h1:itLfOGpIpt+sASS+X0FTmB/OF3vUY6YnUGx9a+j34So= -github.com/pluralsh/console-client-go v0.0.70/go.mod h1:u/RjzXE3wtl3L6wiWxwhQHSpxFX46+EYvpkss2mALN4= +github.com/pluralsh/console-client-go v0.0.80 h1:jL0LE6YnddXz4j6LLBt7hRyIOOhxdVbvC6fvLlm8lMA= +github.com/pluralsh/console-client-go v0.0.80/go.mod h1:u/RjzXE3wtl3L6wiWxwhQHSpxFX46+EYvpkss2mALN4= github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E= github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s= github.com/pluralsh/gqlclient v1.11.0 h1:FfXW7FiEJLHOfTAa7NxDb8jb3aMZNIpCAcG+bg8uHYA= diff --git a/pkg/console/describe.go b/pkg/console/describe.go index 3e68b39e..14234910 100644 --- a/pkg/console/describe.go +++ b/pkg/console/describe.go @@ -84,6 +84,11 @@ func DescribeService(service *consoleclient.ServiceDeploymentExtended) (string, if service.DeletedAt != nil { w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", *service.DeletedAt) } + dryRun := false + if service.DryRun != nil { + dryRun = *service.DryRun + } + w.Write(LEVEL_0, "Dry run:\t%v\n", dryRun) w.Write(LEVEL_0, "Git:\t\n") w.Write(LEVEL_1, "Ref:\t%s\n", service.Git.Ref) w.Write(LEVEL_1, "Folder:\t%s\n", service.Git.Folder)