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

chore(cli): env delete should not proceed when it is used in any pipelines #5246

Merged
merged 5 commits into from
Aug 29, 2023

Conversation

iamhopaul123
Copy link
Contributor

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

@iamhopaul123 iamhopaul123 requested a review from a team as a code owner August 28, 2023 23:19
@iamhopaul123 iamhopaul123 requested review from efekarakus and removed request for a team August 28, 2023 23:19
@github-actions
Copy link

github-actions bot commented Aug 28, 2023

🍕 Here are the new binary sizes!

Name New size (kiB) size (kiB) Delta (%)
macOS (amd) 51716 51488 +0.44
macOS (arm) 51912 51684 +0.44
linux (amd) 45536 45324 +0.47
linux (arm) 43780 43588 +0.44
windows (amd) 42336 42144 +0.46

@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2023

Codecov Report

Merging #5246 (f592bd2) into mainline (a50d809) will decrease coverage by 0.01%.
The diff coverage is 55.88%.

❗ Current head f592bd2 differs from pull request most recent head f381826. Consider uploading reports for the commit f381826 to get more accurate results

@@             Coverage Diff              @@
##           mainline    #5246      +/-   ##
============================================
- Coverage     69.79%   69.78%   -0.01%     
============================================
  Files           296      296              
  Lines         44513    44544      +31     
  Branches        286      286              
============================================
+ Hits          31068    31087      +19     
- Misses        11942    11952      +10     
- Partials       1503     1505       +2     
Files Changed Coverage Δ
internal/pkg/cli/app_delete.go 28.41% <0.00%> (ø)
internal/pkg/cli/errors.go 58.82% <33.33%> (-2.47%) ⬇️
internal/pkg/cli/env_delete.go 58.04% <65.21%> (+0.46%) ⬆️
internal/pkg/deploy/pipeline.go 69.84% <100.00%> (+0.12%) ⬆️

Copy link
Contributor

@bvtujo bvtujo left a comment

Choose a reason for hiding this comment

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

Lgtm ship it boss

return fmt.Errorf("get pipeline %s: %w", pipeline.ResourceName, err)
}
for _, stage := range info.Stages {
if strings.TrimPrefix(stage.Name, deploy.StageFullNamePrefix) == o.name {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the most durable way we can find this out? Do we stick the manifest in the pipeline metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a very good question. We've never changed our naming pattern for this and I am making it more durable by extracting deploy.StageFullNamePrefix.

Do we stick the manifest in the pipeline metadata?

Unfortunately we don't do that for manifest :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately we don't do that for manifest :(

Maybe we should! (later)

Copy link
Contributor

@CaptainCarpensir CaptainCarpensir left a comment

Choose a reason for hiding this comment

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

LGTM

getter.EXPECT().GetPipeline("mockResourceName").Return(&codepipeline.Pipeline{
Stages: []*codepipeline.Stage{
{
Name: "DeployTo-test",
Copy link
Contributor

Choose a reason for hiding this comment

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

This test having the name hardcoded helps with the durability too because it should catch any breaking name change 👍

@@ -188,6 +188,10 @@ func (o *deleteAppOpts) Ask() error {
// It removes all the services from each environment, the environments, the pipeline S3 buckets,
// the pipeline, the application, removes the variables from the config store, and deletes the local workspace.
func (o *deleteAppOpts) Execute() error {
if err := o.deletePipelines(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe a comment why it needs to go first? or just in the Execute() description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the function comment. I think it's pretty obvious. Deleting the pipelines in the middle (previous impl) should be more confusing because nothing depends on a pipeline.

internal/pkg/cli/env_delete.go Outdated Show resolved Hide resolved
@CaptainCarpensir CaptainCarpensir added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 29, 2023
@iamhopaul123 iamhopaul123 removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Aug 29, 2023
@mergify mergify bot merged commit d0f0c52 into aws:mainline Aug 29, 2023
12 checks passed
Sprint 🏃‍♀️ automation moved this from In review to Pending release Aug 29, 2023
KollaAdithya pushed a commit to KollaAdithya/copilot-cli that referenced this pull request Oct 18, 2023
…lines (aws#5246)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Sprint 🏃‍♀️
  
Pending release
Development

Successfully merging this pull request may close these issues.

None yet

6 participants