From 95216027ff361564080281f4bb2c1e7d241978fd Mon Sep 17 00:00:00 2001 From: Nikita Podshivalov Date: Mon, 14 Nov 2022 16:42:33 +0300 Subject: [PATCH] added `force` flag for sls deploy --- internal/commands/deploy.go | 4 ++++ internal/config/app.go | 1 + internal/manager/serverless/native.go | 6 +++++- internal/schema/ize-spec.json | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/commands/deploy.go b/internal/commands/deploy.go index 3ec4fa12..47319df9 100644 --- a/internal/commands/deploy.go +++ b/internal/commands/deploy.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "github.com/aws/aws-sdk-go/aws" "github.com/hazelops/ize/internal/config" "github.com/hazelops/ize/internal/manager" @@ -20,6 +21,7 @@ type DeployOptions struct { Image string TaskDefinitionRevision string Unsafe bool + Force bool } var deployLongDesc = templates.LongDesc(` @@ -85,6 +87,7 @@ func NewCmdDeploy(project *config.Project) *cobra.Command { cmd.Flags().StringVar(&o.TaskDefinitionRevision, "task-definition-revision", "", "set task definition revision (ECS only)") cmd.Flags().BoolVar(&o.Unsafe, "unsafe", false, "set unsafe healthcheck options (accelerates deployment if possible)") + cmd.Flags().BoolVar(&o.Force, "force", false, "forces a deployment to take place (only serverless)") return cmd } @@ -141,6 +144,7 @@ func (o *DeployOptions) Run() error { if app, ok := o.Config.Serverless[o.AppName]; ok { app.Name = o.AppName + app.Force = o.Force m = &serverless.Manager{ Project: o.Config, App: app, diff --git a/internal/config/app.go b/internal/config/app.go index 6a5b884d..c0ff8a39 100644 --- a/internal/config/app.go +++ b/internal/config/app.go @@ -24,6 +24,7 @@ type Serverless struct { Path string `mapstructure:",omitempty"` SLSNodeModuleCacheMount string `mapstructure:",omitempty"` CreateDomain bool `mapstructure:"create_domain"` + Force bool `mapstructure:"force"` Env []string `mapstructure:",omitempty"` Icon string `mapstructure:"icon,omitempty"` UseYarn bool `mapstructure:"use_yarn,omitempty"` diff --git a/internal/manager/serverless/native.go b/internal/manager/serverless/native.go index 4788bd99..e01c4c76 100644 --- a/internal/manager/serverless/native.go +++ b/internal/manager/serverless/native.go @@ -141,6 +141,11 @@ func (sls *Manager) runDeploy(w io.Writer) error { command = npmToYarn(command) } + if sls.App.Force { + command += ` \ + --force` + } + logrus.SetOutput(w) logrus.Debugf("command: %s", command) @@ -258,7 +263,6 @@ func (sls *Manager) runRemoveDomain(w io.Writer) error { --stage %s`, nvmDir, sls.App.NodeVersion, sls.App.AwsRegion, sls.App.AwsProfile, sls.Project.Env) - if sls.App.UseYarn { command = npmToYarn(command) diff --git a/internal/schema/ize-spec.json b/internal/schema/ize-spec.json index dfaa1648..0a4cda92 100644 --- a/internal/schema/ize-spec.json +++ b/internal/schema/ize-spec.json @@ -419,6 +419,10 @@ "type": "boolean", "description": "(optional) execute commands using yarn" }, + "force": { + "type": "boolean", + "description": "(optional) forces a deployment to take place" + }, "aws_region" : { "type": "string", "description": "(optional) Serverless-specific AWS Region of this environment should be specified here. Normally global AWS_REGION is used."