Skip to content
Merged
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
7 changes: 0 additions & 7 deletions internal/pkg/cli/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,6 @@ func (o *deployOpts) maybeDeployEnv() error {
if !o.envExistsInWs {
return nil
}
if o.deployEnv == nil {
v, err := o.prompt.Confirm(fmt.Sprintf("Would you like to deploy the environment %q before deploying your workload?", o.envName), "", prompt.WithFinalMessage("Deploy environment:"))
if err != nil {
return fmt.Errorf("confirm env deployment: %w", err)
}
o.deployEnv = aws.Bool(v)
}

if aws.BoolValue(o.deployEnv) {
cmd, err := o.newDeployEnvCmd(o)
Expand Down
34 changes: 3 additions & 31 deletions internal/pkg/cli/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,51 +945,26 @@ func Test_deployOpts_maybeInitEnv(t *testing.T) {
}

func Test_deployOpts_maybeDeployEnv(t *testing.T) {
mockError := errors.New("some error")
tests := map[string]struct {
envExistsInWs bool
deployEnv *bool

mockPrompt func(m *mocks.Mockprompter)
mockDeployEnvCmd func(m *mocks.Mockcmd)

wantErr string
}{
"env does not exist in ws": {
envExistsInWs: false,
mockPrompt: func(m *mocks.Mockprompter) {},
mockDeployEnvCmd: func(m *mocks.Mockcmd) {},
},
"env exists; deploy false when prompted": {
envExistsInWs: true,
mockPrompt: func(m *mocks.Mockprompter) {
m.EXPECT().Confirm(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, nil)
},
"env exists in app, flag set false": {
envExistsInWs: true,
deployEnv: aws.Bool(false),
mockDeployEnvCmd: func(m *mocks.Mockcmd) {},
},
"env exists; deploy true when prompted": {
envExistsInWs: true,
mockPrompt: func(m *mocks.Mockprompter) {
m.EXPECT().Confirm(gomock.Any(), gomock.Any(), gomock.Any()).Return(true, nil)
},
mockDeployEnvCmd: func(m *mocks.Mockcmd) {
m.EXPECT().Validate().Return(nil)
m.EXPECT().Ask().Return(nil)
m.EXPECT().Execute().Return(nil)
},
},
"error selecting whether to deploy env": {
envExistsInWs: true,
mockPrompt: func(m *mocks.Mockprompter) {
m.EXPECT().Confirm(gomock.Any(), gomock.Any(), gomock.Any()).Return(false, mockError)
},
mockDeployEnvCmd: func(m *mocks.Mockcmd) {},
wantErr: "confirm env deployment: some error",
},
"env exists; deploy flag set": {
envExistsInWs: true,
deployEnv: aws.Bool(true),
mockPrompt: func(m *mocks.Mockprompter) {},
mockDeployEnvCmd: func(m *mocks.Mockcmd) {
m.EXPECT().Validate().Return(nil)
m.EXPECT().Ask().Return(nil)
Expand All @@ -1002,10 +977,8 @@ func Test_deployOpts_maybeDeployEnv(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockPrompt := mocks.NewMockprompter(ctrl)
mockDeployEnvCmd := mocks.NewMockcmd(ctrl)

tc.mockPrompt(mockPrompt)
tc.mockDeployEnvCmd(mockDeployEnvCmd)

o := &deployOpts{
Expand All @@ -1017,7 +990,6 @@ func Test_deployOpts_maybeDeployEnv(t *testing.T) {
deployEnv: tc.deployEnv,
},
envExistsInWs: tc.envExistsInWs,
prompt: mockPrompt,
newDeployEnvCmd: func(o *deployOpts) (cmd, error) {
return mockDeployEnvCmd, nil
},
Expand Down
4 changes: 2 additions & 2 deletions site/content/docs/commands/deploy.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ rollback of the stack via the AWS console or AWS CLI before the next deployment.
## Examples
Deploys a service named "frontend" to a "test" environment.
```console
$ copilot deploy --name frontend --env test --deploy-env=false
$ copilot deploy --name frontend --env test
```

Deploys a job named "mailer" with additional resource tags to a "prod" environment.
```console
$ copilot deploy -n mailer -e prod --resource-tags source/revision=bb133e7,deployment/initiator=manual --deploy-env=false
$ copilot deploy -n mailer -e prod --resource-tags source/revision=bb133e7,deployment/initiator=manual
```

Initializes and deploys an environment named "test" in us-west-2 under the "default" profile with local manifest,
Expand Down