Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstating associate external type for primitives #55

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20231017-173826.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ENHANCEMENTS
body: Add associated external types for Bool, Float64, Int64, Number, and String Attributes
for data sources, provider, and resources
time: 2023-10-17T17:38:26.139188+01:00
custom:
Issue: "62"
15 changes: 15 additions & 0 deletions datasource/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ type NestedAttributeObject struct {

// BoolAttribute represents a Schema attribute that is a boolean.
type BoolAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a BoolAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -139,6 +142,9 @@ type BoolAttribute struct {
// Use Int64Attribute for a 64-bit integer attribute, or NumberAttribute
// for a 512-bit generic number attribute.
type Float64Attribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a Float64Attribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -169,6 +175,9 @@ type Float64Attribute struct {
// Use Float64Attribute for a 64-bit floating point number, or
// NumberAttribute for a 512-bit generic number attribute.
type Int64Attribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a Int64Attribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -318,6 +327,9 @@ type MapNestedAttribute struct {
// Use Float64Attribute for a 64-bit floating point number attribute,
// or Int64Attribute for a 64-bit integer number attribute.
type NumberAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a NumberAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -464,6 +476,9 @@ type SingleNestedAttribute struct {

// StringAttribute represents a Schema attribute that is a string.
type StringAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a StringAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down
2 changes: 2 additions & 0 deletions datasource/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

func TestAttributes_Validate(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
attributes datasource.Attributes
request datasource.AttributeValidateRequest
Expand Down
15 changes: 15 additions & 0 deletions provider/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ type NestedAttributeObject struct {

// BoolAttribute represents a Schema attribute that is a boolean.
type BoolAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a BoolAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// OptionalRequired indicates whether the attribute is required
// (`required`), or optional (`optional`).
OptionalRequired schema.OptionalRequired `json:"optional_required"`
Expand Down Expand Up @@ -137,6 +140,9 @@ type BoolAttribute struct {
// Use Int64Attribute for a 64-bit integer attribute, or NumberAttribute
// for a 512-bit generic number attribute.
type Float64Attribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a Float64Attribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// OptionalRequired indicates whether the attribute is required
// (`required`), or optional (`optional`).
OptionalRequired schema.OptionalRequired `json:"optional_required"`
Expand Down Expand Up @@ -165,6 +171,9 @@ type Float64Attribute struct {
// Use Float64Attribute for a 64-bit floating point number, or
// NumberAttribute for a 512-bit generic number attribute.
type Int64Attribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a Int64Attribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// OptionalRequired indicates whether the attribute is required
// (`required`), or optional (`optional`).
OptionalRequired schema.OptionalRequired `json:"optional_required"`
Expand Down Expand Up @@ -309,6 +318,9 @@ type MapNestedAttribute struct {
// Use Float64Attribute for a 64-bit floating point number attribute,
// or Int64Attribute for a 64-bit integer number attribute.
type NumberAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a NumberAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// OptionalRequired indicates whether the attribute is required
// (`required`), or optional (`optional`).
OptionalRequired schema.OptionalRequired `json:"optional_required"`
Expand Down Expand Up @@ -453,6 +465,9 @@ type SingleNestedAttribute struct {

// StringAttribute represents a Schema attribute that is a string.
type StringAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a StringAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// OptionalRequired indicates whether the attribute is required
// (`required`), or optional (`optional`).
OptionalRequired schema.OptionalRequired `json:"optional_required"`
Expand Down
2 changes: 2 additions & 0 deletions provider/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

func TestAttributes_Validate(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
attributes provider.Attributes
request provider.AttributeValidateRequest
Expand Down
15 changes: 15 additions & 0 deletions resource/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ type NestedAttributeObject struct {

// BoolAttribute represents a Schema attribute that is a boolean.
type BoolAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a BoolAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -150,6 +153,9 @@ type BoolAttribute struct {
// Use Int64Attribute for a 64-bit integer attribute, or NumberAttribute
// for a 512-bit generic number attribute.
type Float64Attribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a Float64Attribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -186,6 +192,9 @@ type Float64Attribute struct {
// Use Float64Attribute for a 64-bit floating point number, or
// NumberAttribute for a 512-bit generic number attribute.
type Int64Attribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a Int64Attribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -371,6 +380,9 @@ type MapNestedAttribute struct {
// Use Float64Attribute for a 64-bit floating point number attribute,
// or Int64Attribute for a 64-bit integer number attribute.
type NumberAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a NumberAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down Expand Up @@ -555,6 +567,9 @@ type SingleNestedAttribute struct {

// StringAttribute represents a Schema attribute that is a string.
type StringAttribute struct {
// AssociatedExternalType defines a Go type that can be used to represent a StringAttribute.
AssociatedExternalType *schema.AssociatedExternalType `json:"associated_external_type,omitempty"`

// ComputedOptionalRequired indicates whether the attribute is required
// (`required`), optional (`optional`), computed (`computed`), or
// computed and optional (`computed_optional`).
Expand Down
2 changes: 2 additions & 0 deletions resource/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

func TestAttributes_Validate(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
attributes resource.Attributes
request resource.AttributeValidateRequest
Expand Down
Loading