feat: add DNS record resource and datasources (#25)
* add DNS record * revamp tests * lint * cleanup * feat dns test * chore: add DNS Record tests * linting * f
This commit is contained in:
committed by
GitHub
parent
325d7b7f20
commit
e7164c0460
35
internal/utils/attribute.go
Normal file
35
internal/utils/attribute.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
|
||||
)
|
||||
|
||||
// ID generates an attribute definition suitable for the always-present `id` attribute.
|
||||
func ID(desc ...string) schema.StringAttribute {
|
||||
a := schema.StringAttribute{
|
||||
Computed: true,
|
||||
Description: "The unique identifier of this resource.",
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.UseStateForUnknown(),
|
||||
},
|
||||
}
|
||||
|
||||
if len(desc) > 0 {
|
||||
a.Description = desc[0]
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// ShouldBeRemoved evaluates if an attribute should be removed from the plan during update.
|
||||
func ShouldBeRemoved(plan attr.Value, state attr.Value, isClone bool) bool {
|
||||
return !IsDefined(plan) && IsDefined(state) && !isClone
|
||||
}
|
||||
|
||||
// IsDefined returns true if attribute is known and not null.
|
||||
func IsDefined(v attr.Value) bool {
|
||||
return !v.IsNull() && !v.IsUnknown()
|
||||
}
|
||||
Reference in New Issue
Block a user