Skip to content

Commit

Permalink
Default requireApproverJustification to false before diffing
Browse files Browse the repository at this point in the history
  • Loading branch information
maqiuyujoyce committed Dec 19, 2024
1 parent 80e33b5 commit ace49eb
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ func (a *Adapter) Update(ctx context.Context, updateOp *directbase.UpdateOperati
log.V(2).Info("'spec.additionalNotificationTargets' field is updated (-old +new)", cmp.Diff(parsedActual.AdditionalNotificationTargets, parsedDesired.Spec.AdditionalNotificationTargets))
updateMask.Paths = append(updateMask.Paths, "additional_notification_targets")
}
defaultApprovalWorkflowManualApprovalsRequireApproverJustification(parsedActual)
defaultApprovalWorkflowManualApprovalsRequireApproverJustification(&parsedDesired.Spec)
if !reflect.DeepEqual(parsedActual.ApprovalWorkflow, parsedDesired.Spec.ApprovalWorkflow) {
log.V(2).Info("'spec.approvalWorkflow' field is updated (-old +new)", cmp.Diff(parsedActual.ApprovalWorkflow, parsedDesired.Spec.ApprovalWorkflow))
updateMask.Paths = append(updateMask.Paths, "approval_workflow")
Expand Down Expand Up @@ -387,6 +389,26 @@ func (a *Adapter) Update(ctx context.Context, updateOp *directbase.UpdateOperati
return setStatus(u, status)
}

func defaultApprovalWorkflowManualApprovalsRequireApproverJustification(spec *krm.PrivilegedAccessManagerEntitlementSpec) {
if spec.ApprovalWorkflow == nil {
spec.ApprovalWorkflow = &krm.ApprovalWorkflow{
ManualApprovals: &krm.ManualApprovals{
RequireApproverJustification: direct.PtrTo(false),
},
}
return
}
if spec.ApprovalWorkflow.ManualApprovals == nil {
spec.ApprovalWorkflow.ManualApprovals = &krm.ManualApprovals{
RequireApproverJustification: direct.PtrTo(false),
}
return
}
if spec.ApprovalWorkflow.ManualApprovals.RequireApproverJustification == nil {
spec.ApprovalWorkflow.ManualApprovals.RequireApproverJustification = direct.PtrTo(false)
}
}

func (a *Adapter) Export(ctx context.Context) (*unstructured.Unstructured, error) {
if a.actual == nil {
return nil, fmt.Errorf("Find() not called")
Expand Down

0 comments on commit ace49eb

Please sign in to comment.