Skip to content

Commit

Permalink
Merge branch 'release/v0.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Apr 4, 2024
2 parents 24d7e2c + 5331b2a commit 8868dcf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docs/resources/uplink.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ resource "instellar_cluster" "main" {
resource "instellar_uplink" "this" {
channel_slug = "master"
kit_slug = "lite"
cluster_id = instellar_cluster.main.id
database_url = "postgresql://user:pass@localhost:5432/some_db_example"
}
```

Expand All @@ -41,4 +41,5 @@ resource "instellar_uplink" "this" {

- `current_state` (String) The current state of uplink
- `id` (String) Uplink identifier
- `installation_id` (String) Which installation does uplink belong to
- `last_updated` (String) Timestamp of terraform update
2 changes: 1 addition & 1 deletion examples/resources/instellar_uplink/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ resource "instellar_cluster" "main" {

resource "instellar_uplink" "this" {
channel_slug = "master"
kit_slug = "lite"
cluster_id = instellar_cluster.main.id
database_url = "postgresql://user:pass@localhost:5432/some_db_example"
}
20 changes: 14 additions & 6 deletions instellar/uplink/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ type uplinkResource struct {
}

type uplinkResourceModel struct {
ID types.String `tfsdk:"id"`
ChannelSlug types.String `tfsdk:"channel_slug"`
KitSlug types.String `tfsdk:"kit_slug"`
CurrentState types.String `tfsdk:"current_state"`
ClusterID types.String `tfsdk:"cluster_id"`
LastUpdated types.String `tfsdk:"last_updated"`
ID types.String `tfsdk:"id"`
ChannelSlug types.String `tfsdk:"channel_slug"`
KitSlug types.String `tfsdk:"kit_slug"`
CurrentState types.String `tfsdk:"current_state"`
ClusterID types.String `tfsdk:"cluster_id"`
InstallationID types.String `tfsdk:"installation_id"`
LastUpdated types.String `tfsdk:"last_updated"`
}

func (r *uplinkResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
Expand Down Expand Up @@ -70,6 +71,10 @@ func (r *uplinkResource) Schema(_ context.Context, _ resource.SchemaRequest, res
Description: "Which cluster does uplink belong to",
Required: true,
},
"installation_id": schema.StringAttribute{
Description: "Which installation does uplink belong to",
Computed: true,
},
"last_updated": schema.StringAttribute{
Description: "Timestamp of terraform update",
Computed: true,
Expand Down Expand Up @@ -127,6 +132,7 @@ func (r *uplinkResource) Create(ctx context.Context, req resource.CreateRequest,
plan.ID = types.StringValue(strconv.Itoa(uplink.Data.Attributes.ID))
plan.CurrentState = types.StringValue(uplink.Data.Attributes.CurrentState)
plan.ClusterID = types.StringValue(strconv.Itoa(uplink.Data.Attributes.ClusterID))
plan.InstallationID = types.StringValue(strconv.Itoa(uplink.Data.Attributes.InstallationID))
plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850))

diags = resp.State.Set(ctx, plan)
Expand Down Expand Up @@ -158,6 +164,7 @@ func (r *uplinkResource) Read(ctx context.Context, req resource.ReadRequest, res
state.KitSlug = types.StringValue(uplink.Data.Attributes.KitSlug)
state.CurrentState = types.StringValue(uplink.Data.Attributes.CurrentState)
state.ClusterID = types.StringValue(strconv.Itoa(uplink.Data.Attributes.ClusterID))
state.InstallationID = types.StringValue(strconv.Itoa(uplink.Data.Attributes.InstallationID))

diags = resp.State.Set(ctx, &state)
resp.Diagnostics.Append(diags...)
Expand Down Expand Up @@ -201,6 +208,7 @@ func (r *uplinkResource) Update(ctx context.Context, req resource.UpdateRequest,
plan.ChannelSlug = types.StringValue(uplink.Data.Attributes.ChannelSlug)
plan.KitSlug = types.StringValue(uplink.Data.Attributes.KitSlug)
plan.CurrentState = types.StringValue(uplink.Data.Attributes.CurrentState)
plan.InstallationID = types.StringValue(strconv.Itoa(uplink.Data.Attributes.InstallationID))
plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850))

diags = resp.State.Set(ctx, plan)
Expand Down

0 comments on commit 8868dcf

Please sign in to comment.