Skip to content

Resource Identity: Initial implementation + Schemas #1107

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

Merged
merged 17 commits into from
Mar 18, 2025
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
12 changes: 12 additions & 0 deletions datasource/schema/bool_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,15 @@ func (a BoolAttribute) IsWriteOnly() bool {
func (a BoolAttribute) IsSensitive() bool {
return a.Sensitive
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a BoolAttribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a BoolAttribute) IsOptionalForImport() bool {
return false
}
52 changes: 52 additions & 0 deletions datasource/schema/bool_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,55 @@ func TestBoolAttributeIsWriteOnly(t *testing.T) {
})
}
}

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

testCases := map[string]struct {
attribute schema.BoolAttribute
expected bool
}{
"not-requiredForImport": {
attribute: schema.BoolAttribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsRequiredForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}

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

testCases := map[string]struct {
attribute schema.BoolAttribute
expected bool
}{
"not-optionalForImport": {
attribute: schema.BoolAttribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsOptionalForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}
12 changes: 12 additions & 0 deletions datasource/schema/dynamic_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ func (a DynamicAttribute) IsWriteOnly() bool {
return false
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a DynamicAttribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a DynamicAttribute) IsOptionalForImport() bool {
return false
}

// DynamicValidators returns the Validators field value.
func (a DynamicAttribute) DynamicValidators() []validator.Dynamic {
return a.Validators
Expand Down
52 changes: 52 additions & 0 deletions datasource/schema/dynamic_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,55 @@ func TestDynamicAttributeDynamicValidators(t *testing.T) {
})
}
}

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

testCases := map[string]struct {
attribute schema.DynamicAttribute
expected bool
}{
"not-requiredForImport": {
attribute: schema.DynamicAttribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsRequiredForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}

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

testCases := map[string]struct {
attribute schema.DynamicAttribute
expected bool
}{
"not-optionalForImport": {
attribute: schema.DynamicAttribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsOptionalForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}
12 changes: 12 additions & 0 deletions datasource/schema/float32_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,15 @@ func (a Float32Attribute) IsSensitive() bool {
func (a Float32Attribute) IsWriteOnly() bool {
return false
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Float32Attribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Float32Attribute) IsOptionalForImport() bool {
return false
}
52 changes: 52 additions & 0 deletions datasource/schema/float32_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,55 @@ func TestFloat32AttributeIsWriteOnly(t *testing.T) {
})
}
}

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

testCases := map[string]struct {
attribute schema.Float32Attribute
expected bool
}{
"not-requiredForImport": {
attribute: schema.Float32Attribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsRequiredForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}

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

testCases := map[string]struct {
attribute schema.Float32Attribute
expected bool
}{
"not-optionalForImport": {
attribute: schema.Float32Attribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsOptionalForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}
12 changes: 12 additions & 0 deletions datasource/schema/float64_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,15 @@ func (a Float64Attribute) IsSensitive() bool {
func (a Float64Attribute) IsWriteOnly() bool {
return false
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Float64Attribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Float64Attribute) IsOptionalForImport() bool {
return false
}
52 changes: 52 additions & 0 deletions datasource/schema/float64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,55 @@ func TestFloat64AttributeIsWriteOnly(t *testing.T) {
})
}
}

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

testCases := map[string]struct {
attribute schema.Float64Attribute
expected bool
}{
"not-requiredForImport": {
attribute: schema.Float64Attribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsRequiredForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}

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

testCases := map[string]struct {
attribute schema.Float64Attribute
expected bool
}{
"not-optionalForImport": {
attribute: schema.Float64Attribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsOptionalForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}
12 changes: 12 additions & 0 deletions datasource/schema/int32_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,15 @@ func (a Int32Attribute) IsSensitive() bool {
func (a Int32Attribute) IsWriteOnly() bool {
return false
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Int32Attribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Int32Attribute) IsOptionalForImport() bool {
return false
}
52 changes: 52 additions & 0 deletions datasource/schema/int32_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,55 @@ func TestInt32AttributeIsWriteOnly(t *testing.T) {
})
}
}

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

testCases := map[string]struct {
attribute schema.Int32Attribute
expected bool
}{
"not-requiredForImport": {
attribute: schema.Int32Attribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsRequiredForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}

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

testCases := map[string]struct {
attribute schema.Int32Attribute
expected bool
}{
"not-optionalForImport": {
attribute: schema.Int32Attribute{},
expected: false,
},
}

for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.attribute.IsOptionalForImport()

if diff := cmp.Diff(got, testCase.expected); diff != "" {
t.Errorf("unexpected difference: %s", diff)
}
})
}
}
12 changes: 12 additions & 0 deletions datasource/schema/int64_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,15 @@ func (a Int64Attribute) IsSensitive() bool {
func (a Int64Attribute) IsWriteOnly() bool {
return false
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Int64Attribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a Int64Attribute) IsOptionalForImport() bool {
return false
}
Loading
Loading