Skip to content

Commit

Permalink
feat: update upstream_types and set additional spec as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
zufardhiyaulhaq committed Apr 13, 2024
1 parent 9b88625 commit 307e67d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions api/v1alpha1/upstream_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
19 changes: 2 additions & 17 deletions charts/frp-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -154,7 +148,6 @@ spec:
- port
type: object
required:
- healthCheck
- host
- port
- server
Expand All @@ -179,8 +172,6 @@ spec:
type: object
required:
- client
- tcp
- udp
type: object
status:
description: UpstreamStatus defines the observed state of Upstream
Expand All @@ -190,9 +181,3 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Binary file modified charts/releases/frp-operator-1.1.0.tgz
Binary file not shown.
8 changes: 4 additions & 4 deletions charts/releases/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
8 changes: 1 addition & 7 deletions config/crd/bases/frp.zufardhiyaulhaq.com_clients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -77,9 +77,3 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
11 changes: 1 addition & 10 deletions config/crd/bases/frp.zufardhiyaulhaq.com_upstreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -69,7 +69,6 @@ spec:
- port
type: object
required:
- healthCheck
- host
- port
- server
Expand All @@ -94,8 +93,6 @@ spec:
type: object
required:
- client
- tcp
- udp
type: object
status:
description: UpstreamStatus defines the observed state of Upstream
Expand All @@ -105,9 +102,3 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
4 changes: 4 additions & 0 deletions pkg/client/models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 307e67d

Please sign in to comment.