Skip to content

Commit

Permalink
fix(core): Add status fields in CRDs
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
anurag-rajawat committed Feb 14, 2024
1 parent 01e022c commit 20b9ba9
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 9 deletions.
7 changes: 6 additions & 1 deletion api/v1/clusternimbuspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion api/v1/clustersecurityintentbinding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions api/v1/nimbuspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion api/v1/securityintent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions api/v1/securityintentbinding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions config/crd/bases/intent.security.nimbus.com_nimbuspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions config/crd/bases/intent.security.nimbus.com_securityintents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 20b9ba9

Please sign in to comment.