Skip to content

Commit

Permalink
updated terraform-plugin-framework to v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andreee94 committed Dec 20, 2022
1 parent 0d131df commit 919e603
Show file tree
Hide file tree
Showing 20 changed files with 384 additions and 744 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HOSTNAME=registry.terraform.io
NAMESPACE=andreee94
NAME=warpgate
BINARY=terraform-provider-${NAME}
VERSION=0.2.0
VERSION=0.3.0
OS_ARCH=linux_amd64

GOBIN=~/go/bin
Expand Down
47 changes: 21 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,61 @@ go 1.18

require (
github.com/deepmap/oapi-codegen v1.12.3
github.com/hashicorp/terraform-plugin-framework v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.0.1
github.com/hashicorp/terraform-plugin-framework-validators v0.9.0
github.com/hashicorp/terraform-plugin-go v0.14.2
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
)

require (
github.com/bxcodec/faker/v4 v4.0.0-beta.3
github.com/hashicorp/terraform-plugin-framework-validators v0.6.0
github.com/google/uuid v1.3.0
)

require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-test/deep v1.0.7 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
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/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.6 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.4.0 // indirect
github.com/hashicorp/hcl/v2 v2.14.0 // indirect
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.17.3 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.11.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
)

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
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-plugin v1.4.6 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
82 changes: 20 additions & 62 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var (
// these will be set by the goreleaser configuration
// to appropriate values for the compiled binary
Version string = "0.1.0"
Version string = "0.2.0"

// goreleaser can also pass the specific commit if you want
// commit string = ""
Expand Down
78 changes: 26 additions & 52 deletions provider/datasource_http_target_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

Expand All @@ -21,62 +20,37 @@ func NewHttpTargetListDataSource() datasource.DataSource {
return &httpTargetListDataSource{}
}

func (d *httpTargetListDataSource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Attributes: map[string]tfsdk.Attribute{
"id": { // required for acceptance testing
Type: types.StringType,
func (d httpTargetListDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{Computed: true},
"targets": schema.ListNestedAttribute{
Computed: true,
},
"targets": {
Computed: true,
Attributes: tfsdk.ListNestedAttributes(map[string]tfsdk.Attribute{
"allow_roles": {
Type: types.SetType{ElemType: types.StringType},
Computed: true,
},
"id": {
Type: types.StringType,
Computed: true,
},
"name": {
Type: types.StringType,
Computed: true,
},
"options": {
Computed: true,
Attributes: tfsdk.SingleNestedAttributes(map[string]tfsdk.Attribute{
"external_host": {
Type: types.StringType,
Computed: true,
},
"url": {
Type: types.StringType,
Computed: true,
},
"headers": {
Type: types.MapType{ElemType: types.StringType},
Computed: true,
},
"tls": {
Computed: true,
Attributes: tfsdk.SingleNestedAttributes(map[string]tfsdk.Attribute{
"mode": {
Type: types.StringType,
Computed: true,
},
"verify": {
Type: types.BoolType,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"allow_roles": schema.SetAttribute{Computed: true, ElementType: types.StringType},
"id": schema.StringAttribute{Computed: true},
"name": schema.StringAttribute{Computed: true},
"options": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"external_host": schema.StringAttribute{Computed: true},
"url": schema.StringAttribute{Computed: true},
"headers": schema.MapAttribute{Computed: true, ElementType: types.StringType},
"tls": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"mode": schema.StringAttribute{Computed: true},
"verify": schema.BoolAttribute{Computed: true},
},
}),
},
},
}),
},
},
}),
},
},
},
}, nil
}
}

type httpTargetListDataSource struct {
Expand Down
32 changes: 12 additions & 20 deletions provider/datasource_role_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

Expand All @@ -21,28 +20,21 @@ func NewRoleListDataSource() datasource.DataSource {
return &roleListDataSource{}
}

func (r *roleListDataSource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Attributes: map[string]tfsdk.Attribute{
"id": { // required for acceptance testing
Type: types.StringType,
func (d roleListDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{Computed: true},
"roles": schema.ListNestedAttribute{
Computed: true,
},
"roles": {
Computed: true,
Attributes: tfsdk.ListNestedAttributes(map[string]tfsdk.Attribute{
"id": {
Type: types.StringType,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{Computed: true},
"name": schema.StringAttribute{Computed: true},
},
"name": {
Type: types.StringType,
Computed: true,
},
}),
},
},
},
}, nil
}
}

type roleListDataSource struct {
Expand Down
79 changes: 22 additions & 57 deletions provider/datasource_ssh_target_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"terraform-provider-warpgate/warpgate"

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"

Expand All @@ -23,65 +21,32 @@ func NewSshTargetListDataSource() datasource.DataSource {
return &sshTargetListDataSource{}
}

func (r *sshTargetListDataSource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{
Attributes: map[string]tfsdk.Attribute{
"id": { // required for acceptance testing
Type: types.StringType,
func (d sshTargetListDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{Computed: true},
"targets": schema.ListNestedAttribute{
Computed: true,
},
"targets": {
Computed: true,
Attributes: tfsdk.ListNestedAttributes(map[string]tfsdk.Attribute{
"allow_roles": {
Type: types.SetType{ElemType: types.StringType},
Computed: true,
},
"id": {
Type: types.StringType,
Computed: true,
},
"name": {
Type: types.StringType,
Computed: true,
},
"options": {
Computed: true,
Attributes: tfsdk.SingleNestedAttributes(map[string]tfsdk.Attribute{
"host": {
Type: types.StringType,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{Computed: true},
"name": schema.StringAttribute{Computed: true},
"allow_roles": schema.SetAttribute{Computed: true, ElementType: types.StringType},
"options": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
"host": schema.StringAttribute{Computed: true},
"port": schema.Int64Attribute{Computed: true},
"username": schema.StringAttribute{Computed: true},
"auth_kind": schema.StringAttribute{Computed: true},
"password": schema.StringAttribute{Computed: true, Sensitive: true},
},
"port": {
Type: types.Int64Type,
Computed: true,
},
"username": {
Type: types.StringType,
Computed: true,
},
"auth_kind": {
Type: types.StringType,
Computed: true,
Validators: []tfsdk.AttributeValidator{
stringvalidator.OneOf(
string(warpgate.Password),
string(warpgate.PublicKey),
),
// validators.StringIn([]string{string(warpgate.Password), string(warpgate.PublicKey)}, false),
},
},
"password": {
Type: types.StringType,
Computed: true,
Sensitive: true,
},
}),
},
},
}),
},
},
},
}, nil
}
}

type sshTargetListDataSource struct {
Expand Down
Loading

0 comments on commit 919e603

Please sign in to comment.