From 20b9ba9a20a1d0b3a6d6c1814c6aa939b56e03f5 Mon Sep 17 00:00:00 2001 From: Anurag Rajawat Date: Wed, 14 Feb 2024 13:07:30 +0530 Subject: [PATCH] fix(core): Add status fields in CRDs Signed-off-by: Anurag Rajawat --- api/v1/clusternimbuspolicy_types.go | 7 ++++- api/v1/clustersecurityintentbinding_types.go | 9 ++++++- api/v1/nimbuspolicy_types.go | 8 ++++-- api/v1/securityintent_types.go | 6 ++++- api/v1/securityintentbinding_types.go | 10 +++++-- api/v1/zz_generated.deepcopy.go | 26 +++++++++++++++++-- ...rity.nimbus.com_clusternimbuspolicies.yaml | 16 ++++++++++++ ...bus.com_clustersecurityintentbindings.yaml | 22 ++++++++++++++++ ...nt.security.nimbus.com_nimbuspolicies.yaml | 13 ++++++++++ ...ity.nimbus.com_securityintentbindings.yaml | 19 ++++++++++++++ ...t.security.nimbus.com_securityintents.yaml | 17 ++++++++++++ 11 files changed, 144 insertions(+), 9 deletions(-) diff --git a/api/v1/clusternimbuspolicy_types.go b/api/v1/clusternimbuspolicy_types.go index e8861575..9ee4204d 100644 --- a/api/v1/clusternimbuspolicy_types.go +++ b/api/v1/clusternimbuspolicy_types.go @@ -15,13 +15,18 @@ type ClusterNimbusPolicySpec struct { // ClusterNimbusPolicyStatus defines the observed state of ClusterNimbusPolicy type ClusterNimbusPolicyStatus struct { - Status string `json:"status"` + Status string `json:"status"` + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + NumberOfAdapterPolicies uint `json:"numberOfAdapterPolicies"` + Policies []string `json:"adapterPolicies,omitempty"` } //+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:resource:scope=Cluster,shortName="cwnp" //+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status" +//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +//+kubebuilder:printcolumn:name="Policies",type="integer",JSONPath=".status.numberOfAdapterPolicies" // ClusterNimbusPolicy is the Schema for the clusternimbuspolicies API type ClusterNimbusPolicy struct { diff --git a/api/v1/clustersecurityintentbinding_types.go b/api/v1/clustersecurityintentbinding_types.go index 4ca68b49..6aac2000 100644 --- a/api/v1/clustersecurityintentbinding_types.go +++ b/api/v1/clustersecurityintentbinding_types.go @@ -27,12 +27,19 @@ type ClusterSecurityIntentBindingSpec struct { // ClusterSecurityIntentBindingStatus defines the observed state of ClusterSecurityIntentBinding type ClusterSecurityIntentBindingStatus struct { - Status string `json:"status"` + Status string `json:"status"` + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + NumberOfBoundIntents uint `json:"numberOfBoundIntents"` + BoundIntents []string `json:"boundIntents,omitempty"` + ClusterNimbusPolicy string `json:"clusterNimbusPolicy"` } //+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status" +//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +//+kubebuilder:printcolumn:name="Intents",type="integer",JSONPath=".status.numberOfBoundIntents" +//+kubebuilder:printcolumn:name="ClusterNimbusPolicy",type="string",JSONPath=".status.clusterNimbusPolicy" //+kubebuilder:resource:scope=Cluster,shortName="csib" //+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/api/v1/nimbuspolicy_types.go b/api/v1/nimbuspolicy_types.go index a4cd0dd1..5b0516fe 100644 --- a/api/v1/nimbuspolicy_types.go +++ b/api/v1/nimbuspolicy_types.go @@ -37,13 +37,17 @@ type Rule struct { // NimbusPolicyStatus defines the observed state of NimbusPolicy type NimbusPolicyStatus struct { - Status string `json:"status"` - LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + Status string `json:"status"` + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + NumberOfAdapterPolicies uint `json:"numberOfAdapterPolicies"` + Policies []string `json:"adapterPolicies,omitempty"` } //+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status" +//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +//+kubebuilder:printcolumn:name="Policies",type="integer",JSONPath=".status.numberOfAdapterPolicies" //+kubebuilder:resource: shortName="np" // NimbusPolicy is the Schema for the nimbuspolicies API diff --git a/api/v1/securityintent_types.go b/api/v1/securityintent_types.go index 19d561e8..d1b3208a 100644 --- a/api/v1/securityintent_types.go +++ b/api/v1/securityintent_types.go @@ -40,14 +40,18 @@ type Intent struct { // SecurityIntentStatus defines the observed state of SecurityIntent type SecurityIntentStatus struct { + ID string `json:"id"` + Action string `json:"action"` Status string `json:"status"` } -// SecurityIntent is the Schema for the securityintents API // +kubebuilder:object:root=true // +kubebuilder:resource:shortName="si",scope="Cluster" // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:printcolumn:name="ID",type="string",JSONPath=".spec.intent.id",priority=1 +// +kubebuilder:printcolumn:name="Action",type="string",JSONPath=".spec.intent.action",priority=1 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // SecurityIntent is the Schema for the securityintents API diff --git a/api/v1/securityintentbinding_types.go b/api/v1/securityintentbinding_types.go index 41006c3c..6fea2895 100644 --- a/api/v1/securityintentbinding_types.go +++ b/api/v1/securityintentbinding_types.go @@ -39,14 +39,20 @@ type Resources struct { // SecurityIntentBindingStatus defines the observed state of SecurityIntentBinding type SecurityIntentBindingStatus struct { - Status string `json:"status"` - LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + Status string `json:"status"` + LastUpdated metav1.Time `json:"lastUpdated,omitempty"` + NumberOfBoundIntents uint `json:"numberOfBoundIntents"` + BoundIntents []string `json:"boundIntents,omitempty"` + NimbusPolicy string `json:"nimbusPolicy"` } // +kubebuilder:object:root=true // +kubebuilder:resource: shortName="sib" // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.status" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:printcolumn:name="Intents",type="integer",JSONPath=".status.numberOfBoundIntents" +// +kubebuilder:printcolumn:name="NimbusPolicy",type="string",JSONPath=".status.nimbusPolicy" // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // SecurityIntentBinding is the Schema for the securityintentbindings API diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 69b39925..59b56c06 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -17,7 +17,7 @@ func (in *ClusterNimbusPolicy) DeepCopyInto(out *ClusterNimbusPolicy) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterNimbusPolicy. @@ -96,6 +96,12 @@ func (in *ClusterNimbusPolicySpec) DeepCopy() *ClusterNimbusPolicySpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterNimbusPolicyStatus) DeepCopyInto(out *ClusterNimbusPolicyStatus) { *out = *in + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.Policies != nil { + in, out := &in.Policies, &out.Policies + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterNimbusPolicyStatus. @@ -114,7 +120,7 @@ func (in *ClusterSecurityIntentBinding) DeepCopyInto(out *ClusterSecurityIntentB out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSecurityIntentBinding. @@ -191,6 +197,12 @@ func (in *ClusterSecurityIntentBindingSpec) DeepCopy() *ClusterSecurityIntentBin // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterSecurityIntentBindingStatus) DeepCopyInto(out *ClusterSecurityIntentBindingStatus) { *out = *in + in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.BoundIntents != nil { + in, out := &in.BoundIntents, &out.BoundIntents + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSecurityIntentBindingStatus. @@ -389,6 +401,11 @@ func (in *NimbusPolicySpec) DeepCopy() *NimbusPolicySpec { func (in *NimbusPolicyStatus) DeepCopyInto(out *NimbusPolicyStatus) { *out = *in in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.Policies != nil { + in, out := &in.Policies, &out.Policies + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NimbusPolicyStatus. @@ -619,6 +636,11 @@ func (in *SecurityIntentBindingSpec) DeepCopy() *SecurityIntentBindingSpec { func (in *SecurityIntentBindingStatus) DeepCopyInto(out *SecurityIntentBindingStatus) { *out = *in in.LastUpdated.DeepCopyInto(&out.LastUpdated) + if in.BoundIntents != nil { + in, out := &in.BoundIntents, &out.BoundIntents + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityIntentBindingStatus. diff --git a/config/crd/bases/intent.security.nimbus.com_clusternimbuspolicies.yaml b/config/crd/bases/intent.security.nimbus.com_clusternimbuspolicies.yaml index 69d6271a..1c86468f 100644 --- a/config/crd/bases/intent.security.nimbus.com_clusternimbuspolicies.yaml +++ b/config/crd/bases/intent.security.nimbus.com_clusternimbuspolicies.yaml @@ -20,6 +20,12 @@ spec: - jsonPath: .status.status name: Status type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.numberOfAdapterPolicies + name: Policies + type: integer name: v1 schema: openAPIV3Schema: @@ -102,9 +108,19 @@ spec: status: description: ClusterNimbusPolicyStatus defines the observed state of ClusterNimbusPolicy properties: + adapterPolicies: + items: + type: string + type: array + lastUpdated: + format: date-time + type: string + numberOfAdapterPolicies: + type: integer status: type: string required: + - numberOfAdapterPolicies - status type: object type: object diff --git a/config/crd/bases/intent.security.nimbus.com_clustersecurityintentbindings.yaml b/config/crd/bases/intent.security.nimbus.com_clustersecurityintentbindings.yaml index 6261f5b4..14b281ef 100644 --- a/config/crd/bases/intent.security.nimbus.com_clustersecurityintentbindings.yaml +++ b/config/crd/bases/intent.security.nimbus.com_clustersecurityintentbindings.yaml @@ -20,6 +20,15 @@ spec: - jsonPath: .status.status name: Status type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.numberOfBoundIntents + name: Intents + type: integer + - jsonPath: .status.clusterNimbusPolicy + name: ClusterNimbusPolicy + type: string name: v1 schema: openAPIV3Schema: @@ -86,9 +95,22 @@ spec: description: ClusterSecurityIntentBindingStatus defines the observed state of ClusterSecurityIntentBinding properties: + boundIntents: + items: + type: string + type: array + clusterNimbusPolicy: + type: string + lastUpdated: + format: date-time + type: string + numberOfBoundIntents: + type: integer status: type: string required: + - clusterNimbusPolicy + - numberOfBoundIntents - status type: object type: object diff --git a/config/crd/bases/intent.security.nimbus.com_nimbuspolicies.yaml b/config/crd/bases/intent.security.nimbus.com_nimbuspolicies.yaml index 918ff7d1..9a66afd6 100644 --- a/config/crd/bases/intent.security.nimbus.com_nimbuspolicies.yaml +++ b/config/crd/bases/intent.security.nimbus.com_nimbuspolicies.yaml @@ -20,6 +20,12 @@ spec: - jsonPath: .status.status name: Status type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.numberOfAdapterPolicies + name: Policies + type: integer name: v1 schema: openAPIV3Schema: @@ -91,12 +97,19 @@ spec: status: description: NimbusPolicyStatus defines the observed state of NimbusPolicy properties: + adapterPolicies: + items: + type: string + type: array lastUpdated: format: date-time type: string + numberOfAdapterPolicies: + type: integer status: type: string required: + - numberOfAdapterPolicies - status type: object type: object diff --git a/config/crd/bases/intent.security.nimbus.com_securityintentbindings.yaml b/config/crd/bases/intent.security.nimbus.com_securityintentbindings.yaml index d5e6d568..7326ed41 100644 --- a/config/crd/bases/intent.security.nimbus.com_securityintentbindings.yaml +++ b/config/crd/bases/intent.security.nimbus.com_securityintentbindings.yaml @@ -20,6 +20,15 @@ spec: - jsonPath: .status.status name: Status type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.numberOfBoundIntents + name: Intents + type: integer + - jsonPath: .status.nimbusPolicy + name: NimbusPolicy + type: string name: v1 schema: openAPIV3Schema: @@ -106,12 +115,22 @@ spec: description: SecurityIntentBindingStatus defines the observed state of SecurityIntentBinding properties: + boundIntents: + items: + type: string + type: array lastUpdated: format: date-time type: string + nimbusPolicy: + type: string + numberOfBoundIntents: + type: integer status: type: string required: + - nimbusPolicy + - numberOfBoundIntents - status type: object type: object diff --git a/config/crd/bases/intent.security.nimbus.com_securityintents.yaml b/config/crd/bases/intent.security.nimbus.com_securityintents.yaml index c15bba85..5af260ea 100644 --- a/config/crd/bases/intent.security.nimbus.com_securityintents.yaml +++ b/config/crd/bases/intent.security.nimbus.com_securityintents.yaml @@ -20,6 +20,17 @@ spec: - jsonPath: .status.status name: Status type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .spec.intent.id + name: ID + priority: 1 + type: string + - jsonPath: .spec.intent.action + name: Action + priority: 1 + type: string name: v1 schema: openAPIV3Schema: @@ -85,9 +96,15 @@ spec: status: description: SecurityIntentStatus defines the observed state of SecurityIntent properties: + action: + type: string + id: + type: string status: type: string required: + - action + - id - status type: object type: object