Skip to content

Commit

Permalink
WIP add first_recoverability_time to Instance model
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel committed Aug 15, 2024
1 parent e0e6b33 commit 74a5aca
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions internal/provider/instance_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"
temboclient "github.com/tembo-io/terraform-provider-tembo/temboclient"
)

Expand All @@ -35,24 +36,25 @@ const (

// temboInstanceResourceModel maps the resource schema data.
type temboInstanceResourceModel struct {
InstanceID types.String `tfsdk:"instance_id"`
InstanceName types.String `tfsdk:"instance_name"`
OrgId types.String `tfsdk:"org_id"`
CPU types.String `tfsdk:"cpu"`
StackType types.String `tfsdk:"stack_type"`
Environment types.String `tfsdk:"environment"`
Replicas types.Int64 `tfsdk:"replicas"`
Memory types.String `tfsdk:"memory"`
Storage types.String `tfsdk:"storage"`
LastUpdated types.String `tfsdk:"last_updated"`
State types.String `tfsdk:"state"`
ExtraDomainsRw []types.String `tfsdk:"extra_domains_rw"`
PostgresConfigs []KeyValue `tfsdk:"postgres_configs"`
TrunkInstalls []TrunkInstall `tfsdk:"trunk_installs"`
Extensions []Extension `tfsdk:"extensions"`
IpAllowList []types.String `tfsdk:"ip_allow_list"`
ConnectionPooler *ConnectionPooler `tfsdk:"connection_pooler"`
Restore *Restore `tfsdk:"restore"`
InstanceID types.String `tfsdk:"instance_id"`
InstanceName types.String `tfsdk:"instance_name"`
OrgId types.String `tfsdk:"org_id"`
CPU types.String `tfsdk:"cpu"`
StackType types.String `tfsdk:"stack_type"`
Environment types.String `tfsdk:"environment"`
Replicas types.Int64 `tfsdk:"replicas"`
Memory types.String `tfsdk:"memory"`
Storage types.String `tfsdk:"storage"`
LastUpdated types.String `tfsdk:"last_updated"`
State types.String `tfsdk:"state"`
ExtraDomainsRw []types.String `tfsdk:"extra_domains_rw"`
PostgresConfigs []KeyValue `tfsdk:"postgres_configs"`
TrunkInstalls []TrunkInstall `tfsdk:"trunk_installs"`
Extensions []Extension `tfsdk:"extensions"`
IpAllowList []types.String `tfsdk:"ip_allow_list"`
ConnectionPooler *ConnectionPooler `tfsdk:"connection_pooler"`
Restore *Restore `tfsdk:"restore"`
FirstRecoverabilityTime types.String `tfsdk:"first_recoverability_time"`
}

type Restore struct {
Expand Down Expand Up @@ -309,6 +311,11 @@ func (r *temboInstanceResource) Schema(_ context.Context, _ resource.SchemaReque
},
Optional: true,
},
"first_recoverability_time": schema.StringAttribute{
Computed: true,
Optional: true,
Description: "The time at which the instance first became recoverable",
},
},
}
}
Expand Down Expand Up @@ -716,6 +723,19 @@ func setTemboInstanceResourceModel(instanceResourceModel *temboInstanceResourceM
}
instanceResourceModel.IpAllowList = localIpAllowList
}

if instance.FirstRecoverabilityTime. != nil && instance.FirstRecoverabilityTime.IsSet() {

Check failure on line 727 in internal/provider/instance_resource.go

View workflow job for this annotation

GitHub Actions / generate

syntax error: unexpected !=, expecting name or (

Check failure on line 727 in internal/provider/instance_resource.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected !=, expecting name or (

Check failure on line 727 in internal/provider/instance_resource.go

View workflow job for this annotation

GitHub Actions / generate

syntax error: unexpected !=, expecting name or (

Check failure on line 727 in internal/provider/instance_resource.go

View workflow job for this annotation

GitHub Actions / Build

syntax error: unexpected !=, expecting name or (
// Happened right here
instanceResourceModel.FirstRecoverabilityTime = types.StringValue(instance.FirstRecoverabilityTime.Get().Format(time.RFC3339))
} else {
instanceResourceModel.FirstRecoverabilityTime = types.StringNull()
}

tflog.Debug(context.Background(), "Setting Tembo Instance state", map[string]interface{}{
"instance_id": instanceResourceModel.InstanceID.ValueString(),
"first_recoverability_time": instanceResourceModel.FirstRecoverabilityTime.ValueString(),
})

}

func getStringArray(inputArray []basetypes.StringValue) []string {
Expand Down

0 comments on commit 74a5aca

Please sign in to comment.