Skip to content

Commit

Permalink
fix(misconf): wrap AWS EnvVar to iac types (#7407)
Browse files Browse the repository at this point in the history
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
  • Loading branch information
nikpivkin authored Dec 2, 2024
1 parent a16270c commit 54130dc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/iac/adapters/cloudformation/aws/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Resources:
Privileged: types.BoolTest(true),
Environment: []ecs.EnvVar{
{
Name: "entryPoint",
Value: "sh, -c",
Name: types.StringTest("entryPoint"),
Value: types.StringTest("sh, -c"),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/iac/adapters/cloudformation/aws/ecs/task_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func getContainerDefinitions(r *parser.Resource) ([]ecs.ContainerDefinition, err
if envVarsList.IsNotNil() && envVarsList.IsList() {
for _, envVar := range envVarsList.AsList() {
envVars = append(envVars, ecs.EnvVar{
Name: envVar.GetStringProperty("Name").Value(),
Value: envVar.GetStringProperty("Value").Value(),
Name: envVar.GetStringProperty("Name"),
Value: envVar.GetStringProperty("Value"),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/iac/adapters/terraform/aws/ecs/adapt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func Test_adaptTaskDefinitionResource(t *testing.T) {
Privileged: iacTypes.Bool(false, iacTypes.NewTestMetadata()),
Environment: []ecs.EnvVar{
{
Name: "ENVIRONMENT",
Value: "development",
Name: iacTypes.StringTest("ENVIRONMENT"),
Value: iacTypes.StringTest("development"),
},
},
},
Expand Down
11 changes: 8 additions & 3 deletions pkg/iac/providers/aws/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ func (j containerDefinitionJSON) convert(metadata iacTypes.Metadata) ContainerDe
HostPort: iacTypes.Int(jMapping.HostPort, metadata),
})
}

var envVars []EnvVar
for _, env := range j.EnvVars {
envVars = append(envVars, EnvVar(env))
envVars = append(envVars, EnvVar{
Name: iacTypes.String(env.Name, metadata),
Value: iacTypes.String(env.Value, metadata),
})
}

return ContainerDefinition{
Metadata: metadata,
Name: iacTypes.String(j.Name, metadata),
Expand All @@ -99,8 +104,8 @@ type ContainerDefinition struct {
}

type EnvVar struct {
Name string
Value string
Name iacTypes.StringValue
Value iacTypes.StringValue
}

type PortMapping struct {
Expand Down

0 comments on commit 54130dc

Please sign in to comment.