Is it possible using PlanModifiers: []planmodifier.Set{}
add a new item into the Set, if this item is not currently provided in the configuration?
I’d like to have something like this:
"groups": schema.SetAttribute{
ElementType: types.StringType,
MarkdownDescription: "List of groups this user is a part of.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Set{
myModifier.AddReaders(ctx, req, resp),
),
},
Validators: []validator.Set{setvalidator.SizeAtLeast(1)},
},
The scenario is if groups = [ "test0", "test1" ]
in the configuration, then the Provider should add a group “readers”, so the end result in the state will be [ "readers", "test0", "test1" ]
.
If I add this item in the Create
function, it will break the import.
I’ve tried to write a custom plan modifier but not sure if I’m on the right way. Can someone share some ideas please?