|
| 1 | +/* |
| 2 | +Copyright 2023 Pramodh Ayyappan. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + "github.com/Facets-cloud/postgresql-operator/apis/common" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | +) |
| 23 | + |
| 24 | +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
| 25 | +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. |
| 26 | + |
| 27 | +// GrantStatementSpec defines the desired state of GrantStatement |
| 28 | +type GrantStatementSpec struct { |
| 29 | + // +kubebuilder:validation:Required |
| 30 | + Database string `json:"database"` |
| 31 | + |
| 32 | + // +kubebuilder:validation:Required |
| 33 | + RoleRef common.ResourceReference `json:"roleRef"` |
| 34 | + |
| 35 | + // +kubebuilder:validation:Required |
| 36 | + // +kubebuilder:validation:MinItems=1 |
| 37 | + Statements []string `json:"statements"` |
| 38 | +} |
| 39 | + |
| 40 | +// GrantStatementStatus defines the observed state of GrantStatement |
| 41 | +type GrantStatementStatus struct { |
| 42 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 43 | + PreviousGrantStatementState PreviousGrantStatementState `json:"previousGrantStatementState,omitempty"` |
| 44 | +} |
| 45 | + |
| 46 | +type PreviousGrantStatementState struct { |
| 47 | + Database string `json:"database"` |
| 48 | + RoleRef common.ResourceReference `json:"roleRef"` |
| 49 | + Statements []string `json:"statements"` |
| 50 | +} |
| 51 | + |
| 52 | +//+kubebuilder:object:root=true |
| 53 | +//+kubebuilder:subresource:status |
| 54 | +//+kubebuilder:printcolumn:name="Database",type=string,JSONPath=`.spec.database` |
| 55 | +//+kubebuilder:printcolumn:name="Role",type=string,JSONPath=`.spec.roleRef.name` |
| 56 | +//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[-1:].status` |
| 57 | +//+kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[-1:].reason` |
| 58 | +//+kubebuilder:printcolumn:name="Last Transition Time",type=string,priority=1,JSONPath=`.status.conditions[-1:].lastTransitionTime` |
| 59 | +//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` |
| 60 | + |
| 61 | +// GrantStatement is the Schema for the grantstatements API |
| 62 | +type GrantStatement struct { |
| 63 | + metav1.TypeMeta `json:",inline"` |
| 64 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 65 | + |
| 66 | + Spec GrantStatementSpec `json:"spec,omitempty"` |
| 67 | + Status GrantStatementStatus `json:"status,omitempty"` |
| 68 | +} |
| 69 | + |
| 70 | +//+kubebuilder:object:root=true |
| 71 | + |
| 72 | +// GrantStatementList contains a list of GrantStatement |
| 73 | +type GrantStatementList struct { |
| 74 | + metav1.TypeMeta `json:",inline"` |
| 75 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 76 | + Items []GrantStatement `json:"items"` |
| 77 | +} |
| 78 | + |
| 79 | +func init() { |
| 80 | + SchemeBuilder.Register(&GrantStatement{}, &GrantStatementList{}) |
| 81 | +} |
0 commit comments