From 54130dcc1d775506d34b83a558952176fc549914 Mon Sep 17 00:00:00 2001 From: Nikita Pivkin Date: Tue, 3 Dec 2024 05:25:42 +0600 Subject: [PATCH] fix(misconf): wrap AWS EnvVar to iac types (#7407) Signed-off-by: nikpivkin --- pkg/iac/adapters/cloudformation/aws/ecs/ecs_test.go | 4 ++-- .../cloudformation/aws/ecs/task_definition.go | 4 ++-- pkg/iac/adapters/terraform/aws/ecs/adapt_test.go | 4 ++-- pkg/iac/providers/aws/ecs/ecs.go | 11 ++++++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pkg/iac/adapters/cloudformation/aws/ecs/ecs_test.go b/pkg/iac/adapters/cloudformation/aws/ecs/ecs_test.go index 9cf56b0d8b6f..d1da249f7525 100644 --- a/pkg/iac/adapters/cloudformation/aws/ecs/ecs_test.go +++ b/pkg/iac/adapters/cloudformation/aws/ecs/ecs_test.go @@ -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"), }, }, }, diff --git a/pkg/iac/adapters/cloudformation/aws/ecs/task_definition.go b/pkg/iac/adapters/cloudformation/aws/ecs/task_definition.go index b4cc39205147..c9b8e59a4a86 100644 --- a/pkg/iac/adapters/cloudformation/aws/ecs/task_definition.go +++ b/pkg/iac/adapters/cloudformation/aws/ecs/task_definition.go @@ -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"), }) } } diff --git a/pkg/iac/adapters/terraform/aws/ecs/adapt_test.go b/pkg/iac/adapters/terraform/aws/ecs/adapt_test.go index 9c70a3b1abee..412380e4d197 100644 --- a/pkg/iac/adapters/terraform/aws/ecs/adapt_test.go +++ b/pkg/iac/adapters/terraform/aws/ecs/adapt_test.go @@ -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"), }, }, }, diff --git a/pkg/iac/providers/aws/ecs/ecs.go b/pkg/iac/providers/aws/ecs/ecs.go index 36e9938c80f2..661d2233b2da 100755 --- a/pkg/iac/providers/aws/ecs/ecs.go +++ b/pkg/iac/providers/aws/ecs/ecs.go @@ -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), @@ -99,8 +104,8 @@ type ContainerDefinition struct { } type EnvVar struct { - Name string - Value string + Name iacTypes.StringValue + Value iacTypes.StringValue } type PortMapping struct {