Skip to content

fix: Env manifest UX fix for http config #4068

Merged
mergify[bot] merged 13 commits intoaws:mainlinefrom
paragbhingre:envManifestUXFix
Oct 20, 2022
Merged

fix: Env manifest UX fix for http config #4068
mergify[bot] merged 13 commits intoaws:mainlinefrom
paragbhingre:envManifestUXFix

Conversation

@paragbhingre
Copy link
Copy Markdown
Contributor

@paragbhingre paragbhingre commented Oct 6, 2022

This PR fix multiple problems -

  1. This PR fix the env manifest fields that were organized in incorrect manner.
  2. Also resolves Using "--internal-alb-allow-vpc-ingress" with "copilot env deploy" #4032
  3. copilot env init with private subnets create env manifest with following field
http:
  private:

This should only be created when there is at least one parameter inside private is enabled. This PR fix this nit as well.

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

@paragbhingre paragbhingre requested a review from a team as a code owner October 6, 2022 23:03
@paragbhingre paragbhingre requested review from KollaAdithya and removed request for a team October 6, 2022 23:03
@paragbhingre paragbhingre added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Oct 11, 2022
@Lou1415926
Copy link
Copy Markdown
Contributor

Lou1415926 commented Oct 11, 2022

Just making sure I'm understanding correctly (also for other reviewers' reference!)
We currently have:

http:
  public:
    security_groups:
      ingress: # This doesn't make sense because `ingress` is for one sg, not sgs
        restrict_to: # This is redundant because `ingress` implies "restrict_to".
          cdn: true
  private:
    security_groups:
      ingress: # This doesn't make sense because `ingress` is for one sg, not sgs
        from_vpc: true

After the fix, we want to have:

http:
  public:
    ingress:
      cdn: true
  private:
    ingress:
      from_vpc: true

while still accepting the old manifest.

@paragbhingre paragbhingre removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Oct 11, 2022
@paragbhingre
Copy link
Copy Markdown
Contributor Author

Just making sure I'm understanding correctly (also for other reviewers' reference!) We currently have:

http:
  public:
    security_groups:
      ingress: # This doesn't make sense because `ingress` is for one sg, not sgs
        restrict_to: # This is redundant because `ingress` implies "restrict_to".
          cdn: true
  private:
    security_groups:
      ingress: # This doesn't make sense because `ingress` is for one sg, not sgs
        from_vpc: true

After the fix, we want to have:

http:
  public:
    ingress:
      cdn: true
  private:
    ingress:
      from_vpc: true

while still accepting the old manifest.

Yes you are right @Lou1415926

Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/validate_env.go Outdated
Comment thread internal/pkg/template/env.go Outdated
Comment thread internal/pkg/manifest/errors.go Outdated
Comment thread internal/pkg/manifest/env_test.go
Comment thread internal/pkg/cli/env_init.go Outdated
Comment thread internal/pkg/config/env.go Outdated
ImportCertARNs []string `json:"importCertARNs,omitempty"`
InternalALBSubnets []string `json:"internalALBSubnets,omitempty"`
EnableInternalALBVPCIngress bool `json:"enableInternalALBVPCIngress,omitempty"`
EnableInternalALBVPCIngress *bool `json:"enableInternalALBVPCIngress,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question here. Why do we need a pointer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it because you want to differentiate between nil and &false? I feel like if this field is false then it still means CustomizeEnv is empty

Copy link
Copy Markdown
Contributor Author

@paragbhingre paragbhingre Oct 17, 2022

Choose a reason for hiding this comment

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

The reason why made this change because if we do not keep EnableInternalALBVPCIngress as pointer then this will always be false and in that case if customer imports vpc config with private subnet without --internal-alb-allow-vpc-ingress flag then also manifest has following config specified.

# Configure the load balancers in your environment, once created.
http:
  private:
    ingress:
      from_vpc: false

In order to get rid of this part I made changes related to pointer. Does that make sense?

But right now I have removed pointer logic and kept the existing logic as it is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we just not write to the manifest if the field is false? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was not sure how right it is to not write that field to the manifest when it is false. But now I have made changes in the new commit, let me know if that works.

Comment thread internal/pkg/cli/env_init.go Outdated
Comment thread internal/pkg/config/env.go Outdated
ImportCertARNs []string `json:"importCertARNs,omitempty"`
InternalALBSubnets []string `json:"internalALBSubnets,omitempty"`
EnableInternalALBVPCIngress bool `json:"enableInternalALBVPCIngress,omitempty"`
EnableInternalALBVPCIngress *bool `json:"enableInternalALBVPCIngress,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it because you want to differentiate between nil and &false? I feel like if this field is false then it still means CustomizeEnv is empty

Comment thread internal/pkg/cli/deploy/env.go Outdated
Comment thread internal/pkg/deploy/cloudformation/stack/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/errors.go
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/template/env.go
Comment thread internal/pkg/template/templates/environment/manifest.yml
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 18, 2022

Codecov Report

Attention: Patch coverage is 55.69620% with 35 lines in your changes missing coverage. Please review.

Project coverage is 69.14%. Comparing base (3c4fd93) to head (99510a0).
Report is 943 commits behind head on mainline.

Files with missing lines Patch % Lines
internal/pkg/manifest/errors.go 7.40% 25 Missing ⚠️
internal/pkg/manifest/env.go 68.75% 4 Missing and 1 partial ⚠️
internal/pkg/manifest/validate_env.go 85.71% 2 Missing and 2 partials ⚠️
internal/pkg/config/env.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           mainline    #4068      +/-   ##
============================================
- Coverage     69.17%   69.14%   -0.03%     
============================================
  Files           248      249       +1     
  Lines         35608    35656      +48     
  Branches        264      264              
============================================
+ Hits          24631    24654      +23     
- Misses         9782     9805      +23     
- Partials       1195     1197       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Comment thread internal/pkg/deploy/cloudformation/stack/env.go Outdated
Comment thread internal/pkg/manifest/deprecated.go
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/template/templates/environment/manifest.yml
Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

Do you think this sort of manifest UX fix is worth testing in a regression test? Like we can test a manifest that looks like:

http:
   public: 
        ingress:
             from_cdn: true

works the same before & after?

Comment thread internal/pkg/cli/deploy/env_test.go
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/errors.go Outdated
Comment thread internal/pkg/deploy/cloudformation/stack/env_integration_test.go
Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

lgtm!

Comment thread internal/pkg/manifest/env_test.go Outdated
Comment thread internal/pkg/manifest/errors.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Copy link
Copy Markdown
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 good, just tiny nits. Feel free to remove the label afterwards!

Comment thread internal/pkg/deploy/cloudformation/stack/env_integration_test.go Outdated
Comment thread internal/pkg/manifest/env.go Outdated
Comment thread internal/pkg/manifest/errors.go
@efekarakus efekarakus added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Oct 20, 2022
@paragbhingre paragbhingre removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Oct 20, 2022
Copy link
Copy Markdown
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

:shipit: !!

@mergify mergify Bot merged commit dc49c14 into aws:mainline Oct 20, 2022
KollaAdithya pushed a commit to KollaAdithya/copilot-cli that referenced this pull request Oct 21, 2022
This PR fix multiple problems -
1. This PR fix the env manifest fields that were organized in incorrect manner.
2. Also resolves aws#4032
3. `copilot env init` with private subnets create env manifest with following field
```
http:
  private:
```
This should only be created when there is at least one parameter inside private is enabled. This PR fix this nit as well.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
@paragbhingre paragbhingre deleted the envManifestUXFix branch January 26, 2023 07:28
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.

5 participants