Skip to content

fix(manifest): preserve default network config on empty env overrides#2442

Merged
mergify[bot] merged 3 commits intoaws:mainlinefrom
efekarakus:issues/fix-2420
Jun 14, 2021
Merged

fix(manifest): preserve default network config on empty env overrides#2442
mergify[bot] merged 3 commits intoaws:mainlinefrom
efekarakus:issues/fix-2420

Conversation

@efekarakus
Copy link
Copy Markdown
Contributor

Fixes #2420

Previously, when a user provided a network config and an env override:

network:
  vpc:
    security_groups: ['sg-123123']
environments:
  dev:
    count: 2

The network config for the "dev" environment got overriden to an empty
struct{}.

This change ensures that the default entry is preserved for network
config is preserved for the "dev" environment.
This is done by changing the type for the Network field to a pointer so
that mergo does not overwrite it.

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

Comment thread internal/pkg/manifest/workload.go Outdated
Fixes aws#2420

Previously, when a user provided a network config and an env override:
```yaml
network:
  vpc:
    security_groups: ['sg-123123']
environments:
  dev:
    count: 2
```
The network config for the "dev" environment got overriden to an empty
struct{}.

This change ensures that the default entry is preserved for network
config is preserved for the "dev" environment.
This is done by changing the type for the Network field to a pointer so
that mergo does not overwrite it.
Copy link
Copy Markdown
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

:shipit:

Comment on lines +537 to 545
if network == nil || network.VPC == nil {
return &template.NetworkOpts{
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement,
}
}
opts := &template.NetworkOpts{
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement,
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.

Suggested change
if network == nil || network.VPC == nil {
return &template.NetworkOpts{
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement,
}
}
opts := &template.NetworkOpts{
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement,
opts := &template.NetworkOpts{
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement
}
if network == nil || network.VPC == nil {
return opts
}
opts.SecurityGroups = network.VPC.SecurityGroups

Copy link
Copy Markdown
Contributor

@huanjani huanjani left a comment

Choose a reason for hiding this comment

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

lgtm!

@mergify mergify Bot merged commit ae9170d into aws:mainline Jun 14, 2021
mergify Bot pushed a commit that referenced this pull request Jun 21, 2021
…verrides (#2490)

This fixes the bug where an empty environment `entrypoint`/`command` will replace the default `entrypoint`/`command` in manifest if they are specified as list.

This is because an empty list `[]string` isn't considered a zero value, hence `mergo` will use the empty list to replace the original list.

This is the same fix as #2442, only it's on entrypoint and command overrides.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
…aws#2442)

Fixes aws#2420

Previously, when a user provided a network config and an env override:
```yaml
network:
  vpc:
    security_groups: ['sg-123123']
environments:
  dev:
    count: 2
```
The network config for the "dev" environment got overriden to an empty
struct{}.

This change ensures that the default entry is preserved for network
config is preserved for the "dev" environment.
This is done by changing the type for the Network field to a pointer so
that mergo does not overwrite it.

<!-- Provide summary of changes -->

<!-- Issue number, if available. E.g. "Fixes aws#31", "Addresses aws#42, 77" -->

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
thrau pushed a commit to localstack/copilot-cli-local that referenced this pull request Dec 9, 2022
…verrides (aws#2490)

This fixes the bug where an empty environment `entrypoint`/`command` will replace the default `entrypoint`/`command` in manifest if they are specified as list.

This is because an empty list `[]string` isn't considered a zero value, hence `mergo` will use the empty list to replace the original list.

This is the same fix as aws#2442, only it's on entrypoint and command overrides.

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.

How to configure security groups in Load Balancer Web Service

4 participants