Skip to content

Commit

Permalink
add force_update field to schema
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jan 12, 2024
1 parent 2566978 commit 8008735
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion manifest/provider/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,15 @@ func (s *RawProviderServer) PlanResourceChange(ctx context.Context, req *tfproto
nowCfg, restPath, err := tftypes.WalkAttributePath(ppMan, ap)
hasChanged = err == nil && len(restPath.Steps()) == 0 && wasCfg.(tftypes.Value).IsKnown() && !wasCfg.(tftypes.Value).Equal(nowCfg.(tftypes.Value))
if hasChanged {
forceUpdate := false
h, ok := hints[morph.ValueToTypePath(ap).String()]
if ok && h == manifest.PreserveUnknownFieldsLabel {
if !proposedVal["force_update"].IsNull() && proposedVal["force_update"].IsKnown() {
err = proposedVal["force_update"].As(&forceUpdate)
if err != nil {
s.logger.Error("[force_update] error setting force_update value")
}
}
if ok && h == manifest.PreserveUnknownFieldsLabel && !forceUpdate {
apm := append(tftypes.NewAttributePath().WithAttributeName("manifest").Steps(), ap.Steps()...)
resp.RequiresReplace = append(resp.RequiresReplace, tftypes.NewAttributePathWithSteps(apm))
}
Expand Down
11 changes: 11 additions & 0 deletions manifest/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ func GetProviderResourceSchema() map[string]*tfprotov5.Schema {
Required: true,
Description: "A Kubernetes manifest describing the desired state of the resource in HCL format.",
},
{
Name: "force_update",
Type: tftypes.Bool,
Required: false,
Optional: true,
Computed: false,
Sensitive: false,
Description: "Force update will replace destroy + create with just a replacement.",
DescriptionKind: 0,
Deprecated: false,
},
{
Name: "object",
Type: tftypes.DynamicPseudoType,
Expand Down

0 comments on commit 8008735

Please sign in to comment.