Skip to content

Commit a235cc4

Browse files
authored
Merge pull request #4 from Facets-cloud/pg-grant-stmt
add grantstatement crd
2 parents efefe2f + e81ef67 commit a235cc4

26 files changed

+1521
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
2+
FROM golang:1.19 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -16,6 +16,7 @@ COPY main.go main.go
1616
COPY apis/ apis/
1717
COPY controllers/ controllers/
1818
COPY utility/ utility/
19+
COPY validations/ validations
1920

2021
# Build
2122
# the GOARCH has not a default value to allow the binary be built according to the host where the command

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,13 @@ resources:
3030
kind: Grant
3131
path: github.com/Facets-cloud/postgresql-operator/apis/postgresql/v1alpha1
3232
version: v1alpha1
33+
- api:
34+
crdVersion: v1
35+
namespaced: true
36+
controller: true
37+
domain: facets.cloud
38+
group: postgresql
39+
kind: GrantStatement
40+
path: github.com/Facets-cloud/postgresql-operator/apis/postgresql/v1alpha1
41+
version: v1alpha1
3342
version: "3"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
}

apis/postgresql/v1alpha1/zz_generated.deepcopy.go

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)