Skip to content

Commit

Permalink
chore: render latest environment template version instead of hardcodi…
Browse files Browse the repository at this point in the history
…ng it (#2617)

Previously we have to make changes to two places when we need to update the environment template version, one being the `environment/cf.yml` template, the other being the variable `deploy.LatestEnvTemplateVersion`

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
  • Loading branch information
Lou1415926 committed Jul 15, 2021
1 parent 092a626 commit ea29075
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/pkg/deploy/cloudformation/stack/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (e *EnvStackConfig) Template() (string, error) {
ImportVPC: e.in.ImportVPCConfig,
VPCConfig: vpcConf,
Version: e.in.Version,
LatestVersion: deploy.LatestEnvTemplateVersion,
}, template.WithFuncs(map[string]interface{}{
"inc": template.IncFunc,
}))
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/deploy/cloudformation/stack/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestEnv_Template(t *testing.T) {
PrivateSubnetCIDRs: strings.Split(DefaultPrivateSubnetCIDRs, ","),
PublicSubnetCIDRs: strings.Split(DefaultPublicSubnetCIDRs, ","),
},
LatestVersion: deploy.LatestEnvTemplateVersion,
}, gomock.Any()).Return(&template.Content{Buffer: bytes.NewBufferString("mockTemplate")}, nil)
e.parser = m
},
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/deploy/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
// LegacyEnvTemplateVersion is the version associated with the environment template before we started versioning.
LegacyEnvTemplateVersion = "v0.0.0"
// LatestEnvTemplateVersion is the latest version number available for environment templates.
LatestEnvTemplateVersion = "v1.5.0"
LatestEnvTemplateVersion = "v1.5.1"
)

// CreateEnvironmentInput holds the fields required to deploy an environment.
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/template/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type EnvOpts struct {

ImportVPC *config.ImportVPC
VPCConfig *config.AdjustVPC

LatestVersion string
}

// ParseEnv parses an environment's CloudFormation template with the specified data object and returns its content.
Expand Down
2 changes: 1 addition & 1 deletion templates/environment/cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: MIT-0
Description: CloudFormation environment template for infrastructure shared among Copilot workloads.
Metadata:
Version: 'v1.5.1'
Version: {{ .LatestVersion }}
Parameters:
AppName:
Type: String
Expand Down

0 comments on commit ea29075

Please sign in to comment.