Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit cbe4e91

Browse files
Merge pull request #7 from matthewhartstonge/dependabot/go_modules/github.com/hashicorp/terraform-plugin-framework-0.16.0
2 parents ccc539c + 893dd34 commit cbe4e91

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

.run/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## .run
2+
3+
The `.run` folder provides configs to set your Intellij IDE up to perform
4+
testing locally.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="go test terraform-plugin-framework-type-uuid/uuidtype" type="GoTestRunConfiguration" factoryName="Go Test">
3+
<module name="terraform-plugin-framework-type-uuid" />
4+
<working_directory value="$PROJECT_DIR$/uuidtypes" />
5+
<root_directory value="$PROJECT_DIR$" />
6+
<kind value="PACKAGE" />
7+
<package value="github.com/matthewhartstonge/terraform-plugin-framework-type-uuid/uuidtypes" />
8+
<directory value="$PROJECT_DIR$" />
9+
<filePath value="$PROJECT_DIR$" />
10+
<framework value="gotest" />
11+
<method v="2" />
12+
</configuration>
13+
</component>

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/google/go-cmp v0.5.9
77
github.com/google/uuid v1.3.0
8-
github.com/hashicorp/terraform-plugin-framework v0.14.0
8+
github.com/hashicorp/terraform-plugin-framework v0.16.0
99
github.com/hashicorp/terraform-plugin-go v0.14.1
1010
)
1111

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
99
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1010
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
1111
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
12-
github.com/hashicorp/terraform-plugin-framework v0.14.0 h1:Mwj55u+Jc/QGM6fLBPCe1P+ZF3cuYs6wbCdB15lx/Dg=
13-
github.com/hashicorp/terraform-plugin-framework v0.14.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8=
12+
github.com/hashicorp/terraform-plugin-framework v0.16.0 h1:kEHh0d6dp5Ig/ey6PYXkWDZPMLIW8Me41T/Oa7bpO4s=
13+
github.com/hashicorp/terraform-plugin-framework v0.16.0/go.mod h1:Vk5MuIJoE1qksHZawAZr6psx6YXsQBFIKDrWbROrwus=
1414
github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek=
1515
github.com/hashicorp/terraform-plugin-go v0.14.1/go.mod h1:Bc/K6K26BQ2FHqIELPbpKtt2CzzbQou+0UQF3/0NsCQ=
1616
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=

uuidtypes/uuid.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ var (
3535

3636
// UUIDNull returns a null UUID value.
3737
func UUIDNull() UUID {
38-
return UUID{null: true}
38+
return UUID{state: attr.ValueStateNull}
3939
}
4040

4141
// UUIDUnknown returns an unknown UUID value.
4242
func UUIDUnknown() UUID {
43-
return UUID{unknown: true}
43+
return UUID{state: attr.ValueStateUnknown}
4444
}
4545

4646
// UUIDFromString returns a value or any errors when attempting to parse the
@@ -61,6 +61,7 @@ func UUIDFromString(value string, schemaPath path.Path) (UUID, diag.Diagnostics)
6161
}
6262

6363
return UUID{
64+
state: attr.ValueStateKnown,
6465
value: validUUID,
6566
}, nil
6667
}
@@ -69,16 +70,16 @@ func UUIDFromString(value string, schemaPath path.Path) (UUID, diag.Diagnostics)
6970
// UUID Value.
7071
func UUIDFromGoogleUUID(value uuid.UUID) UUID {
7172
return UUID{
73+
state: attr.ValueStateKnown,
7274
value: value,
7375
}
7476
}
7577

7678
// UUID provides a concrete implementation of a UUID tftypes.Value for the
7779
// Terraform Plugin framework.
7880
type UUID struct {
79-
null bool
80-
unknown bool
81-
value uuid.UUID
81+
state attr.ValueState
82+
value uuid.UUID
8283
}
8384

8485
// Type returns the UUID type that created the UUID.
@@ -101,12 +102,12 @@ func (u UUID) ToTerraformValue(_ context.Context) (tftypes.Value, error) {
101102

102103
// IsNull returns true if the uuid represents a null value.
103104
func (u UUID) IsNull() bool {
104-
return u.null
105+
return u.state == attr.ValueStateNull
105106
}
106107

107108
// IsUnknown returns true if the uuid represents an unknown value.
108109
func (u UUID) IsUnknown() bool {
109-
return u.unknown
110+
return u.state == attr.ValueStateUnknown
110111
}
111112

112113
// Equal returns true if the uuid is semantically equal to the Value passed as
@@ -117,11 +118,7 @@ func (u UUID) Equal(other attr.Value) bool {
117118
return false
118119
}
119120

120-
if otherValue.null != u.null {
121-
return false
122-
}
123-
124-
if otherValue.unknown != u.unknown {
121+
if otherValue.state != u.state {
125122
return false
126123
}
127124

@@ -133,13 +130,14 @@ func (u UUID) Equal(other attr.Value) bool {
133130
// or UnknownValueString (`<unknown>`) when IsUnknown() returns true,
134131
// or NullValueString (`<null>`) when IsNull() return true.
135132
func (u UUID) String() string {
136-
if u.null {
133+
switch u.state {
134+
case attr.ValueStateNull:
137135
return attr.NullValueString
138-
}
139136

140-
if u.unknown {
137+
case attr.ValueStateUnknown:
141138
return attr.UnknownValueString
142-
}
143139

144-
return u.value.String()
140+
default:
141+
return u.value.String()
142+
}
145143
}

uuidtypes/uuid_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func TestUUID_Equal(t *testing.T) {
150150
{
151151
name: "not-uuidtypes.UUID",
152152
value: uuidtypes.UUIDFromGoogleUUID(uuid.MustParse(valueUUIDv4)),
153-
other: types.String{Value: valueUUIDv4},
153+
other: types.StringValue(valueUUIDv4),
154154
expected: false,
155155
},
156156
}

uuidtypes/uuid_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ func (u UUIDType) ValueFromTerraform(_ context.Context, value tftypes.Value) (at
113113

114114
// ValueType returns attr.Value type returned by ValueFromTerraform.
115115
func (u UUIDType) ValueType(context.Context) attr.Value {
116-
return UUID{}
116+
return UUIDNull()
117117
}

0 commit comments

Comments
 (0)