Skip to content

Commit a8add41

Browse files
committed
feat: manifest.Load(...) includes unselected environments as not enabled environments with Enabled: false
In order to be able to check environment and group overrides in `project.LoadProject(...)` they need not to be removed in `manifest.Load(...)`. Instead, this function marks them as not enabled, with `Enabled: false`.
1 parent a7dc9ee commit a8add41

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

cmd/monaco/dynatrace/dynatrace.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ func VerifyEnvironmentGeneration(ctx context.Context, envs manifest.Environments
5151
return true
5252
}
5353
for _, env := range envs {
54+
if !env.Enabled {
55+
continue
56+
}
5457
if !isValidEnvironment(ctx, env) {
5558
return false
5659
}
@@ -187,6 +190,9 @@ func (e EnvironmentClients) Names() []string {
187190
func CreateEnvironmentClients(ctx context.Context, environments manifest.Environments, dryRun bool) (EnvironmentClients, error) {
188191
clients := make(EnvironmentClients, len(environments))
189192
for _, env := range environments {
193+
if !env.Enabled {
194+
continue
195+
}
190196
if dryRun {
191197
clients[EnvironmentInfo{
192198
Name: env.Name,

cmd/monaco/dynatrace/dynatrace_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ func TestVerifyEnvironmentGeneration_OneOfManyFails(t *testing.T) {
6767

6868
ok := VerifyEnvironmentGeneration(t.Context(), manifest.Environments{
6969
"env": manifest.EnvironmentDefinition{
70-
Name: "env",
70+
Enabled: true,
71+
Name: "env",
7172
URL: manifest.URLDefinition{
7273
Type: manifest.ValueURLType,
7374
Name: "URL",
7475
Value: server.URL,
7576
},
7677
},
7778
"env2": manifest.EnvironmentDefinition{
78-
Name: "env",
79+
Enabled: true,
80+
Name: "env",
7981
URL: manifest.URLDefinition{
8082
Type: manifest.ValueURLType,
8183
Name: "URL",
@@ -130,7 +132,8 @@ func TestVerifyEnvironmentGen(t *testing.T) {
130132

131133
ok := VerifyEnvironmentGeneration(t.Context(), manifest.Environments{
132134
"env": manifest.EnvironmentDefinition{
133-
Name: "env",
135+
Enabled: true,
136+
Name: "env",
134137
URL: manifest.URLDefinition{
135138
Type: manifest.ValueURLType,
136139
Name: "URL",
@@ -163,7 +166,8 @@ func TestVerifyEnvironmentGen(t *testing.T) {
163166

164167
ok := VerifyEnvironmentGeneration(t.Context(), manifest.Environments{
165168
"env": manifest.EnvironmentDefinition{
166-
Name: "env",
169+
Enabled: true,
170+
Name: "env",
167171
URL: manifest.URLDefinition{
168172
Type: manifest.ValueURLType,
169173
Name: "URL",
@@ -202,7 +206,8 @@ func TestVerifyEnvironmentGen(t *testing.T) {
202206

203207
ok := VerifyEnvironmentGeneration(t.Context(), manifest.Environments{
204208
"env1": manifest.EnvironmentDefinition{
205-
Name: "env1",
209+
Enabled: true,
210+
Name: "env1",
206211
URL: manifest.URLDefinition{
207212
Type: manifest.ValueURLType,
208213
Name: "URL",
@@ -214,7 +219,8 @@ func TestVerifyEnvironmentGen(t *testing.T) {
214219

215220
ok = VerifyEnvironmentGeneration(t.Context(), manifest.Environments{
216221
"env2": manifest.EnvironmentDefinition{
217-
Name: "env2",
222+
Enabled: true,
223+
Name: "env2",
218224
URL: manifest.URLDefinition{
219225
Type: manifest.ValueURLType,
220226
Name: "URL",

0 commit comments

Comments
 (0)