-
Notifications
You must be signed in to change notification settings - Fork 6
feat(approval-expiration): approvals can now expire and notifications are sent before they do #387
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
Open
julius-malcovsky
wants to merge
4
commits into
main
Choose a base branch
from
feat/approval-expiry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
866cdd6
feat(approval-expiration): approvals can now expire and notifications…
julius-malcovsky d979b38
fix(approval-expiry): add new CR to kustomization
julius-malcovsky 837d5fe
Merge branch 'main' into feat/approval-expiry
julius-malcovsky 6e96612
chore(approval-expiration): code improvements and refactoring
julius-malcovsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Copyright 2025 Deutsche Telekom IT GmbH | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package v1 | ||
|
|
||
| import ( | ||
| "github.com/telekom/controlplane/common/pkg/types" | ||
| "k8s.io/apimachinery/pkg/api/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // ApprovalExpirationSpec defines the desired state of ApprovalExpiration | ||
| type ApprovalExpirationSpec struct { | ||
| // Approval is a reference to the parent Approval resource | ||
| Approval types.ObjectRef `json:"approval"` | ||
|
|
||
| // Expiration is the absolute date when the approval expires | ||
| Expiration metav1.Time `json:"expiration"` | ||
|
|
||
| // WeeklyReminder is the date from which weekly reminders start | ||
| WeeklyReminder metav1.Time `json:"weeklyReminder"` | ||
|
|
||
| // DailyReminder is the date from which daily reminders start | ||
| DailyReminder metav1.Time `json:"dailyReminder"` | ||
| } | ||
|
|
||
| // ApprovalExpirationStatus defines the observed state of ApprovalExpiration | ||
| type ApprovalExpirationStatus struct { | ||
| // +listType=map | ||
| // +listMapKey=type | ||
| // +patchStrategy=merge | ||
| // +patchMergeKey=type | ||
| // +optional | ||
| Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` | ||
|
|
||
| // LastReminder is the timestamp when the last reminder was sent | ||
| // +optional | ||
| LastReminder *metav1.Time `json:"lastReminder,omitempty"` | ||
|
|
||
| // LastNotificationRef is a reference to the last sent reminder notification | ||
| // +optional | ||
| LastNotificationRef *types.ObjectRef `json:"lastNotificationRef,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // ApprovalExpiration is the Schema for the approvalexpirations API | ||
| // +kubebuilder:printcolumn:name="Approval",type="string",JSONPath=".spec.approval.name",description="The parent Approval" | ||
| // +kubebuilder:printcolumn:name="Expiration",type="date",JSONPath=".spec.expiration",description="When the approval expires" | ||
| type ApprovalExpiration struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec ApprovalExpirationSpec `json:"spec,omitempty"` | ||
| Status ApprovalExpirationStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // ApprovalExpirationList contains a list of ApprovalExpiration | ||
| type ApprovalExpirationList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []ApprovalExpiration `json:"items"` | ||
| } | ||
|
|
||
| // GetConditions returns the conditions of the ApprovalExpiration | ||
| func (ae *ApprovalExpiration) GetConditions() []metav1.Condition { | ||
| return ae.Status.Conditions | ||
| } | ||
|
|
||
| // SetCondition sets the condition of the ApprovalExpiration | ||
| func (ae *ApprovalExpiration) SetCondition(condition metav1.Condition) bool { | ||
| return meta.SetStatusCondition(&ae.Status.Conditions, condition) | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&ApprovalExpiration{}, &ApprovalExpirationList{}) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,11 +241,13 @@ func (b *approvalBuilder) Build(ctx context.Context) (finalResult ApprovalResult | |
| // Approval was found | ||
| if approvalExists { | ||
| log.V(2).Info("Approval exists") | ||
| isDenied := b.Approval.Spec.State == v1.ApprovalStateRejected || b.Approval.Spec.State == v1.ApprovalStateSuspended | ||
| isDenied := b.Approval.Spec.State == v1.ApprovalStateRejected || | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that you explained it in the Review but is it really the goal to enforce this? Currently its just purely informational |
||
| b.Approval.Spec.State == v1.ApprovalStateSuspended || | ||
| b.Approval.Spec.State == v1.ApprovalStateExpired | ||
|
|
||
| if isDenied { | ||
| log.V(1).Info("Approval is rejected or suspended and must not be provisioned") | ||
| b.Owner.SetCondition(newApprovalGrantedCondition(b.Approval.Spec.State, "Approval has been rejected or suspended")) | ||
| log.V(1).Info("Approval is rejected, suspended, or expired and must not be provisioned") | ||
| b.Owner.SetCondition(newApprovalGrantedCondition(b.Approval.Spec.State, "Approval has been rejected, suspended, or expired")) | ||
| return ApprovalResultDenied, nil | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we use the reminder logic in common for this? That was implemented for graceful-client-secret-rotation?