From d5b324287a09c1acb5d41d283382b6568ed63a70 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Mon, 22 Apr 2024 12:35:18 +0200 Subject: [PATCH] update attributes --- .../resource/infrastructure_stack_model.go | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/internal/resource/infrastructure_stack_model.go b/internal/resource/infrastructure_stack_model.go index dd6ce75..874aae7 100644 --- a/internal/resource/infrastructure_stack_model.go +++ b/internal/resource/infrastructure_stack_model.go @@ -32,9 +32,9 @@ func (is *infrastructureStack) Attributes(ctx context.Context, d diag.Diagnostic Type: gqlclient.StackType(is.Type.ValueString()), RepositoryID: is.Repository.Id.ValueString(), ClusterID: is.ClusterId.ValueString(), - Git: gqlclient.GitRefAttributes{}, + Git: is.Repository.Attributes(), JobSpec: nil, - Configuration: gqlclient.StackConfigurationAttributes{}, + Configuration: is.Configuration.Attributes(), Approval: is.Approval.ValueBoolPointer(), ReadBindings: is.Bindings.ReadAttributes(ctx, d), WriteBindings: is.Bindings.WriteAttributes(ctx, d), @@ -75,6 +75,17 @@ type InfrastructureStackRepository struct { Folder types.String `tfsdk:"folder"` } +func (isr *InfrastructureStackRepository) Attributes() gqlclient.GitRefAttributes { + if isr == nil { + return gqlclient.GitRefAttributes{} + } + + return gqlclient.GitRefAttributes{ + Ref: isr.Ref.ValueString(), + Folder: isr.Folder.ValueString(), + } +} + func (isr *InfrastructureStackRepository) From(repository *gqlclient.GitRepositoryFragment, ref *gqlclient.GitRefFragment) { if isr == nil { return @@ -95,6 +106,17 @@ type InfrastructureStackConfiguration struct { Version types.String `tfsdk:"version"` } +func (isc *InfrastructureStackConfiguration) Attributes() gqlclient.StackConfigurationAttributes { + if isc == nil { + return gqlclient.StackConfigurationAttributes{} + } + + return gqlclient.StackConfigurationAttributes{ + Image: isc.Image.ValueStringPointer(), + Version: isc.Version.ValueString(), + } +} + func (isc *InfrastructureStackConfiguration) From(configuration *gqlclient.StackConfigurationFragment) { if isc == nil || configuration == nil { return