Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed May 26, 2023
2 parents 1b8d864 + e05af48 commit d7bdd0f
Show file tree
Hide file tree
Showing 9 changed files with 405 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "instellar_cluster" "example" {

- `endpoint` (String) Endpoint for cluster
- `name` (String) Name assigned by the user
- `password_token` (String) Password or Trust Token for cluster
- `password_token` (String, Sensitive) Password or Trust Token for cluster
- `provider_name` (String) Provider of the infrastructure
- `region` (String) Region of the cluster

Expand Down
33 changes: 33 additions & 0 deletions docs/resources/uplink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "instellar_uplink Resource - terraform-provider-instellar"
subcategory: ""
description: |-
Uplink management
---

# instellar_uplink (Resource)

Uplink management



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `channel_slug` (String) Which distribution channel are we using?
- `cluster_id` (String) Which cluster does uplink belong to

### Optional

- `database_url` (String, Sensitive) Database URL to use with uplink, if supplied will setup uplink pro

### Read-Only

- `current_state` (String) The current state of uplink
- `id` (String) Uplink identifier
- `last_updated` (String) Timestamp of terraform update


4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ module github.com/upmaru/terraform-provider-instellar
go 1.19

require (
github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-docs v0.14.1
github.com/hashicorp/terraform-plugin-framework v1.2.0
github.com/hashicorp/terraform-plugin-go v0.15.0
github.com/hashicorp/terraform-plugin-log v0.8.0
github.com/hashicorp/terraform-plugin-testing v1.2.0
github.com/upmaru/instellar-go v0.1.3
github.com/upmaru/instellar-go v0.2.6
)

require (
Expand All @@ -22,7 +23,6 @@ require (
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/upmaru/instellar-go v0.1.3 h1:6l9Xl/I6A/8uCk5gDI+GThe2tTK9avHm0CvzNtBeZdQ=
github.com/upmaru/instellar-go v0.1.3/go.mod h1:DyU7Pd7Syn6NIbdD5PMGkR1XE+qxGj0UDYwoKZgUxyI=
github.com/upmaru/instellar-go v0.2.6 h1:zzIdCPMmAreButJc5o7mlTcw29JNjqGTUuM298q4YaA=
github.com/upmaru/instellar-go v0.2.6/go.mod h1:DyU7Pd7Syn6NIbdD5PMGkR1XE+qxGj0UDYwoKZgUxyI=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand Down
17 changes: 9 additions & 8 deletions instellar/cluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cluster
import (
"context"
"fmt"
"strconv"
"time"

// instellar client = instc.
Expand Down Expand Up @@ -83,6 +84,7 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
},
"password_token": schema.StringAttribute{
Description: "Password or Trust Token for cluster",
Sensitive: true,
Required: true,
},
"last_updated": schema.StringAttribute{
Expand Down Expand Up @@ -115,7 +117,6 @@ func (r *clusterResource) Configure(_ context.Context, req resource.ConfigureReq
}

func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {

var plan clusterResourceModel
diags := req.Plan.Get(ctx, &plan)

Expand All @@ -139,12 +140,12 @@ func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest
if err != nil {
resp.Diagnostics.AddError(
"Error creating instellar cluster",
"Cloud not create order, unexpected error: "+err.Error(),
"Cloud not create cluster, unexpected error: "+err.Error(),
)
return
}

plan.ID = types.StringValue(cluster.Data.Attributes.Slug)
plan.ID = types.StringValue(strconv.Itoa(cluster.Data.Attributes.ID))
plan.Name = types.StringValue(cluster.Data.Attributes.Name)
plan.Slug = types.StringValue(cluster.Data.Attributes.Slug)
plan.Region = types.StringValue(cluster.Data.Attributes.Region)
Expand All @@ -171,7 +172,7 @@ func (r *clusterResource) Read(ctx context.Context, req resource.ReadRequest, re
if err != nil {
resp.Diagnostics.AddError(
"Error reading instellar cluster",
"Cloud not read cluster id "+state.Slug.ValueString()+": "+err.Error(),
"Cloud not read cluster id "+state.ID.ValueString()+": "+err.Error(),
)
return
}
Expand All @@ -198,7 +199,7 @@ func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

_, err := r.client.UpdateCluster(plan.Slug.ValueString())
_, err := r.client.UpdateCluster(plan.ID.ValueString())
if err != nil {
resp.Diagnostics.AddError(
"Error updating instellar cluster",
Expand All @@ -207,12 +208,12 @@ func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

cluster, err := r.client.GetCluster(plan.Slug.ValueString())
cluster, err := r.client.GetCluster(plan.ID.ValueString())

if err != nil {
resp.Diagnostics.AddError(
"Error reading instellar cluster",
"Could not read instellar cluster ID "+plan.Slug.ValueString()+": "+err.Error(),
"Could not read instellar cluster ID "+plan.ID.ValueString()+": "+err.Error(),
)
}

Expand All @@ -234,7 +235,7 @@ func (r *clusterResource) Delete(ctx context.Context, req resource.DeleteRequest
return
}

_, err := r.client.DeleteCluster(state.Slug.ValueString())
_, err := r.client.DeleteCluster(state.ID.ValueString())
if err != nil {
resp.Diagnostics.AddError(
"Error deleting cluster",
Expand Down
2 changes: 2 additions & 0 deletions instellar/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/upmaru/terraform-provider-instellar/instellar/cluster"
"github.com/upmaru/terraform-provider-instellar/instellar/uplink"
)

var (
Expand Down Expand Up @@ -137,5 +138,6 @@ func (p *instellarProvider) DataSources(_ context.Context) []func() datasource.D
func (p *instellarProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
cluster.NewClusterResource,
uplink.NewUplinkResource,
}
}
Loading

0 comments on commit d7bdd0f

Please sign in to comment.