Skip to content

Commit d5d9464

Browse files
committed
add gate service
1 parent eaf765c commit d5d9464

22 files changed

+1251
-164
lines changed

PROJECT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ resources:
77
group: ocgate
88
kind: GateToken
99
version: v1beta1
10+
- crdVersion: v1
11+
group: ocgate
12+
kind: GateServer
13+
version: v1beta1
1014
version: 3-alpha
1115
plugins:
1216
manifests.sdk.operatorframework.io/v2: {}

api/v1beta1/gateserver_types.go

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
Copyright 2021 Yaacov Zamir.
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 v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// GateServerSpec defines the desired state of GateServer
27+
type GateServerSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// api-url is the k8s API url.
32+
// Defalut value is "https://kubernetes.default.svc".
33+
// +kubebuilder:validation:Optional
34+
// +kubebuilder:validation:Type="string"
35+
// +kubebuilder:validation:Pattern="^(http|https)://.*"
36+
// +kubebuilder:validation:MaxLength=1024
37+
// +kubebuilder:default:="https://kubernetes.default.svc"
38+
APIURL string `json:"api-url,omitempty"`
39+
40+
// route for the gate proxy server.
41+
// +required
42+
// +kubebuilder:validation:Required
43+
// +kubebuilder:validation:Type="string"
44+
// +kubebuilder:validation:Pattern="^([a-z0-9-_])+[.]([a-z0-9-_])+[.]([a-z0-9-._])+$"
45+
// +kubebuilder:validation:MaxLength=226
46+
Route string `json:"route,omitempty"`
47+
48+
// admin-role is the verbs athorization role of the service (reader/admin)
49+
// if service is role is reader, clients getting tokens to use this service
50+
// will be able to excute get, watch and list verbs.
51+
// if service is role is admin, clients getting tokens to use this service
52+
// will be able to excute get, watch, list, patch, creat and delete verbs.
53+
// Defalut value is "reader".
54+
// +kubebuilder:validation:Optional
55+
// +kubebuilder:validation:Type="string"
56+
// +kubebuilder:validation:Pattern="^(reader|admin)$"
57+
// +kubebuilder:validation:MaxLength=1024
58+
// +kubebuilder:default:="reader"
59+
AdminRole string `json:"admin-role,omitempty"`
60+
61+
// admin-resources is a comma seperated list of resources athorization role of the service
62+
// if left empty service could access any resource.
63+
// Defalut value is "".
64+
// +kubebuilder:validation:Optional
65+
// +kubebuilder:validation:Type="string"
66+
// +kubebuilder:validation:MaxLength=1024
67+
// +kubebuilder:default:=""
68+
AdminResources string `json:"admin-resources,omitempty"`
69+
70+
// passthrough the tokens aquired from OAuth2 server directly to k8s API
71+
// +optional
72+
// +kubebuilder:validation:Optional
73+
// +kubebuilder:validation:Type="boolean"
74+
// +kubebuilder:default:=false
75+
PassThrough bool `json:"passthrough,omitempty"`
76+
}
77+
78+
// GateServerStatus defines the observed state of GateServer
79+
type GateServerStatus struct {
80+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
81+
// Important: Run "make" to regenerate code after modifying this file
82+
83+
// Conditions represent the latest available observations of an object's state
84+
Conditions []metav1.Condition `json:"conditions"`
85+
86+
// Token generation phase (ready|error)
87+
Phase string `json:"phase"`
88+
}
89+
90+
// +kubebuilder:object:root=true
91+
// +kubebuilder:subresource:status
92+
93+
// GateServer is the Schema for the gateservers API
94+
type GateServer struct {
95+
metav1.TypeMeta `json:",inline"`
96+
metav1.ObjectMeta `json:"metadata,omitempty"`
97+
98+
Spec GateServerSpec `json:"spec,omitempty"`
99+
Status GateServerStatus `json:"status,omitempty"`
100+
}
101+
102+
// +kubebuilder:object:root=true
103+
104+
// GateServerList contains a list of GateServer
105+
type GateServerList struct {
106+
metav1.TypeMeta `json:",inline"`
107+
metav1.ListMeta `json:"metadata,omitempty"`
108+
Items []GateServer `json:"items"`
109+
}
110+
111+
func init() {
112+
SchemeBuilder.Register(&GateServer{}, &GateServerList{})
113+
}

api/v1beta1/gatetoken_types.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ type GateTokenSpec struct {
4040
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
4141
// Important: Run "make" to regenerate code after modifying this file
4242

43-
// user-id is the user id of the user requesting this token.
44-
// +required
45-
// +kubebuilder:validation:Required
46-
// +kubebuilder:validation:Type="string"
47-
// +kubebuilder:validation:MaxLength=226
48-
UserID string `json:"user-id"`
49-
5043
// match-path is a regular expresion used to validate API request path,
5144
// API requests matching this pattern will be validated by the token.
5245
// This field may not be empty.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 96 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)