Skip to content

Commit

Permalink
scaffold request and response types
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoe committed May 25, 2021
1 parent 668dd44 commit 196a620
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 13 deletions.
12 changes: 0 additions & 12 deletions framework.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/hashicorp/terraform-plugin-framework

go 1.16

require github.com/hashicorp/terraform-plugin-go v0.2.1
require github.com/hashicorp/terraform-plugin-go v0.3.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9
github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0=
github.com/hashicorp/terraform-plugin-go v0.2.1 h1:EW/R8bB2Zbkjmugzsy1d27yS8/0454b3MtYHkzOknqA=
github.com/hashicorp/terraform-plugin-go v0.2.1/go.mod h1:10V6F3taeDWVAoLlkmArKttR3IULlRWFAGtQIQTIDr4=
github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA=
github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand Down
30 changes: 30 additions & 0 deletions request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package tfsdk

import (
"github.com/hashicorp/terraform-plugin-go/tftypes"
)

type ConfigureProviderRequest struct {
Config *tftypes.Value
}

type CreateResourceRequest struct {
Config *tftypes.Value
PriorState State
PlannedState State
}

type ReadResourceRequest struct {
Config *tftypes.Value
CurrentState State
}

type DeleteResourceRequest struct {
Config *tftypes.Value
}

type UpdateResourceRequest struct {
Config *tftypes.Value
PriorState State
PlannedState State
}
64 changes: 64 additions & 0 deletions response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package tfsdk

import (
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)

type ConfigureProviderResponse struct {
Diagnostics []*tfprotov6.Diagnostic
}

type CreateResourceResponse struct {
NewState State

Diagnostics []*tfprotov6.Diagnostic
}

func (r *CreateResourceResponse) AddWarning(summary, detail string) {
r.Diagnostics = append(r.Diagnostics, &tfprotov6.Diagnostic{
Summary: summary,
Detail: detail,
Severity: tfprotov6.DiagnosticSeverityWarning,
})
}

func (r *CreateResourceResponse) AddAttributeWarning(attributePath *tftypes.AttributePath, summary, detail string) {
r.Diagnostics = append(r.Diagnostics, &tfprotov6.Diagnostic{
Attribute: attributePath,
Summary: summary,
Detail: detail,
Severity: tfprotov6.DiagnosticSeverityWarning,
})
}

func (r *CreateResourceResponse) AddError(summary, detail string) {
r.Diagnostics = append(r.Diagnostics, &tfprotov6.Diagnostic{
Summary: summary,
Detail: detail,
Severity: tfprotov6.DiagnosticSeverityError,
})
}

func (r *CreateResourceResponse) AddAttributeError(attributePath *tftypes.AttributePath, summary, detail string) {
r.Diagnostics = append(r.Diagnostics, &tfprotov6.Diagnostic{
Attribute: attributePath,
Summary: summary,
Detail: detail,
Severity: tfprotov6.DiagnosticSeverityError,
})
}

type ReadResourceResponse struct {
Diagnostics []*tfprotov6.Diagnostic
}

type DeleteResourceResponse struct {
Diagnostics []*tfprotov6.Diagnostic
}

type UpdateResourceResponse struct {
NewState State

Diagnostics []*tfprotov6.Diagnostic
}

0 comments on commit 196a620

Please sign in to comment.