diff --git a/internal/resource/infrastructure_stack_model.go b/internal/resource/infrastructure_stack_model.go index 5b3f427..4850c89 100644 --- a/internal/resource/infrastructure_stack_model.go +++ b/internal/resource/infrastructure_stack_model.go @@ -330,7 +330,7 @@ func (iscs *InfrastructureStackContainerSpec) Attributes(ctx context.Context, d return &gqlclient.ContainerAttributes{ Image: iscs.Image.ValueString(), Args: iscs.ArgsAttributes(ctx, d), - Env: nil, // TODO + Env: iscs.EnvAttributes(ctx, d), EnvFrom: iscs.EnvFromAttributes(ctx, d), } } @@ -345,6 +345,22 @@ func (isjs *InfrastructureStackContainerSpec) ArgsAttributes(ctx context.Context return algorithms.Map(elements, func(v types.String) *string { return v.ValueStringPointer() }) } +func (isjs *InfrastructureStackContainerSpec) EnvAttributes(ctx context.Context, d diag.Diagnostics) []*gqlclient.EnvAttributes { + if isjs.Env.IsNull() { + return nil + } + + result := make([]*gqlclient.EnvAttributes, 0) + elements := make(map[string]types.String, len(isjs.Env.Elements())) + d.Append(isjs.Env.ElementsAs(ctx, &elements, false)...) + + for k, v := range elements { + result = append(result, &gqlclient.EnvAttributes{Name: k, Value: v.ValueString()}) + } + + return result +} + func (isjs *InfrastructureStackContainerSpec) EnvFromAttributes(ctx context.Context, d diag.Diagnostics) []*gqlclient.EnvFromAttributes { if isjs.EnvFrom.IsNull() { return nil