-
Notifications
You must be signed in to change notification settings - Fork 865
feat: implement expansion template pod status #2598
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
Merged
davis-haba
merged 22 commits into
open-policy-agent:master
from
davis-haba:expansion-status
Apr 5, 2023
Merged
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5920c95
implement expansion template pod status
davis-haba 3587840
appease linter, fix tests
davis-haba 6bf3fab
gofumpt et status controller
davis-haba 14ce870
controller tests
davis-haba d1a8fae
address comments
davis-haba 70d76d3
remove dead code
davis-haba 97c3727
fix expansion tests
davis-haba 1dc7a4c
readiness test for expansion
davis-haba 85b5e6c
cleanup tests
davis-haba 51a3cec
fix linter
davis-haba b2196b7
fix helm kustomization for expansion status
davis-haba e3dfede
add byPod json annotation to ExpansionTEmplateStatus.ByPod
davis-haba 4f44f81
revert auto indent
davis-haba 50d6127
fix kustomize
davis-haba cf895f2
Merge branch 'master' into expansion-status
ritazh f5a7567
Update apis/status/v1beta1/expansiontemplatepodstatus_types.go
davis-haba 95754ee
Update apis/expansion/unversioned/expansiontemplate_types.go
davis-haba 80b2608
Update apis/status/v1beta1/expansiontemplatepodstatus_types.go
davis-haba 82e00fd
Merge branch 'master' into expansion-status
ritazh 4edaeb5
Update apis/expansion/v1alpha1/expansiontemplate_types.go
davis-haba 35fe404
make manifests
davis-haba c03e842
Merge branch 'master' into expansion-status
davis-haba 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,83 @@ | ||
| package v1beta1 | ||
|
|
||
| import ( | ||
| "github.com/open-policy-agent/gatekeeper/pkg/operations" | ||
| "github.com/open-policy-agent/gatekeeper/pkg/util" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
| ) | ||
|
|
||
| // ExpansionTemplatePodStatusStatus defines the observed state of ExpansionTemplatePodStatus. | ||
| type ExpansionTemplatePodStatusStatus struct { | ||
| // Important: Run "make" to regenerate code after modifying this file | ||
| ID string `json:"id,omitempty"` | ||
| TemplateUID types.UID `json:"templateUID,omitempty"` | ||
| Operations []string `json:"operations,omitempty"` | ||
| ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
| Errors []*ExpansionTemplateError `json:"errors,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:generate=true | ||
|
|
||
| type ExpansionTemplateError struct { | ||
| Type string `json:"type,omitempty"` | ||
| Message string `json:"message"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:resource:scope=Namespaced | ||
|
|
||
| // ExpansionTemplatePodStatus is the Schema for the expansiontemplatepodstatuses API. | ||
| type ExpansionTemplatePodStatus struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Status ExpansionTemplatePodStatusStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // ExpansionTemplatePodStatusList contains a list of ExpansionTemplatePodStatus. | ||
| type ExpansionTemplatePodStatusList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []ExpansionTemplatePodStatus `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&ExpansionTemplatePodStatus{}, &ExpansionTemplatePodStatusList{}) | ||
| } | ||
|
|
||
| // NewExpansionTemplateStatusForPod returns a constraint template status object | ||
|
ritazh marked this conversation as resolved.
Outdated
|
||
| // that has been initialized with the bare minimum of fields to make it functional | ||
| // with the constraint template status controller. | ||
|
davis-haba marked this conversation as resolved.
Outdated
|
||
| func NewExpansionTemplateStatusForPod(pod *corev1.Pod, templateName string, scheme *runtime.Scheme) (*ExpansionTemplatePodStatus, error) { | ||
| obj := &ExpansionTemplatePodStatus{} | ||
| name, err := KeyForExpansionTemplate(pod.Name, templateName) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| obj.SetName(name) | ||
| obj.SetNamespace(util.GetNamespace()) | ||
| obj.Status.ID = pod.Name | ||
| obj.Status.Operations = operations.AssignedStringList() | ||
| obj.SetLabels(map[string]string{ | ||
| ExpansionTemplateNameLabel: templateName, | ||
| PodLabel: pod.Name, | ||
| }) | ||
|
|
||
| if err := controllerutil.SetOwnerReference(pod, obj, scheme); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return obj, nil | ||
| } | ||
|
|
||
| // KeyForExpansionTemplate returns a unique status object name given the Pod ID and | ||
| // a template object. | ||
| func KeyForExpansionTemplate(id string, templateName string) (string, error) { | ||
| return DashPacker(id, templateName) | ||
| } | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.