Skip to content

Commit

Permalink
Merge branch 'release/v0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jun 1, 2023
2 parents fec467c + c2a4012 commit e37d5c9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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-framework-validators v0.10.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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ github.com/hashicorp/terraform-plugin-docs v0.14.1 h1:MikFi59KxrP/ewrZoaowrB9he5
github.com/hashicorp/terraform-plugin-docs v0.14.1/go.mod h1:k2NW8+t113jAus6bb5tQYQgEAX/KueE/u8X2Z45V1GM=
github.com/hashicorp/terraform-plugin-framework v1.2.0 h1:MZjFFfULnFq8fh04FqrKPcJ/nGpHOvX4buIygT3MSNY=
github.com/hashicorp/terraform-plugin-framework v1.2.0/go.mod h1:nToI62JylqXDq84weLJ/U3umUsBhZAaTmU0HXIVUOcw=
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8esP6OcvocVymw52lY0HyQ5OxB7VNl7k4bS0=
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE=
github.com/hashicorp/terraform-plugin-go v0.15.0 h1:1BJNSUFs09DS8h/XNyJNJaeusQuWc/T9V99ylU9Zwp0=
github.com/hashicorp/terraform-plugin-go v0.15.0/go.mod h1:tk9E3/Zx4RlF/9FdGAhwxHExqIHHldqiQGt20G6g+nQ=
github.com/hashicorp/terraform-plugin-log v0.8.0 h1:pX2VQ/TGKu+UU1rCay0OlzosNKe4Nz1pepLXj95oyy0=
Expand Down
14 changes: 14 additions & 0 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"
"regexp"
"strconv"
"time"

Expand All @@ -14,7 +15,10 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
)

var (
Expand Down Expand Up @@ -61,6 +65,13 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
"name": schema.StringAttribute{
Description: "Name assigned by the user",
Required: true,
Validators: []validator.String{
stringvalidator.LengthBetween(3, 32),
stringvalidator.RegexMatches(
regexp.MustCompile(`^[a-z0-9\-]+$`),
"must contain only lowercase alphanumeric characters",
),
},
},
"slug": schema.StringAttribute{
Description: "Unique slug for cluster",
Expand All @@ -73,6 +84,9 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
"provider_name": schema.StringAttribute{
Description: "Provider of the infrastructure",
Required: true,
Validators: []validator.String{
stringvalidator.OneOf([]string{"aws", "hcloud", "digitalocean", "google", "azurerm"}...),
},
},
"region": schema.StringAttribute{
Description: "Region of the cluster",
Expand Down
9 changes: 9 additions & 0 deletions instellar/node/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ package node
import (
"context"
"fmt"
"regexp"
"strconv"
"time"

instc "github.com/upmaru/instellar-go"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)

Expand Down Expand Up @@ -57,6 +60,12 @@ func (r *nodeResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
"slug": schema.StringAttribute{
Description: "Node slug",
Required: true,
Validators: []validator.String{
stringvalidator.RegexMatches(
regexp.MustCompile(`^[a-z0-9\-]+$`),
"must contain only lowercase alphanumeric characters",
),
},
},
"current_state": schema.StringAttribute{
Description: "Current state",
Expand Down

0 comments on commit e37d5c9

Please sign in to comment.