-
Notifications
You must be signed in to change notification settings - Fork 16
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
Reimplement role metadata with tf-framework #228
Reimplement role metadata with tf-framework #228
Conversation
b7a9677
to
1566aea
Compare
1566aea
to
8aff3d7
Compare
dad098d
to
a7ca184
Compare
a7ca184
to
576d3ad
Compare
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Computed: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.UseStateForUnknown(), // immutable | ||
}, | ||
}, | ||
"service": schema.StringAttribute{ | ||
Description: "The name of the service.", | ||
Required: true, | ||
Validators: []validator.String{ | ||
mackerel.ServiceNameValidator(), | ||
}, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), // force new | ||
}, | ||
}, | ||
"role": schema.StringAttribute{ | ||
Description: "The name of the role.", | ||
Required: true, | ||
Validators: []validator.String{ | ||
mackerel.RoleNameValidator(), | ||
}, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), // force new | ||
}, | ||
}, | ||
"namespace": schema.StringAttribute{ | ||
Description: "The identifier for the metadata.", | ||
Required: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), // force new | ||
}, | ||
}, | ||
"metadata_json": schema.StringAttribute{ | ||
Description: "The arbitrary JSON data for the role.", | ||
Required: true, | ||
CustomType: jsontypes.NormalizedType{}, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original schema:
Schema: map[string]*schema.Schema{ | |
"service": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"role": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"namespace": { | |
Type: schema.TypeString, | |
Required: true, | |
ForceNew: true, | |
}, | |
"metadata_json": { | |
Type: schema.TypeString, | |
Required: true, | |
ValidateFunc: validation.StringIsJSON, | |
}, | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo] The service
and role
on the original schema does not have ForceNew: true
(equivalence of planmodifier.RequiresReplace()
). It seems like a bug (FYI: #231).
resp.Schema = schema.Schema{ | ||
Description: "This data source accesses to details of a specific Role Metadata.", | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Computed: true, | ||
}, | ||
"service": schema.StringAttribute{ | ||
Description: "The name of the service.", | ||
Required: true, | ||
Validators: []validator.String{mackerel.ServiceNameValidator()}, | ||
}, | ||
"role": schema.StringAttribute{ | ||
Description: "The name of the role.", | ||
Required: true, | ||
Validators: []validator.String{mackerel.RoleNameValidator()}, | ||
}, | ||
"namespace": schema.StringAttribute{ | ||
Description: "The identifier for the metadata.", | ||
Required: true, | ||
}, | ||
"metadata_json": schema.StringAttribute{ | ||
Description: "The arbitrary JSON data for the role.", | ||
Computed: true, | ||
CustomType: jsontypes.NormalizedType{}, | ||
}, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original schema:
terraform-provider-mackerel/mackerel/data_source_mackerel_role_metadata.go
Lines 16 to 33 in 9a863e6
Schema: map[string]*schema.Schema{ | |
"service": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"role": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"namespace": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"metadata_json": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems good 👍
Output from acceptance testing: