Skip to content

Commit 2a0f65d

Browse files
authored
feat(pipeline): change pipeline update to pipeline deploy (with update as alias) (#3154)
[Originally](#249), the prompt "Would you like to deploy your pipeline?" was part of `pipeline init`, so [the decision](#329 (comment)) was made to name the deployment command `pipeline update` instead of `pipeline deploy`, assuming that the command would be run on an already-deployed pipeline. We ended up separating deployment from `pipeline init` because the user needs to push files to their repo between `init` and `update`. `pipeline deploy` makes more sense as the name of the command, and is consistent with `svc init` and `svc deploy`. We must keep `pipeline update` for backwards-compatibility, and it does make sense, as it does update existing pipelines. This PR adds `pipeline deploy` as an alias to `pipeline update`. Having both also gives us the capacity to eventually separate the two commands and add functionality to `pipeline update` that may not be appropriate for `pipeline deploy`, or vice versa. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
1 parent 4727a7b commit 2a0f65d

File tree

14 files changed

+166
-163
lines changed

14 files changed

+166
-163
lines changed

e2e/internal/client/cli.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,9 @@ func (cli *CLI) PipelineInit(app, url, branch string, envs []string) (string, er
656656
"-e", strings.Join(envs, ",")))
657657
}
658658

659-
// PipelineUpdate runs "copilot pipeline update".
660-
func (cli *CLI) PipelineUpdate(app string) (string, error) {
661-
return cli.exec(exec.Command(cli.path, "pipeline", "update", "-a", app, "--yes"))
659+
// PipelineDeploy runs "copilot pipeline deploy".
660+
func (cli *CLI) PipelineDeploy(app string) (string, error) {
661+
return cli.exec(exec.Command(cli.path, "pipeline", "deploy", "-a", app, "--yes"))
662662
}
663663

664664
// PipelineShow runs "copilot pipeline show --json"

e2e/multi-env-app/multi_env_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ var _ = Describe("Multiple Env App", func() {
253253
Skip("not implemented yet")
254254
})
255255

256-
It("pipeline update should create a pipeline", func() {
256+
It("pipeline deploy should create a pipeline", func() {
257257
Skip("not implemented yet")
258258
})
259259
})

e2e/pipeline/pipeline_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ var _ = Describe("pipeline flow", func() {
170170

171171
Context("when creating the pipeline stack", func() {
172172
It("should start creating the pipeline stack", func() {
173-
_, err := copilot.PipelineUpdate(appName)
173+
_, err := copilot.PipelineDeploy(appName)
174174
Expect(err).NotTo(HaveOccurred())
175175
})
176176

internal/pkg/cli/flag.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const (
2626
jsonFlag = "json"
2727
allFlag = "all"
2828
forceFlag = "force"
29-
3029
// Command specific flags.
3130
dockerFileFlag = "dockerfile"
3231
dockerFileContextFlag = "build-context"

internal/pkg/cli/pipeline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Continuous delivery pipelines to release services.`,
2020
}
2121

2222
cmd.AddCommand(buildPipelineInitCmd())
23-
cmd.AddCommand(buildPipelineUpdateCmd())
23+
cmd.AddCommand(buildPipelineDeployCmd())
2424
cmd.AddCommand(buildPipelineDeleteCmd())
2525
cmd.AddCommand(buildPipelineShowCmd())
2626
cmd.AddCommand(buildPipelineStatusCmd())

internal/pkg/cli/pipeline_update.go renamed to internal/pkg/cli/pipeline_deploy.go

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ import (
2626
)
2727

2828
const (
29-
fmtPipelineUpdateResourcesStart = "Adding pipeline resources to your application: %s"
30-
fmtPipelineUpdateResourcesFailed = "Failed to add pipeline resources to your application: %s\n"
31-
fmtPipelineUpdateResourcesComplete = "Successfully added pipeline resources to your application: %s\n"
29+
fmtPipelineDeployResourcesStart = "Adding pipeline resources to your application: %s"
30+
fmtPipelineDeployResourcesFailed = "Failed to add pipeline resources to your application: %s\n"
31+
fmtPipelineDeployResourcesComplete = "Successfully added pipeline resources to your application: %s\n"
3232

33-
fmtPipelineUpdateStart = "Creating a new pipeline: %s"
34-
fmtPipelineUpdateFailed = "Failed to create a new pipeline: %s.\n"
35-
fmtPipelineUpdateComplete = "Successfully created a new pipeline: %s\n"
33+
fmtPipelineDeployStart = "Creating a new pipeline: %s"
34+
fmtPipelineDeployFailed = "Failed to create a new pipeline: %s.\n"
35+
fmtPipelineDeployComplete = "Successfully created a new pipeline: %s\n"
3636

37-
fmtPipelineUpdateProposalStart = "Proposing infrastructure changes for the pipeline: %s"
38-
fmtPipelineUpdateProposalFailed = "Failed to accept changes for pipeline: %s.\n"
39-
fmtPipelineUpdateProposalComplete = "Successfully updated pipeline: %s\n"
37+
fmtPipelineDeployProposalStart = "Proposing infrastructure changes for the pipeline: %s"
38+
fmtPipelineDeployProposalFailed = "Failed to accept changes for pipeline: %s.\n"
39+
fmtPipelineDeployProposalComplete = "Successfully deployed pipeline: %s\n"
4040

41-
fmtPipelineUpdateExistPrompt = "Are you sure you want to update an existing pipeline: %s?"
41+
fmtPipelineDeployExistPrompt = "Are you sure you want to redeploy an existing pipeline: %s?"
4242
)
4343

4444
const connectionsURL = "https://console.aws.amazon.com/codesuite/settings/connections"
4545

46-
type updatePipelineVars struct {
46+
type deployPipelineVars struct {
4747
appName string
4848
skipConfirmation bool
4949
}
5050

51-
type updatePipelineOpts struct {
52-
updatePipelineVars
51+
type deployPipelineOpts struct {
52+
deployPipelineVars
5353

5454
pipelineDeployer pipelineDeployer
5555
app *config.Application
@@ -64,7 +64,7 @@ type updatePipelineOpts struct {
6464
shouldPromptUpdateConnection bool
6565
}
6666

67-
func newUpdatePipelineOpts(vars updatePipelineVars) (*updatePipelineOpts, error) {
67+
func newDeployPipelineOpts(vars deployPipelineVars) (*deployPipelineOpts, error) {
6868
store, err := config.NewStore()
6969
if err != nil {
7070
return nil, fmt.Errorf("new config store client: %w", err)
@@ -85,11 +85,11 @@ func newUpdatePipelineOpts(vars updatePipelineVars) (*updatePipelineOpts, error)
8585
return nil, fmt.Errorf("new workspace client: %w", err)
8686
}
8787

88-
return &updatePipelineOpts{
88+
return &deployPipelineOpts{
8989
app: app,
9090
pipelineDeployer: deploycfn.New(defaultSession),
9191
region: aws.StringValue(defaultSession.Config.Region),
92-
updatePipelineVars: vars,
92+
deployPipelineVars: vars,
9393
envStore: store,
9494
ws: ws,
9595
prog: termprogress.NewSpinner(log.DiagnosticWriter),
@@ -99,20 +99,20 @@ func newUpdatePipelineOpts(vars updatePipelineVars) (*updatePipelineOpts, error)
9999
}
100100

101101
// Validate returns an error if the flag values passed by the user are invalid.
102-
func (o *updatePipelineOpts) Validate() error {
102+
func (o *deployPipelineOpts) Validate() error {
103103
return nil
104104
}
105105

106106
// Execute creates a new pipeline or updates the current pipeline if it already exists.
107-
func (o *updatePipelineOpts) Execute() error {
107+
func (o *deployPipelineOpts) Execute() error {
108108
// bootstrap pipeline resources
109-
o.prog.Start(fmt.Sprintf(fmtPipelineUpdateResourcesStart, color.HighlightUserInput(o.appName)))
109+
o.prog.Start(fmt.Sprintf(fmtPipelineDeployResourcesStart, color.HighlightUserInput(o.appName)))
110110
err := o.pipelineDeployer.AddPipelineResourcesToApp(o.app, o.region)
111111
if err != nil {
112-
o.prog.Stop(log.Serrorf(fmtPipelineUpdateResourcesFailed, color.HighlightUserInput(o.appName)))
112+
o.prog.Stop(log.Serrorf(fmtPipelineDeployResourcesFailed, color.HighlightUserInput(o.appName)))
113113
return fmt.Errorf("add pipeline resources to application %s in %s: %w", o.appName, o.region, err)
114114
}
115-
o.prog.Stop(log.Ssuccessf(fmtPipelineUpdateResourcesComplete, color.HighlightUserInput(o.appName)))
115+
o.prog.Stop(log.Ssuccessf(fmtPipelineDeployResourcesComplete, color.HighlightUserInput(o.appName)))
116116

117117
// read pipeline manifest
118118
data, err := o.ws.ReadPipelineManifest()
@@ -173,7 +173,7 @@ func (o *updatePipelineOpts) Execute() error {
173173
return nil
174174
}
175175

176-
func (o *updatePipelineOpts) convertStages(manifestStages []manifest.PipelineStage) ([]deploy.PipelineStage, error) {
176+
func (o *deployPipelineOpts) convertStages(manifestStages []manifest.PipelineStage) ([]deploy.PipelineStage, error) {
177177
var stages []deploy.PipelineStage
178178
workloads, err := o.ws.ListWorkloads()
179179
if err != nil {
@@ -202,7 +202,7 @@ func (o *updatePipelineOpts) convertStages(manifestStages []manifest.PipelineSta
202202
return stages, nil
203203
}
204204

205-
func (o *updatePipelineOpts) getArtifactBuckets() ([]deploy.ArtifactBucket, error) {
205+
func (o *deployPipelineOpts) getArtifactBuckets() ([]deploy.ArtifactBucket, error) {
206206
regionalResources, err := o.pipelineDeployer.GetRegionalAppResources(o.app)
207207
if err != nil {
208208
return nil, err
@@ -220,27 +220,27 @@ func (o *updatePipelineOpts) getArtifactBuckets() ([]deploy.ArtifactBucket, erro
220220
return buckets, nil
221221
}
222222

223-
func (o *updatePipelineOpts) getBucketName() (string, error) {
223+
func (o *deployPipelineOpts) getBucketName() (string, error) {
224224
resources, err := o.pipelineDeployer.GetAppResourcesByRegion(o.app, o.region)
225225
if err != nil {
226226
return "", fmt.Errorf("get app resources: %w", err)
227227
}
228228
return resources.S3Bucket, nil
229229
}
230230

231-
func (o *updatePipelineOpts) shouldUpdate() (bool, error) {
231+
func (o *deployPipelineOpts) shouldUpdate() (bool, error) {
232232
if o.skipConfirmation {
233233
return true, nil
234234
}
235235

236-
shouldUpdate, err := o.prompt.Confirm(fmt.Sprintf(fmtPipelineUpdateExistPrompt, o.pipelineName), "")
236+
shouldUpdate, err := o.prompt.Confirm(fmt.Sprintf(fmtPipelineDeployExistPrompt, o.pipelineName), "")
237237
if err != nil {
238-
return false, fmt.Errorf("prompt for pipeline update: %w", err)
238+
return false, fmt.Errorf("prompt for pipeline deploy: %w", err)
239239
}
240240
return shouldUpdate, nil
241241
}
242242

243-
func (o *updatePipelineOpts) deployPipeline(in *deploy.CreatePipelineInput) error {
243+
func (o *deployPipelineOpts) deployPipeline(in *deploy.CreatePipelineInput) error {
244244
exist, err := o.pipelineDeployer.PipelineExists(in)
245245
if err != nil {
246246
return fmt.Errorf("check if pipeline exists: %w", err)
@@ -252,7 +252,7 @@ func (o *updatePipelineOpts) deployPipeline(in *deploy.CreatePipelineInput) erro
252252
return fmt.Errorf("get bucket name: %w", err)
253253
}
254254
if !exist {
255-
o.prog.Start(fmt.Sprintf(fmtPipelineUpdateStart, color.HighlightUserInput(o.pipelineName)))
255+
o.prog.Start(fmt.Sprintf(fmtPipelineDeployStart, color.HighlightUserInput(o.pipelineName)))
256256

257257
// If the source requires CodeStar Connections, the user is prompted to update the connection status.
258258
if o.shouldPromptUpdateConnection {
@@ -273,11 +273,11 @@ func (o *updatePipelineOpts) deployPipeline(in *deploy.CreatePipelineInput) erro
273273
if err := o.pipelineDeployer.CreatePipeline(in, bucketName); err != nil {
274274
var alreadyExists *cloudformation.ErrStackAlreadyExists
275275
if !errors.As(err, &alreadyExists) {
276-
o.prog.Stop(log.Serrorf(fmtPipelineUpdateFailed, color.HighlightUserInput(o.pipelineName)))
276+
o.prog.Stop(log.Serrorf(fmtPipelineDeployFailed, color.HighlightUserInput(o.pipelineName)))
277277
return fmt.Errorf("create pipeline: %w", err)
278278
}
279279
}
280-
o.prog.Stop(log.Ssuccessf(fmtPipelineUpdateComplete, color.HighlightUserInput(o.pipelineName)))
280+
o.prog.Stop(log.Ssuccessf(fmtPipelineDeployComplete, color.HighlightUserInput(o.pipelineName)))
281281
return nil
282282
}
283283

@@ -289,35 +289,37 @@ func (o *updatePipelineOpts) deployPipeline(in *deploy.CreatePipelineInput) erro
289289
if !shouldUpdate {
290290
return nil
291291
}
292-
o.prog.Start(fmt.Sprintf(fmtPipelineUpdateProposalStart, color.HighlightUserInput(o.pipelineName)))
292+
o.prog.Start(fmt.Sprintf(fmtPipelineDeployProposalStart, color.HighlightUserInput(o.pipelineName)))
293293
if err := o.pipelineDeployer.UpdatePipeline(in, bucketName); err != nil {
294-
o.prog.Stop(log.Serrorf(fmtPipelineUpdateProposalFailed, color.HighlightUserInput(o.pipelineName)))
294+
o.prog.Stop(log.Serrorf(fmtPipelineDeployProposalFailed, color.HighlightUserInput(o.pipelineName)))
295295
return fmt.Errorf("update pipeline: %w", err)
296296
}
297-
o.prog.Stop(log.Ssuccessf(fmtPipelineUpdateProposalComplete, color.HighlightUserInput(o.pipelineName)))
297+
o.prog.Stop(log.Ssuccessf(fmtPipelineDeployProposalComplete, color.HighlightUserInput(o.pipelineName)))
298298
return nil
299299
}
300300

301301
// RecommendedActions returns follow-up actions the user can take after successfully executing the command.
302-
func (o *updatePipelineOpts) RecommendedActions() []string {
302+
func (o *deployPipelineOpts) RecommendedActions() []string {
303303
return []string{
304304
fmt.Sprintf("Run %s to see the state of your pipeline.", color.HighlightCode("copilot pipeline status")),
305305
fmt.Sprintf("Run %s for info about your pipeline.", color.HighlightCode("copilot pipeline show")),
306306
}
307307
}
308308

309-
// BuildPipelineUpdateCmd build the command for deploying a new pipeline or updating an existing pipeline.
310-
func buildPipelineUpdateCmd() *cobra.Command {
311-
vars := updatePipelineVars{}
309+
// BuildPipelineDeployCmd build the command for deploying a new pipeline or updating an existing pipeline.
310+
func buildPipelineDeployCmd() *cobra.Command {
311+
vars := deployPipelineVars{}
312312
cmd := &cobra.Command{
313-
Use: "update",
314-
Short: "Deploys a pipeline for the services in your workspace.",
315-
Long: `Deploys a pipeline for the services in your workspace, using the environments associated with the application.`,
313+
Use: "deploy",
314+
Aliases: []string{"update"},
315+
Short: "Deploys a pipeline for the services in your workspace.",
316+
Long: `Deploys a pipeline for the services in your workspace, using the environments associated with the application.`,
316317
Example: `
317-
Deploys an updated pipeline for the services in your workspace.
318-
/code $ copilot pipeline update`,
318+
Deploys a pipeline for the services and jobs in your workspace.
319+
/code $ copilot pipeline deploy
320+
`,
319321
RunE: runCmdE(func(cmd *cobra.Command, args []string) error {
320-
opts, err := newUpdatePipelineOpts(vars)
322+
opts, err := newDeployPipelineOpts(vars)
321323
if err != nil {
322324
return err
323325
}

0 commit comments

Comments
 (0)