Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): support manual approvals in pipeline manifest. #1273

Merged
merged 9 commits into from
Aug 18, 2020

Conversation

tam0ri
Copy link
Contributor

@tam0ri tam0ri commented Aug 17, 2020

related #1179

When a production environment is added via pipeline init, copilot adds the requires_approval: true line in pipeline.yml.
When requires_approval: true line exists in pipeline.yml, manual approval action is added into the pipeline via pipeline update.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

When a production environment is added via pipeline init, copilot adds the requires_approval: true line in pipeline.yml.
When requires_approval: true line exists in pipeline.yml, manual approval action is added into the pipeline via pipeline update.
@tam0ri tam0ri requested a review from a team as a code owner August 17, 2020 03:05
@tam0ri tam0ri requested a review from kohidave August 17, 2020 03:05
@tam0ri
Copy link
Contributor Author

tam0ri commented Aug 17, 2020

Hi reviewers. I'm not sure we need to update the version of pipeline manifest.

const (
// Ver1 is the current schema major version of the pipeline.yml file.
Ver1 PipelineSchemaMajorVersion = iota + 1
)

If we need to increment the version, please tell me that.

Copy link
Contributor

@efekarakus efekarakus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍 Thank you so much!

It looks good, mostly a comment about decoupling the manifest pkg from config.

}

// CreatePipeline returns a pipeline manifest object.
func CreatePipeline(pipelineName string, provider Provider, stageNames []string) (*PipelineManifest, error) {
func CreatePipeline(pipelineName string, provider Provider, envs []*config.Environment) (*PipelineManifest, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would you mind renaming this function to NewPipelineManifest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed.

environments = append(environments, env)
}

manifest, err := manifest.CreatePipeline(pipelineName, provider, environments)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing []*config.Environment as input to this function, what do you think of passing []manifest.PipelineStage? so this method would transform []*config.Environment -> []manifest.PipelineStage.

Since the function is in the manifest pkg, accepting []manifest.PipelineStage will make it more flexible. The PipelineStage can be created from a config.Environment object or some other way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed. However, now TestNewPipelineManifest just become meaningless because this test expects PipelineStage. I plan to change this test such as it expects PipelineManifest. If you have any opinion, please give me a feedback!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah I agree, the only behavior that might be interesting to test in TestNewPipelineManifest is checking if an error is returned if the list is empty and that's it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, does it mean we simply need to remove happy case and retain only error case? I just modified happy case with PipelineManifest as expected by imitating backend_svc_test.go. If I need to remove happy case, please point out!

@@ -247,14 +247,36 @@ func (o *initPipelineOpts) createPipelineProvider() (manifest.Provider, error) {
return manifest.NewProvider(config)
}

func (o *initPipelineOpts) getEnvFromCache(environmentName string) (*config.Environment, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we rename this method to getEnvConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed.

var environment *config.Environment
for _, env := range o.envs {
if env.Name == environmentName {
environment = env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: break after this statement so that we don't continue looping.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: oh my bad, instead of breaking we should just return instead :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then outside of the for-loop we wouldn't need to check if it's equal to nil and return also an error immediately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree! I addressed.

@efekarakus
Copy link
Contributor

👋 @git823

If we need to increment the version, please tell me that.

We can keep it as is. We don't do anything with the version atm, so it should be fine :)

@efekarakus
Copy link
Contributor

efekarakus commented Aug 17, 2020

This will be a breaking-change for customers that have a pipeline with environments that are initialized with --prod. When we unmarshal the manifest, the requires_approval field won't exist and the copilot pipeline update cmd will result in the removal of the manual approval.

I think this is fine though, we'll explicitly call it out in our release notes as this change gives the customers power to control the manual approvals :)

tam0ri added 4 commits August 18, 2020 05:01
Rename getEnvFromCache -> getEnvConfig.
Add break statement.
Rename CreatePipeline -> NewPipelineManifest.
Instead of passing []*config.Environment as input to NewPipelineManifest, passing []manifest.PipelineStage.
var environment *config.Environment
for _, env := range o.envs {
if env.Name == environmentName {
environment = env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: oh my bad, instead of breaking we should just return instead :)

@@ -21,6 +21,8 @@ source:
stages:{{range .Stages}}
- # The name of the environment to deploy to.
name: {{.Name}}
# Optional: flag for manual approval action before deployment.
requires_approval: {{.RequiresApproval}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of having this commented out, by default (like the test commands)? It will be false by default. and folks can uncomment it if they want it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds nice! I addressed.

@efekarakus efekarakus added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 17, 2020
Copy link
Contributor

@efekarakus efekarakus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Looks great! Thank you

@kohidave kohidave removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 18, 2020
@mergify mergify bot merged commit e096cf8 into aws:mainline Aug 18, 2020
@tam0ri tam0ri deleted the feat/pipeline-approval branch August 19, 2020 21:03
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
related aws#1179

When a production environment is added via `pipeline init`, copilot adds the requires_approval: true line in pipeline.yml.
When requires_approval: true line exists in pipeline.yml, manual approval action is added into the pipeline via `pipeline update`.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants