Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misconf): wrap AWS EnvVar to iac types #7407

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Down Expand Up @@ -101,8 +106,8 @@ type ContainerDefinition struct {
}

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

type PortMapping struct {
Expand Down
Loading