Skip to content

Commit

Permalink
force deletion option to orphan if update strategy is readonly.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Sep 12, 2024
1 parent 21e2399 commit 348f703
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/api/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,21 @@ func EncodeManifest(manifest, deleteOption, updateStrategy map[string]interface{
PropagationPolicy: workv1.DeletePropagationPolicyTypeForeground,
}

// set default delete option to Orphan if update strategy is ReadOnly
// set delete option to Orphan if update strategy is ReadOnly
if upStrategy.Type == workv1.UpdateStrategyTypeReadOnly {
delOption = &workv1.DeleteOption{
PropagationPolicy: workv1.DeletePropagationPolicyTypeOrphan,
}
}

if len(deleteOption) != 0 {
deleteOptionBytes, err := json.Marshal(deleteOption)
if err != nil {
return nil, fmt.Errorf("failed to marshal deleteOption to json: %v", err)
}
err = json.Unmarshal(deleteOptionBytes, delOption)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal json to deleteOption: %v", err)
} else {
if len(deleteOption) != 0 {
deleteOptionBytes, err := json.Marshal(deleteOption)
if err != nil {
return nil, fmt.Errorf("failed to marshal deleteOption to json: %v", err)
}
err = json.Unmarshal(deleteOptionBytes, delOption)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal json to deleteOption: %v", err)
}
}
}

Expand Down

0 comments on commit 348f703

Please sign in to comment.