Skip to content

Commit fdf6a3c

Browse files
authored
chore(template): remove previous env template version (#2569)
<!-- Provide summary of changes --> This PR removes all our previous env template versions because 1. similar to #2567, though we have all our previous env template versions, we don't actually need to rollback. Thus keeping these templates doesn't add any value 2. we don't version the partial env templates as well as the lambdas, which causes the fact that we often forget to update the latest template version even though the env template has been changed 3. creating a new template version is cumbersome and make it difficult for code reviewers to see the difference against the previous version Also updated the latest version to 1.4.1 since we haven't updated the version number for a while even though the template changed because of lambda changes. <!-- Issue number, if available. E.g. "Fixes #31", "Addresses #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.
1 parent b54d3c6 commit fdf6a3c

File tree

12 files changed

+8
-2269
lines changed

12 files changed

+8
-2269
lines changed

internal/pkg/deploy/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
// LegacyEnvTemplateVersion is the version associated with the environment template before we started versioning.
1414
LegacyEnvTemplateVersion = "v0.0.0"
1515
// LatestEnvTemplateVersion is the latest version number available for environment templates.
16-
LatestEnvTemplateVersion = "v1.4.0"
16+
LatestEnvTemplateVersion = "v1.4.1"
1717
)
1818

1919
// CreateEnvironmentInput holds the fields required to deploy an environment.

internal/pkg/template/env.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const (
14-
fmtEnvCFTemplatePath = "environment/versions/cf-%s.yml"
14+
envCFTemplatePath = "environment/cf.yml"
1515
fmtEnvCFSubTemplatePath = "environment/partials/%s.yml"
1616
)
1717

@@ -44,7 +44,7 @@ type EnvOpts struct {
4444

4545
// ParseEnv parses an environment's CloudFormation template with the specified data object and returns its content.
4646
func (t *Template) ParseEnv(data *EnvOpts, options ...ParseOption) (*Content, error) {
47-
tpl, err := t.parse("base", envTemplatePath(data.Version), options...)
47+
tpl, err := t.parse("base", envCFTemplatePath, options...)
4848
if err != nil {
4949
return nil, err
5050
}
@@ -64,10 +64,3 @@ func (t *Template) ParseEnv(data *EnvOpts, options ...ParseOption) (*Content, er
6464
}
6565
return &Content{buf}, nil
6666
}
67-
68-
func envTemplatePath(version string) string {
69-
if version == "" {
70-
return fmt.Sprintf(fmtEnvCFTemplatePath, "v0.0.0")
71-
}
72-
return fmt.Sprintf(fmtEnvCFTemplatePath, version)
73-
}

internal/pkg/template/env_test.go

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package template
55

66
import (
7-
"fmt"
87
"testing"
98

109
"github.com/gobuffalo/packd"
@@ -13,35 +12,14 @@ import (
1312

1413
func TestTemplate_ParseEnv(t *testing.T) {
1514
testCases := map[string]struct {
16-
version string
1715
mockDependencies func(t *Template)
1816
wantedContent string
1917
wantedErr error
2018
}{
21-
"renders all nested templates in legacy template": {
19+
"renders env template": {
2220
mockDependencies: func(t *Template) {
2321
mockBox := packd.NewMemoryBox()
24-
var baseContent string
25-
for _, name := range envCFSubTemplateNames {
26-
baseContent += fmt.Sprintf(`{{include "%s" . | indent 2}}`+"\n", name)
27-
}
28-
mockBox.AddString("environment/versions/cf-v0.0.0.yml", baseContent)
29-
t.box = mockBox
30-
},
31-
wantedContent: ` cfn-execution-role
32-
custom-resources
33-
custom-resources-role
34-
environment-manager-role
35-
lambdas
36-
vpc-resources
37-
nat-gateways
38-
`,
39-
},
40-
"renders v1.0.0 template": {
41-
version: "v1.0.0",
42-
mockDependencies: func(t *Template) {
43-
mockBox := packd.NewMemoryBox()
44-
mockBox.AddString("environment/versions/cf-v1.0.0.yml", "test")
22+
mockBox.AddString("environment/cf.yml", "test")
4523
t.box = mockBox
4624
},
4725
wantedContent: "test",
@@ -62,9 +40,7 @@ func TestTemplate_ParseEnv(t *testing.T) {
6240
tpl.box.AddString("environment/partials/nat-gateways.yml", "nat-gateways")
6341

6442
// WHEN
65-
c, err := tpl.ParseEnv(&EnvOpts{
66-
Version: tc.version,
67-
})
43+
c, err := tpl.ParseEnv(&EnvOpts{})
6844

6945
if tc.wantedErr != nil {
7046
require.Contains(t, err.Error(), tc.wantedErr.Error())

templates/environment/versions/cf-v1.4.0.yml renamed to templates/environment/cf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: MIT-0
33
Description: CloudFormation environment template for infrastructure shared among Copilot workloads.
44
Metadata:
5-
Version: 'v1.4.0'
5+
Version: 'v1.4.1'
66
Parameters:
77
AppName:
88
Type: String

templates/environment/versions/cf-v0.0.0.yml

Lines changed: 0 additions & 285 deletions
This file was deleted.

0 commit comments

Comments
 (0)