Skip to content

Commit 8852480

Browse files
authored
Resource Identity: Initial implementation + Schemas (#1107)
* new attribute additions (breaks build for existing internal schema attributes) * update internal testing/testschema * implement in datasource/schema * implement in ephemeral/schema * implement in provider/metaschema * implement in provider/schema * implement in resource/schema * add to final internal/testing/testschema * get resource identity schema implementation * protov6 + tests * fix up package docs + build specific TODO comments * spellcheck! * update go dep * update go sum
1 parent 2f5a4aa commit 8852480

File tree

251 files changed

+14042
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+14042
-25
lines changed

datasource/schema/bool_attribute.go

+12
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,15 @@ func (a BoolAttribute) IsWriteOnly() bool {
191191
func (a BoolAttribute) IsSensitive() bool {
192192
return a.Sensitive
193193
}
194+
195+
// IsRequiredForImport returns false as this behavior is only relevant
196+
// for managed resource identity schema attributes.
197+
func (a BoolAttribute) IsRequiredForImport() bool {
198+
return false
199+
}
200+
201+
// IsOptionalForImport returns false as this behavior is only relevant
202+
// for managed resource identity schema attributes.
203+
func (a BoolAttribute) IsOptionalForImport() bool {
204+
return false
205+
}

datasource/schema/bool_attribute_test.go

+52
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,55 @@ func TestBoolAttributeIsWriteOnly(t *testing.T) {
428428
})
429429
}
430430
}
431+
432+
func TestBoolAttributeIsRequiredForImport(t *testing.T) {
433+
t.Parallel()
434+
435+
testCases := map[string]struct {
436+
attribute schema.BoolAttribute
437+
expected bool
438+
}{
439+
"not-requiredForImport": {
440+
attribute: schema.BoolAttribute{},
441+
expected: false,
442+
},
443+
}
444+
445+
for name, testCase := range testCases {
446+
t.Run(name, func(t *testing.T) {
447+
t.Parallel()
448+
449+
got := testCase.attribute.IsRequiredForImport()
450+
451+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
452+
t.Errorf("unexpected difference: %s", diff)
453+
}
454+
})
455+
}
456+
}
457+
458+
func TestBoolAttributeIsOptionalForImport(t *testing.T) {
459+
t.Parallel()
460+
461+
testCases := map[string]struct {
462+
attribute schema.BoolAttribute
463+
expected bool
464+
}{
465+
"not-optionalForImport": {
466+
attribute: schema.BoolAttribute{},
467+
expected: false,
468+
},
469+
}
470+
471+
for name, testCase := range testCases {
472+
t.Run(name, func(t *testing.T) {
473+
t.Parallel()
474+
475+
got := testCase.attribute.IsOptionalForImport()
476+
477+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
478+
t.Errorf("unexpected difference: %s", diff)
479+
}
480+
})
481+
}
482+
}

datasource/schema/dynamic_attribute.go

+12
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ func (a DynamicAttribute) IsWriteOnly() bool {
188188
return false
189189
}
190190

191+
// IsRequiredForImport returns false as this behavior is only relevant
192+
// for managed resource identity schema attributes.
193+
func (a DynamicAttribute) IsRequiredForImport() bool {
194+
return false
195+
}
196+
197+
// IsOptionalForImport returns false as this behavior is only relevant
198+
// for managed resource identity schema attributes.
199+
func (a DynamicAttribute) IsOptionalForImport() bool {
200+
return false
201+
}
202+
191203
// DynamicValidators returns the Validators field value.
192204
func (a DynamicAttribute) DynamicValidators() []validator.Dynamic {
193205
return a.Validators

datasource/schema/dynamic_attribute_test.go

+52
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,55 @@ func TestDynamicAttributeDynamicValidators(t *testing.T) {
428428
})
429429
}
430430
}
431+
432+
func TestDynamicAttributeIsRequiredForImport(t *testing.T) {
433+
t.Parallel()
434+
435+
testCases := map[string]struct {
436+
attribute schema.DynamicAttribute
437+
expected bool
438+
}{
439+
"not-requiredForImport": {
440+
attribute: schema.DynamicAttribute{},
441+
expected: false,
442+
},
443+
}
444+
445+
for name, testCase := range testCases {
446+
t.Run(name, func(t *testing.T) {
447+
t.Parallel()
448+
449+
got := testCase.attribute.IsRequiredForImport()
450+
451+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
452+
t.Errorf("unexpected difference: %s", diff)
453+
}
454+
})
455+
}
456+
}
457+
458+
func TestDynamicAttributeIsOptionalForImport(t *testing.T) {
459+
t.Parallel()
460+
461+
testCases := map[string]struct {
462+
attribute schema.DynamicAttribute
463+
expected bool
464+
}{
465+
"not-optionalForImport": {
466+
attribute: schema.DynamicAttribute{},
467+
expected: false,
468+
},
469+
}
470+
471+
for name, testCase := range testCases {
472+
t.Run(name, func(t *testing.T) {
473+
t.Parallel()
474+
475+
got := testCase.attribute.IsOptionalForImport()
476+
477+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
478+
t.Errorf("unexpected difference: %s", diff)
479+
}
480+
})
481+
}
482+
}

datasource/schema/float32_attribute.go

+12
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,15 @@ func (a Float32Attribute) IsSensitive() bool {
194194
func (a Float32Attribute) IsWriteOnly() bool {
195195
return false
196196
}
197+
198+
// IsRequiredForImport returns false as this behavior is only relevant
199+
// for managed resource identity schema attributes.
200+
func (a Float32Attribute) IsRequiredForImport() bool {
201+
return false
202+
}
203+
204+
// IsOptionalForImport returns false as this behavior is only relevant
205+
// for managed resource identity schema attributes.
206+
func (a Float32Attribute) IsOptionalForImport() bool {
207+
return false
208+
}

datasource/schema/float32_attribute_test.go

+52
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,55 @@ func TestFloat32AttributeIsWriteOnly(t *testing.T) {
428428
})
429429
}
430430
}
431+
432+
func TestFloat32AttributeIsRequiredForImport(t *testing.T) {
433+
t.Parallel()
434+
435+
testCases := map[string]struct {
436+
attribute schema.Float32Attribute
437+
expected bool
438+
}{
439+
"not-requiredForImport": {
440+
attribute: schema.Float32Attribute{},
441+
expected: false,
442+
},
443+
}
444+
445+
for name, testCase := range testCases {
446+
t.Run(name, func(t *testing.T) {
447+
t.Parallel()
448+
449+
got := testCase.attribute.IsRequiredForImport()
450+
451+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
452+
t.Errorf("unexpected difference: %s", diff)
453+
}
454+
})
455+
}
456+
}
457+
458+
func TestFloat32AttributeIsOptionalForImport(t *testing.T) {
459+
t.Parallel()
460+
461+
testCases := map[string]struct {
462+
attribute schema.Float32Attribute
463+
expected bool
464+
}{
465+
"not-optionalForImport": {
466+
attribute: schema.Float32Attribute{},
467+
expected: false,
468+
},
469+
}
470+
471+
for name, testCase := range testCases {
472+
t.Run(name, func(t *testing.T) {
473+
t.Parallel()
474+
475+
got := testCase.attribute.IsOptionalForImport()
476+
477+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
478+
t.Errorf("unexpected difference: %s", diff)
479+
}
480+
})
481+
}
482+
}

datasource/schema/float64_attribute.go

+12
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,15 @@ func (a Float64Attribute) IsSensitive() bool {
194194
func (a Float64Attribute) IsWriteOnly() bool {
195195
return false
196196
}
197+
198+
// IsRequiredForImport returns false as this behavior is only relevant
199+
// for managed resource identity schema attributes.
200+
func (a Float64Attribute) IsRequiredForImport() bool {
201+
return false
202+
}
203+
204+
// IsOptionalForImport returns false as this behavior is only relevant
205+
// for managed resource identity schema attributes.
206+
func (a Float64Attribute) IsOptionalForImport() bool {
207+
return false
208+
}

datasource/schema/float64_attribute_test.go

+52
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,55 @@ func TestFloat64AttributeIsWriteOnly(t *testing.T) {
428428
})
429429
}
430430
}
431+
432+
func TestFloat64AttributeIsRequiredForImport(t *testing.T) {
433+
t.Parallel()
434+
435+
testCases := map[string]struct {
436+
attribute schema.Float64Attribute
437+
expected bool
438+
}{
439+
"not-requiredForImport": {
440+
attribute: schema.Float64Attribute{},
441+
expected: false,
442+
},
443+
}
444+
445+
for name, testCase := range testCases {
446+
t.Run(name, func(t *testing.T) {
447+
t.Parallel()
448+
449+
got := testCase.attribute.IsRequiredForImport()
450+
451+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
452+
t.Errorf("unexpected difference: %s", diff)
453+
}
454+
})
455+
}
456+
}
457+
458+
func TestFloat64AttributeIsOptionalForImport(t *testing.T) {
459+
t.Parallel()
460+
461+
testCases := map[string]struct {
462+
attribute schema.Float64Attribute
463+
expected bool
464+
}{
465+
"not-optionalForImport": {
466+
attribute: schema.Float64Attribute{},
467+
expected: false,
468+
},
469+
}
470+
471+
for name, testCase := range testCases {
472+
t.Run(name, func(t *testing.T) {
473+
t.Parallel()
474+
475+
got := testCase.attribute.IsOptionalForImport()
476+
477+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
478+
t.Errorf("unexpected difference: %s", diff)
479+
}
480+
})
481+
}
482+
}

datasource/schema/int32_attribute.go

+12
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,15 @@ func (a Int32Attribute) IsSensitive() bool {
194194
func (a Int32Attribute) IsWriteOnly() bool {
195195
return false
196196
}
197+
198+
// IsRequiredForImport returns false as this behavior is only relevant
199+
// for managed resource identity schema attributes.
200+
func (a Int32Attribute) IsRequiredForImport() bool {
201+
return false
202+
}
203+
204+
// IsOptionalForImport returns false as this behavior is only relevant
205+
// for managed resource identity schema attributes.
206+
func (a Int32Attribute) IsOptionalForImport() bool {
207+
return false
208+
}

datasource/schema/int32_attribute_test.go

+52
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,55 @@ func TestInt32AttributeIsWriteOnly(t *testing.T) {
428428
})
429429
}
430430
}
431+
432+
func TestInt32AttributeIsRequiredForImport(t *testing.T) {
433+
t.Parallel()
434+
435+
testCases := map[string]struct {
436+
attribute schema.Int32Attribute
437+
expected bool
438+
}{
439+
"not-requiredForImport": {
440+
attribute: schema.Int32Attribute{},
441+
expected: false,
442+
},
443+
}
444+
445+
for name, testCase := range testCases {
446+
t.Run(name, func(t *testing.T) {
447+
t.Parallel()
448+
449+
got := testCase.attribute.IsRequiredForImport()
450+
451+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
452+
t.Errorf("unexpected difference: %s", diff)
453+
}
454+
})
455+
}
456+
}
457+
458+
func TestInt32AttributeIsOptionalForImport(t *testing.T) {
459+
t.Parallel()
460+
461+
testCases := map[string]struct {
462+
attribute schema.Int32Attribute
463+
expected bool
464+
}{
465+
"not-optionalForImport": {
466+
attribute: schema.Int32Attribute{},
467+
expected: false,
468+
},
469+
}
470+
471+
for name, testCase := range testCases {
472+
t.Run(name, func(t *testing.T) {
473+
t.Parallel()
474+
475+
got := testCase.attribute.IsOptionalForImport()
476+
477+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
478+
t.Errorf("unexpected difference: %s", diff)
479+
}
480+
})
481+
}
482+
}

datasource/schema/int64_attribute.go

+12
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,15 @@ func (a Int64Attribute) IsSensitive() bool {
194194
func (a Int64Attribute) IsWriteOnly() bool {
195195
return false
196196
}
197+
198+
// IsRequiredForImport returns false as this behavior is only relevant
199+
// for managed resource identity schema attributes.
200+
func (a Int64Attribute) IsRequiredForImport() bool {
201+
return false
202+
}
203+
204+
// IsOptionalForImport returns false as this behavior is only relevant
205+
// for managed resource identity schema attributes.
206+
func (a Int64Attribute) IsOptionalForImport() bool {
207+
return false
208+
}

0 commit comments

Comments
 (0)