Skip to content

Commit

Permalink
finish attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Apr 22, 2024
1 parent 6ff4a34 commit b085657
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion internal/resource/infrastructure_stack_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand All @@ -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
Expand Down

0 comments on commit b085657

Please sign in to comment.