From 307e67ddee0e8456667da4d2059c6aa63f473694 Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Sat, 13 Apr 2024 22:50:59 +0700 Subject: [PATCH] feat: update upstream_types and set additional spec as optional --- Makefile | 2 +- api/v1alpha1/upstream_types.go | 13 +++++++----- charts/frp-operator/crds/crds.yaml | 19 ++---------------- charts/releases/frp-operator-1.1.0.tgz | Bin 4524 -> 4486 bytes charts/releases/index.yaml | 8 ++++---- .../frp.zufardhiyaulhaq.com_clients.yaml | 8 +------- .../frp.zufardhiyaulhaq.com_upstreams.yaml | 11 +--------- pkg/client/models/config.go | 4 ++++ 8 files changed, 21 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index 528b635..b6c5096 100644 --- a/Makefile +++ b/Makefile @@ -165,7 +165,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions KUSTOMIZE_VERSION ?= v3.8.7 -CONTROLLER_TOOLS_VERSION ?= v0.8.0 +CONTROLLER_TOOLS_VERSION ?= v0.11.3 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize diff --git a/api/v1alpha1/upstream_types.go b/api/v1alpha1/upstream_types.go index d1ddfc4..8440d3b 100644 --- a/api/v1alpha1/upstream_types.go +++ b/api/v1alpha1/upstream_types.go @@ -22,9 +22,11 @@ import ( // UpstreamSpec defines the desired state of Upstream type UpstreamSpec struct { - Client string `json:"client"` - TCP *UpstreamSpec_TCP `json:"tcp"` - UDP *UpstreamSpec_UDP `json:"udp"` + Client string `json:"client"` + // +optional + TCP *UpstreamSpec_TCP `json:"tcp"` + // +optional + UDP *UpstreamSpec_UDP `json:"udp"` } type UpstreamSpec_TCP struct { @@ -33,8 +35,9 @@ type UpstreamSpec_TCP struct { Server UpstreamSpec_TCP_Server `json:"server"` // +kubebuilder:validation:Enum=v1;v2 // +optional - ProxyProtocol *string `json:"proxyProtocol"` - HealthCheck *UpstreamSpec_TCP_HealthCheck `json:"healthCheck"` + ProxyProtocol *string `json:"proxyProtocol"` + // +optional + HealthCheck *UpstreamSpec_TCP_HealthCheck `json:"healthCheck"` } type UpstreamSpec_TCP_Server struct { diff --git a/charts/frp-operator/crds/crds.yaml b/charts/frp-operator/crds/crds.yaml index 12242eb..78e6e37 100644 --- a/charts/frp-operator/crds/crds.yaml +++ b/charts/frp-operator/crds/crds.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: clients.frp.zufardhiyaulhaq.com spec: @@ -77,18 +77,12 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: upstreams.frp.zufardhiyaulhaq.com spec: @@ -154,7 +148,6 @@ spec: - port type: object required: - - healthCheck - host - port - server @@ -179,8 +172,6 @@ spec: type: object required: - client - - tcp - - udp type: object status: description: UpstreamStatus defines the observed state of Upstream @@ -190,9 +181,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/charts/releases/frp-operator-1.1.0.tgz b/charts/releases/frp-operator-1.1.0.tgz index d24e0f9bafdca8ffd4c41fe0628faaf47ad4c5ef..1be2b42392567699c23f1ba7cd467837ad55f6fa 100644 GIT binary patch delta 4465 zcmV-%5svPxBZec8K7ZS`vhUyg6dPwcJ?TB9NJ+L+&18CgoX5#D$?-UkxxJY)2}G_a z9D@K0fU=c3_p{#tKvJZhw&TccD*WM4;9_^N02V(yxEaaZ7dc9zh3p)UiPXWAWbC`! zOko&?2mQYNHw?r1f5ZK#|6SBS2oLtV{e#2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_sX4Yl9@jq;7f2w0fRG@r^RdcJ8JUCN;y9 zuAq@mlC^!kDp|vPa}^d?H{M*OZ)e`un&w7PA+-~G{D`m+Vc1nybm(7N1CD)})S5Yn2g3?0TkRFSieBAgj zxF$RNe(5cmVVu!SWBj@e;P&gIgQIZrtLGSF{JsQZCiBk-gR2JAj|K=BR~-vuZxXXtiV+^|DsT8|8! z`j?mL4cI_O*>!=mi}hr;Wj_~1+Zj0{tPBgZ1!=7VCoZMr{28Ha6Qa9HHJYX0RR6|D2Ac{f&c)(H18h( diff --git a/charts/releases/index.yaml b/charts/releases/index.yaml index 8d6e6ad..9da9f3b 100644 --- a/charts/releases/index.yaml +++ b/charts/releases/index.yaml @@ -3,10 +3,10 @@ entries: frp-operator: - apiVersion: v2 appVersion: 0.3.0 - created: "2024-04-04T22:25:33.990033+07:00" + created: "2024-04-13T22:50:20.361732+07:00" description: Expose your service in Kubernetes to the Internet with open source FRP! - digest: b3c9f018a4f8fbd3a94f2c19ed72e99276b5fd7e59468f8109ab479e7230aab7 + digest: 96f342725e362414480ad385e0ad6db348754e8e3bf5db0d9a7e74ee9c5905a7 home: https://github.com/zufardhiyaulhaq/frp-operator maintainers: - email: zufardhiyaulhaq@gmail.com @@ -19,7 +19,7 @@ entries: version: 1.1.0 - apiVersion: v2 appVersion: 0.2.0 - created: "2024-04-04T22:25:33.988819+07:00" + created: "2024-04-13T22:50:20.360889+07:00" description: Expose your service in Kubernetes to the Internet with open source FRP! digest: 5f80631b3ce1dad5ed2039abb144506fa5795d378f4d465d33c475f216b77df1 @@ -33,4 +33,4 @@ entries: urls: - frp-operator-1.0.0.tgz version: 1.0.0 -generated: "2024-04-04T22:25:33.985268+07:00" +generated: "2024-04-13T22:50:20.359307+07:00" diff --git a/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml b/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml index aba268b..28bb299 100644 --- a/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml +++ b/config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: clients.frp.zufardhiyaulhaq.com spec: @@ -77,9 +77,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml b/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml index 38b886c..8c78902 100644 --- a/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml +++ b/config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.8.0 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: upstreams.frp.zufardhiyaulhaq.com spec: @@ -69,7 +69,6 @@ spec: - port type: object required: - - healthCheck - host - port - server @@ -94,8 +93,6 @@ spec: type: object required: - client - - tcp - - udp type: object status: description: UpstreamStatus defines the observed state of Upstream @@ -105,9 +102,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/pkg/client/models/config.go b/pkg/client/models/config.go index e134403..0ba2efa 100644 --- a/pkg/client/models/config.go +++ b/pkg/client/models/config.go @@ -113,6 +113,10 @@ func NewConfig(k8sclient client.Client, clientObject *frpv1alpha1.Client, upstre Name: upstreamObject.Name, } + if upstreamObject.Spec.TCP == nil && upstreamObject.Spec.UDP == nil { + return config, errors.NewBadRequest("TCP or UDP upstream is required") + } + if upstreamObject.Spec.TCP != nil && upstreamObject.Spec.UDP != nil { return config, errors.NewBadRequest("Multiple protocol on the same Upstream object") }