From 6e4a88f9e596b6318a6d02709ed400a34b8540d4 Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Sat, 4 Sep 2021 15:19:35 +0200 Subject: [PATCH 1/5] add TLS protocol, implement host_header, and implement bind_tls Signed-off-by: zufardhiyaulhaq --- .github/workflows/master.yml | 11 +- .github/workflows/pullrequest.yml | 9 +- README.md | 21 ++-- api/v1alpha1/ngrok_types.go | 45 +++++-- charts/ngrok-operator/Chart.yaml | 4 +- charts/ngrok-operator/README.md | 21 ++-- charts/ngrok-operator/README.md.gotmpl | 15 ++- charts/ngrok-operator/crds/crds.yaml | 11 ++ charts/releases/ngrok-operator-1.1.0.tgz | Bin 0 -> 4155 bytes config/crd/bases/ngrok.com_ngroks.yaml | 11 ++ controllers/ngrok_controller.go | 2 +- .../deployment.yaml | 0 .../service.yaml | 0 examples/helloworld/deployment.yaml | 20 ---- examples/helloworld/namespace.yaml | 4 - examples/helloworld/ngrok.yaml | 18 --- examples/helloworld/service.yaml | 11 -- .../http-full-configuration/deployment.yaml | 20 ---- examples/http-full-configuration/service.yaml | 11 -- .../{ => http}/authtoken-secret/ngrok.yaml | 7 +- .../{ => http}/authtoken-secret/secret.yaml | 0 .../full-configuration}/ngrok.yaml | 8 +- examples/{nginx => http/simple}/ngrok.yaml | 2 +- examples/nginx/deployment.yaml | 20 ---- examples/nginx/service.yaml | 11 -- go.mod | 2 + go.sum | 16 +++ pkg/builder/configuration_builder.go | 24 +++- pkg/builder/configuration_builder_test.go | 112 ++++++++++++++++++ pkg/utils/utils.go | 42 +++++-- 30 files changed, 299 insertions(+), 179 deletions(-) create mode 100644 charts/releases/ngrok-operator-1.1.0.tgz rename examples/{authtoken-secret => deployment}/deployment.yaml (100%) rename examples/{authtoken-secret => deployment}/service.yaml (100%) delete mode 100644 examples/helloworld/deployment.yaml delete mode 100644 examples/helloworld/namespace.yaml delete mode 100644 examples/helloworld/ngrok.yaml delete mode 100644 examples/helloworld/service.yaml delete mode 100644 examples/http-full-configuration/deployment.yaml delete mode 100644 examples/http-full-configuration/service.yaml rename examples/{ => http}/authtoken-secret/ngrok.yaml (68%) rename examples/{ => http}/authtoken-secret/secret.yaml (100%) rename examples/{http-full-configuration => http/full-configuration}/ngrok.yaml (87%) rename examples/{nginx => http/simple}/ngrok.yaml (95%) delete mode 100644 examples/nginx/deployment.yaml delete mode 100644 examples/nginx/service.yaml create mode 100644 pkg/builder/configuration_builder_test.go diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index f5d1a2f..ff6a58a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -92,7 +92,10 @@ jobs: version: "${{ matrix.kubernetes }}" k3d-args: --no-lb - name: deploy charts - run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=latest - - run: sleep 30 - - name: check charts installed - run: kubectl get pod + run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci + - name: deploy applications + run: kubectl apply -f examples/nginx + - name: deploy ngrok + run: kubectl apply -f examples/simple + - run: sleep 120 + - run: kubectl get ngrok -A diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index aee5ec8..58e9614 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -84,6 +84,9 @@ jobs: k3d-args: --no-lb - name: deploy charts run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci - - run: sleep 30 - - name: check charts installed - run: kubectl get pod + - name: deploy applications + run: kubectl apply -f examples/nginx + - name: deploy ngrok + run: kubectl apply -f examples/simple + - run: sleep 120 + - run: kubectl get ngrok -A diff --git a/README.md b/README.md index 7f67e3e..c1b7eb3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Ngrok operator provide developer easy access to private Kubernetes cluster for testing purpose via ngrok. Automate the creation of ngrok tunnel via CRD and automatically reload ngrok session when expired! -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls) +![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls) ## Installing @@ -16,23 +16,22 @@ helm install my-release zufardhiyaulhaq/ngrok-operator --values values.yaml ## Usage 1. Apply some example ```console -kubectl apply -f examples/nginx -kubectl apply -f examples/helloworld/namespace.yaml -kubectl apply -f examples/helloworld/ +kubectl apply -f examples/deployment/ +kubectl apply -f examples/http/simple/ +kubectl apply -f examples/http/full-configuration/ ``` 2. Check ngrok object ```console kubectl get ngrok --all-namespaces -NAMESPACE NAME STATUS URL -default nginx-ngrok created https://9496e56ed0bc.ngrok.io -default nginx-ngrok-full created https://ngrok.zufardhiyaulhaq.com -helloworld helloworld-ngrok created https://d00ba8cb0b95.ngrok.io +NAMESPACE NAME STATUS URL +default http-simple created https://9496e56ed0bc.ngrok.io +default http-full-configuration created https://ngrok.zufardhiyaulhaq.com ``` + 3. access the URL ```console https://d5150f7c3588.ngrok.io https://ngrok.zufardhiyaulhaq.com -https://fa03f71fbe18.ngrok.io/hello ``` ## Values @@ -42,4 +41,8 @@ https://fa03f71fbe18.ngrok.io/hello | operator.image | string | `"zufardhiyaulhaq/ngrok-operator"` | | | operator.replica | int | `1` | | | operator.tag | string | `"v1.1.0"` | | +| resources.limits.cpu | string | `"200m"` | | +| resources.limits.memory | string | `"100Mi"` | | +| resources.requests.cpu | string | `"100m"` | | +| resources.requests.memory | string | `"20Mi"` | | diff --git a/api/v1alpha1/ngrok_types.go b/api/v1alpha1/ngrok_types.go index 392207b..7949c6a 100644 --- a/api/v1alpha1/ngrok_types.go +++ b/api/v1alpha1/ngrok_types.go @@ -17,15 +17,19 @@ limitations under the License. package v1alpha1 import ( + "fmt" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NgrokSpec defines the desired state of Ngrok type NgrokSpec struct { Service string `json:"service"` - Port int32 `json:"port"` + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=65535 + Port int32 `json:"port"` - // +kubebuilder:validation:Enum=http;tcp + // +kubebuilder:validation:Enum=http;tcp;tls // +kubebuilder:default:=http // +optional Protocol string `json:"protocol"` @@ -38,29 +42,56 @@ type NgrokSpec struct { // +optional AuthTokenType string `json:"authtoken_type"` + // +kubebuilder:validation:Enum=us;eu;ap;au;sa;jp;in // +optional - Auth string `json:"auth"` + Region string `json:"region"` // +optional - Hostname string `json:"hostname"` + Auth string `json:"auth"` // +optional - RemoteAddr string `json:"remote_addr"` + HostHeader string `json:"host_header"` - // +kubebuilder:validation:Enum=us;eu;ap;au;sa;jp;in + // +kubebuilder:validation:Enum=true;false;both // +optional - Region string `json:"region"` + BindTLS string `json:"bind_tls"` // +kubebuilder:validation:Enum=true;false // +kubebuilder:default:=false // +optional Inspect bool `json:"inspect"` + // +optional + Hostname string `json:"hostname"` + + // +optional + RemoteAddr string `json:"remote_addr"` + // +kubebuilder:default:={image: zufardhiyaulhaq/ngrok} // +optional PodSpec PodSpec `json:"podSpec"` } +func (n *NgrokSpec) Validate() error { + if n.Protocol == "http" || n.Protocol == "tls" { + if n.Service == "" { + return fmt.Errorf("service invalid") + } + } + + if n.AuthToken == "" && n.Protocol == "tls" { + return fmt.Errorf("protocol TLS only available in pro") + } + + if n.Protocol == "tcp" { + if n.RemoteAddr == "" { + return fmt.Errorf("remote_addr invalid") + } + } + + return nil +} + type PodSpec struct { // +optional Image string `json:"image"` diff --git a/charts/ngrok-operator/Chart.yaml b/charts/ngrok-operator/Chart.yaml index 77beec5..5f10239 100644 --- a/charts/ngrok-operator/Chart.yaml +++ b/charts/ngrok-operator/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: ngrok-operator description: Ngrok operator provide developer easy access to private Kubernetes cluster for testing purpose via ngrok. Automate the creation of ngrok tunnel via CRD and automatically reload ngrok session when expired! -version: 1.0.0 -appVersion: 1.1.0 +version: 1.1.0 +appVersion: 1.2.0 type: application home: https://github.com/zufardhiyaulhaq/ngrok-operator diff --git a/charts/ngrok-operator/README.md b/charts/ngrok-operator/README.md index 7f67e3e..c1b7eb3 100644 --- a/charts/ngrok-operator/README.md +++ b/charts/ngrok-operator/README.md @@ -2,7 +2,7 @@ Ngrok operator provide developer easy access to private Kubernetes cluster for testing purpose via ngrok. Automate the creation of ngrok tunnel via CRD and automatically reload ngrok session when expired! -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls) +![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0](https://img.shields.io/badge/AppVersion-1.2.0-informational?style=flat-square) [![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org) [![Github master branch build](https://img.shields.io/github/workflow/status/zufardhiyaulhaq/ngrok-operator/Master)](https://github.com/zufardhiyaulhaq/ngrok-operator/actions/workflows/master.yml) [![GitHub issues](https://img.shields.io/github/issues/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/zufardhiyaulhaq/ngrok-operator)](https://github.com/zufardhiyaulhaq/ngrok-operator/pulls) ## Installing @@ -16,23 +16,22 @@ helm install my-release zufardhiyaulhaq/ngrok-operator --values values.yaml ## Usage 1. Apply some example ```console -kubectl apply -f examples/nginx -kubectl apply -f examples/helloworld/namespace.yaml -kubectl apply -f examples/helloworld/ +kubectl apply -f examples/deployment/ +kubectl apply -f examples/http/simple/ +kubectl apply -f examples/http/full-configuration/ ``` 2. Check ngrok object ```console kubectl get ngrok --all-namespaces -NAMESPACE NAME STATUS URL -default nginx-ngrok created https://9496e56ed0bc.ngrok.io -default nginx-ngrok-full created https://ngrok.zufardhiyaulhaq.com -helloworld helloworld-ngrok created https://d00ba8cb0b95.ngrok.io +NAMESPACE NAME STATUS URL +default http-simple created https://9496e56ed0bc.ngrok.io +default http-full-configuration created https://ngrok.zufardhiyaulhaq.com ``` + 3. access the URL ```console https://d5150f7c3588.ngrok.io https://ngrok.zufardhiyaulhaq.com -https://fa03f71fbe18.ngrok.io/hello ``` ## Values @@ -42,4 +41,8 @@ https://fa03f71fbe18.ngrok.io/hello | operator.image | string | `"zufardhiyaulhaq/ngrok-operator"` | | | operator.replica | int | `1` | | | operator.tag | string | `"v1.1.0"` | | +| resources.limits.cpu | string | `"200m"` | | +| resources.limits.memory | string | `"100Mi"` | | +| resources.requests.cpu | string | `"100m"` | | +| resources.requests.memory | string | `"20Mi"` | | diff --git a/charts/ngrok-operator/README.md.gotmpl b/charts/ngrok-operator/README.md.gotmpl index d7eba69..27b9212 100644 --- a/charts/ngrok-operator/README.md.gotmpl +++ b/charts/ngrok-operator/README.md.gotmpl @@ -15,23 +15,22 @@ helm install my-release zufardhiyaulhaq/ngrok-operator --values values.yaml ## Usage 1. Apply some example ```console -kubectl apply -f examples/nginx -kubectl apply -f examples/helloworld/namespace.yaml -kubectl apply -f examples/helloworld/ +kubectl apply -f examples/deployment/ +kubectl apply -f examples/http/simple/ +kubectl apply -f examples/http/full-configuration/ ``` 2. Check ngrok object ```console kubectl get ngrok --all-namespaces -NAMESPACE NAME STATUS URL -default nginx-ngrok created https://9496e56ed0bc.ngrok.io -default nginx-ngrok-full created https://ngrok.zufardhiyaulhaq.com -helloworld helloworld-ngrok created https://d00ba8cb0b95.ngrok.io +NAMESPACE NAME STATUS URL +default http-simple created https://9496e56ed0bc.ngrok.io +default http-full-configuration created https://ngrok.zufardhiyaulhaq.com ``` + 3. access the URL ```console https://d5150f7c3588.ngrok.io https://ngrok.zufardhiyaulhaq.com -https://fa03f71fbe18.ngrok.io/hello ``` {{ template "chart.requirementsSection" . }} diff --git a/charts/ngrok-operator/crds/crds.yaml b/charts/ngrok-operator/crds/crds.yaml index 4c6aad7..8867e33 100644 --- a/charts/ngrok-operator/crds/crds.yaml +++ b/charts/ngrok-operator/crds/crds.yaml @@ -55,6 +55,14 @@ spec: - plain - secret type: string + bind_tls: + enum: + - true + - false + - both + type: string + host_header: + type: string hostname: type: string inspect: @@ -72,12 +80,15 @@ spec: type: object port: format: int32 + maximum: 65535 + minimum: 1 type: integer protocol: default: http enum: - http - tcp + - tls type: string region: enum: diff --git a/charts/releases/ngrok-operator-1.1.0.tgz b/charts/releases/ngrok-operator-1.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..db5a6932afea2a8942558e0a18c0fd6936b9dca4 GIT binary patch literal 4155 zcmV-B5XA2viwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PH+#bKAC-{mfr+YES3hc9#?-OLnT6&aSVM&34*kJ#m_u-Oil^ zB9AE4Aix5k5~a@m_B#Oh7A5%=d)nxHkVx?0;NWo{cpaWdap{W;CDB3-&K5-KU`0~) z)%`&jhT-veZ2!YB?EZ%*N5ij%Bj$6tlR@o;?d6@>T5!$!!JCi1KB&SiBg z_a_08(Kjd+6?_WIkw>zudL0I%AoOBXk))ZnNiWT4fpWA!CdHD*2r({^nN&ccRzRW% zl>#jwlXOWm!cX}OB}a`4B9<$S(gTxbfJs&V7lue4 zoS2gS&tSmQ3dIA+C965;P_TJj&JF{5mEjafmN6RHmhqN#zYT-XyJr7)b8KE*fGn!Iup8%pPpTZ~%Q~Q=; zD&%Sk!!Ue7Es5WAR4v?L7k6Y(AG=E)6gu*+G0hm!s0MEr$TE~F(Aiy8!7lk9jYb{$ zKb{;-_VWJ_@W&rM#5kuM;h;Shg2?!S2jGADSMeoDv3xE( z2e`80N+N`Ve>;GKw+C(~EpQryt!GnKQIg0+P|^QskMf zt6xlN+*F|Dz!aa92e3prE7I(I2km2w42#DEwf$#QxrdDCXknl7EG{#=w~06BU@)hg zF!~W?hna%*Ehs8Ybl#y>R$`6!HTnk!>x45AE7wAT&uNm9%)Kht1)ske`1!36Y-;$BW2m+k`w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^Tb%t0@xGQOKch1?BguWkCp90)IblE5CAK&e12M9yL}-j^sfNQ^|n z>Bow;-7qnQ+A}t~L(>itPMCAt?2aj6kj`=~r19aF$OeigK9SLaYK(L)aX>QaTh_Ui-5`w*tEG~^wRl|{3=XV-ZRr6c zY^JM8xy)i~Q8%mBw~PxAkqi*BMpa1*X9$pQCi0IF}-|G?B-dpj3Q9x(Ovci*es2@G z@SqztZd~K-=`SmO7a2w^d5KX`X-2d*-kX>=6lw|mQfh$YbySa?btyC0xPG_G_0}S- zWi1@?DP)Y$u4n@w&(rlx{s!za{^Ly;oKYUX)oiVOHkaMH*<2?#FH|95wkw2k9yCImy$?aWNX7i%)nWNht2b@#b`@;K>Q2DcqNH5TV+wDvV6A84AVQ#hVXjwb7$DR-ZT8yGQmta%B# zs=7PLy1Cbl0=;&p_aghCqux~3H6dG@RARE`Ol;#NU#IQ^<~@m|k2}(bsYp-aZ++Q& zbkf$kr9$Id62~`_^x{D94e}HV1s#{bw_~!CR34CCr@L;ntf#uuY+0<9;Sw`b%55!I zU$Hw{ESEil{l=};a{9}}+E3roR%?l_{*5d3N(*VVSDlj2S~oKrRfj)5d37t0D8fu* z{IWa0Iyh)eqU>uVxSI>9Dg63R&lQaEn{vKn5+8deyoWvPVGmyx{3`$e|NkWxlM(=M F008hWE}sAZ literal 0 HcmV?d00001 diff --git a/config/crd/bases/ngrok.com_ngroks.yaml b/config/crd/bases/ngrok.com_ngroks.yaml index 4c6aad7..8867e33 100644 --- a/config/crd/bases/ngrok.com_ngroks.yaml +++ b/config/crd/bases/ngrok.com_ngroks.yaml @@ -55,6 +55,14 @@ spec: - plain - secret type: string + bind_tls: + enum: + - true + - false + - both + type: string + host_header: + type: string hostname: type: string inspect: @@ -72,12 +80,15 @@ spec: type: object port: format: int32 + maximum: 65535 + minimum: 1 type: integer protocol: default: http enum: - http - tcp + - tls type: string region: enum: diff --git a/controllers/ngrok_controller.go b/controllers/ngrok_controller.go index 14b18e1..74339c0 100644 --- a/controllers/ngrok_controller.go +++ b/controllers/ngrok_controller.go @@ -93,7 +93,7 @@ func (r *NgrokReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl } log.Info("Build configuration") - configuration, err := builder.NewNgrokConfigurationBuilder(r.Client). + configuration, err := builder.NewNgrokConfigurationBuilder(). SetSpec(spec). Build() if err != nil { diff --git a/examples/authtoken-secret/deployment.yaml b/examples/deployment/deployment.yaml similarity index 100% rename from examples/authtoken-secret/deployment.yaml rename to examples/deployment/deployment.yaml diff --git a/examples/authtoken-secret/service.yaml b/examples/deployment/service.yaml similarity index 100% rename from examples/authtoken-secret/service.yaml rename to examples/deployment/service.yaml diff --git a/examples/helloworld/deployment.yaml b/examples/helloworld/deployment.yaml deleted file mode 100644 index 442d5a5..0000000 --- a/examples/helloworld/deployment.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: helloworld-deployment - namespace: helloworld -spec: - selector: - matchLabels: - run: helloworld - replicas: 1 - template: - metadata: - labels: - run: helloworld - spec: - containers: - - name: helloworld - image: docker.io/istio/examples-helloworld-v1 - ports: - - containerPort: 80 diff --git a/examples/helloworld/namespace.yaml b/examples/helloworld/namespace.yaml deleted file mode 100644 index 7dd7b3e..0000000 --- a/examples/helloworld/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: helloworld diff --git a/examples/helloworld/ngrok.yaml b/examples/helloworld/ngrok.yaml deleted file mode 100644 index 17db168..0000000 --- a/examples/helloworld/ngrok.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: ngrok.com/v1alpha1 -kind: Ngrok -metadata: - name: ngrok-helloworld - namespace: helloworld -spec: - # protocol used, currently support http & tcp - # tcp is less tested, please create issue - # default is http - protocol: http - - # service section represent - # the service name in the same namespace - service: helloworld-service - - # port section represent - # the service port in the same namespace - port: 5000 diff --git a/examples/helloworld/service.yaml b/examples/helloworld/service.yaml deleted file mode 100644 index f2d55c9..0000000 --- a/examples/helloworld/service.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: helloworld-service - namespace: helloworld -spec: - ports: - - port: 5000 - protocol: TCP - selector: - run: helloworld diff --git a/examples/http-full-configuration/deployment.yaml b/examples/http-full-configuration/deployment.yaml deleted file mode 100644 index 5398d5f..0000000 --- a/examples/http-full-configuration/deployment.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment - namespace: default -spec: - selector: - matchLabels: - run: nginx - replicas: 1 - template: - metadata: - labels: - run: nginx - spec: - containers: - - name: nginx - image: nginx - ports: - - containerPort: 80 diff --git a/examples/http-full-configuration/service.yaml b/examples/http-full-configuration/service.yaml deleted file mode 100644 index 91a16dc..0000000 --- a/examples/http-full-configuration/service.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: nginx-service - namespace: default -spec: - ports: - - port: 80 - protocol: TCP - selector: - run: nginx diff --git a/examples/authtoken-secret/ngrok.yaml b/examples/http/authtoken-secret/ngrok.yaml similarity index 68% rename from examples/authtoken-secret/ngrok.yaml rename to examples/http/authtoken-secret/ngrok.yaml index bdbcba5..57b3c50 100644 --- a/examples/authtoken-secret/ngrok.yaml +++ b/examples/http/authtoken-secret/ngrok.yaml @@ -1,9 +1,14 @@ apiVersion: ngrok.com/v1alpha1 kind: Ngrok metadata: - name: ngrok-authtoken-secret + name: http-authtoken-secret namespace: default spec: + # protocol used, currently support http & tcp + # tcp is less tested, please create issue + # default is http + protocol: http + # ngrok authtoken authtoken: authtoken-secret diff --git a/examples/authtoken-secret/secret.yaml b/examples/http/authtoken-secret/secret.yaml similarity index 100% rename from examples/authtoken-secret/secret.yaml rename to examples/http/authtoken-secret/secret.yaml diff --git a/examples/http-full-configuration/ngrok.yaml b/examples/http/full-configuration/ngrok.yaml similarity index 87% rename from examples/http-full-configuration/ngrok.yaml rename to examples/http/full-configuration/ngrok.yaml index 0150387..b866900 100644 --- a/examples/http-full-configuration/ngrok.yaml +++ b/examples/http/full-configuration/ngrok.yaml @@ -1,7 +1,7 @@ apiVersion: ngrok.com/v1alpha1 kind: Ngrok metadata: - name: ngrok-full-configuration + name: http-full-configuration namespace: default spec: # ngrok authtoken @@ -21,6 +21,12 @@ spec: # https://ngrok.com/docs region: ap + # Rewrite the HTTP Host header to this value + host_header: "foo.bar" + + # bind an HTTPS or HTTP endpoint or both + bind_tls: both + # auth protect your http # with user password combination # : diff --git a/examples/nginx/ngrok.yaml b/examples/http/simple/ngrok.yaml similarity index 95% rename from examples/nginx/ngrok.yaml rename to examples/http/simple/ngrok.yaml index c7514b2..e89efb0 100644 --- a/examples/nginx/ngrok.yaml +++ b/examples/http/simple/ngrok.yaml @@ -1,7 +1,7 @@ apiVersion: ngrok.com/v1alpha1 kind: Ngrok metadata: - name: nginx-ngrok + name: http-simple namespace: default spec: # protocol used, currently support http & tcp diff --git a/examples/nginx/deployment.yaml b/examples/nginx/deployment.yaml deleted file mode 100644 index 5398d5f..0000000 --- a/examples/nginx/deployment.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment - namespace: default -spec: - selector: - matchLabels: - run: nginx - replicas: 1 - template: - metadata: - labels: - run: nginx - spec: - containers: - - name: nginx - image: nginx - ports: - - containerPort: 80 diff --git a/examples/nginx/service.yaml b/examples/nginx/service.yaml deleted file mode 100644 index 91a16dc..0000000 --- a/examples/nginx/service.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: nginx-service - namespace: default -spec: - ports: - - port: 80 - protocol: TCP - selector: - run: nginx diff --git a/go.mod b/go.mod index 3b437d6..ebed4d7 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,12 @@ require ( github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc // indirect github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21 // indirect github.com/klauspost/cpuid v1.2.0 // indirect + github.com/norwoodj/helm-docs v1.6.0 // indirect github.com/onsi/ginkgo v1.16.4 github.com/onsi/gomega v1.13.0 github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7 // indirect github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect + github.com/stretchr/testify v1.7.0 // indirect golang.org/x/tools v0.1.3 // indirect gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect diff --git a/go.sum b/go.sum index 9308a71..26de4e7 100644 --- a/go.sum +++ b/go.sum @@ -57,11 +57,14 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= +github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= @@ -351,6 +354,7 @@ github.com/gordonklaus/ineffassign v0.0.0-20210225214923-2e10b2664254/go.mod h1: github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= @@ -402,10 +406,12 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= +github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -520,6 +526,7 @@ github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7 github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -532,6 +539,7 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= @@ -566,6 +574,8 @@ github.com/nishanths/exhaustive v0.1.0/go.mod h1:S1j9110vxV1ECdCudXRkeMnFQ/DQk9a github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= github.com/nishanths/predeclared v0.2.1 h1:1TXtjmy4f3YCFjTxRd8zcFHOmoUir+gp0ESzjFzG2sw= github.com/nishanths/predeclared v0.2.1/go.mod h1:HvkGJcA3naj4lOwnFXFDkFxVtSqQMB9sbB1usJ+xjQE= +github.com/norwoodj/helm-docs v1.6.0 h1:EH2vShsTEsQ0gjvWsrofYV5ylb9p6LdX7LCIvkkFdFA= +github.com/norwoodj/helm-docs v1.6.0/go.mod h1:z8Evt7esakCuqMKuwpVAAp4NyHgQbH3iGWsGmLuBcV0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -706,6 +716,7 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= @@ -743,6 +754,7 @@ github.com/tomarrell/wrapcheck/v2 v2.1.0/go.mod h1:crK5eI4RGSUrb9duDTQ5GqcukbKZv github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= github.com/tommy-muehle/go-mnd/v2 v2.4.0 h1:1t0f8Uiaq+fqKteUR4N9Umr6E99R+lDnLnq7PwX2PPE= github.com/tommy-muehle/go-mnd/v2 v2.4.0/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA= github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= @@ -864,6 +876,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1157,6 +1170,7 @@ google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6D google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -1244,6 +1258,8 @@ k8s.io/component-base v0.21.2 h1:EsnmFFoJ86cEywC0DoIkAUiEV6fjgauNugiw1lmIjs4= k8s.io/component-base v0.21.2/go.mod h1:9lvmIThzdlrJj5Hp8Z/TOgIkdfsNARQ1pT+3PByuiuc= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/helm v2.14.3+incompatible h1:uzotTcZXa/b2SWVoUzM1xiCXVjI38TuxMujS/1s+3Gw= +k8s.io/helm v2.14.3+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.8.0 h1:Q3gmuM9hKEjefWFFYF0Mat+YyFJvsUyYuwyNNJ5C9Ts= diff --git a/pkg/builder/configuration_builder.go b/pkg/builder/configuration_builder.go index 8629fa4..494cd1a 100644 --- a/pkg/builder/configuration_builder.go +++ b/pkg/builder/configuration_builder.go @@ -2,19 +2,19 @@ package builder import ( "bytes" - "html/template" + "strings" + "text/template" ngrokcomv1alpha1 "github.com/zufardhiyaulhaq/ngrok-operator/api/v1alpha1" "github.com/zufardhiyaulhaq/ngrok-operator/pkg/utils" - "sigs.k8s.io/controller-runtime/pkg/client" ) type NgrokConfigurationBuilder struct { Spec *ngrokcomv1alpha1.NgrokSpec } -func NewNgrokConfigurationBuilder(client client.Client) *NgrokConfigurationBuilder { +func NewNgrokConfigurationBuilder() *NgrokConfigurationBuilder { return &NgrokConfigurationBuilder{} } @@ -24,17 +24,29 @@ func (n *NgrokConfigurationBuilder) SetSpec(spec *ngrokcomv1alpha1.NgrokSpec) *N } func (n *NgrokConfigurationBuilder) Build() (string, error) { - var configuration bytes.Buffer + err := n.Spec.Validate() + if err != nil { + return "", err + } + + var configurationBuffer bytes.Buffer templateEngine, err := template.New("ngrok").Parse(utils.TMPL) if err != nil { return "", err } - err = templateEngine.Execute(&configuration, n.Spec) + err = templateEngine.Execute(&configurationBuffer, n.Spec) if err != nil { return "", err } - return configuration.String(), nil + var configuration []string + for _, data := range strings.Split(configurationBuffer.String(), "\n") { + if len(strings.TrimSpace(data)) != 0 { + configuration = append(configuration, data) + } + } + + return strings.Join(configuration, "\n"), nil } diff --git a/pkg/builder/configuration_builder_test.go b/pkg/builder/configuration_builder_test.go new file mode 100644 index 0000000..708b284 --- /dev/null +++ b/pkg/builder/configuration_builder_test.go @@ -0,0 +1,112 @@ +package builder_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/zufardhiyaulhaq/ngrok-operator/pkg/builder" + + ngrokcomv1alpha1 "github.com/zufardhiyaulhaq/ngrok-operator/api/v1alpha1" +) + +type configurationBuilderTestCase struct { + name string + spec *ngrokcomv1alpha1.NgrokSpec + expectedConfiguration string + expectedError bool +} + +var testGrid = []configurationBuilderTestCase{ + { + name: "empty service", + spec: &ngrokcomv1alpha1.NgrokSpec{ + Service: "", + Port: 80, + AuthTokenType: "plain", + Protocol: "http", + Inspect: false, + }, + expectedError: true, + expectedConfiguration: "", + }, + { + name: "simple HTTP service", + spec: &ngrokcomv1alpha1.NgrokSpec{ + Service: "foo.bar", + Port: 80, + AuthTokenType: "plain", + Protocol: "http", + Inspect: false, + }, + expectedError: false, + expectedConfiguration: `web_addr: 0.0.0.0:4040 +tunnels: + app: + proto: http + addr: foo.bar:80 + inspect: false`, + }, + { + name: "full HTTP service", + spec: &ngrokcomv1alpha1.NgrokSpec{ + Service: "foo.bar", + Port: 80, + Region: "us", + Auth: "foo:bar", + AuthToken: "foo", + AuthTokenType: "plain", + Protocol: "http", + BindTLS: "true", + Inspect: false, + HostHeader: "foo.dev", + Hostname: "foo.bar", + }, + expectedError: false, + expectedConfiguration: `web_addr: 0.0.0.0:4040 +authtoken: foo +region: us +tunnels: + app: + proto: http + addr: foo.bar:80 + inspect: false + auth: foo:bar + host_header: foo.dev + bind_tls: true + hostname: foo.bar`, + }, + { + name: "simple TCP service", + spec: &ngrokcomv1alpha1.NgrokSpec{ + Service: "foo.bar", + Port: 80, + Protocol: "tcp", + RemoteAddr: "1.tcp.ngrok.io:12345", + }, + expectedError: false, + expectedConfiguration: `web_addr: 0.0.0.0:4040 +tunnels: + app: + proto: tcp + addr: foo.bar:80 + remote_addr: 1.tcp.ngrok.io:12345`, + }, +} + +func TestConfigurationBuilder(t *testing.T) { + for _, test := range testGrid { + t.Run(test.name, func(t *testing.T) { + configuration, err := builder.NewNgrokConfigurationBuilder(). + SetSpec(test.spec). + Build() + + assert.Equal(t, configuration, test.expectedConfiguration) + + if test.expectedError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 4aedc4a..63f98bf 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -11,31 +11,49 @@ import ( ) const NGROK_URL_REGEX = `https://.[^"]+` -const TMPL = `web_addr: 0.0.0.0:4040 -{{if .AuthToken }} +const TMPL = ` +web_addr: 0.0.0.0:4040 + +{{ if .AuthToken }} authtoken: {{ .AuthToken }} -{{end}} -{{if .Region }} +{{ end }} + +{{ if .Region }} region: {{ .Region }} -{{end}} +{{ end }} + tunnels: app: proto: {{ .Protocol }} addr: {{ .Service }}:{{ .Port }} - {{if eq .Protocol "http"}} + + {{ if eq .Protocol "http" }} inspect: {{ .Inspect }} {{if .Auth }} auth: {{ .Auth }} {{ end }} + {{if .HostHeader }} + host_header: {{ .HostHeader }} + {{ end }} + {{if .BindTLS }} + bind_tls: {{ .BindTLS }} + {{ end }} {{if .AuthToken }}{{if .Hostname }} hostname: {{ .Hostname }} - {{end}}{{end}} - {{end}} - {{if eq .Protocol "tcp"}} - {{if .AuthToken }}{{if .RemoteAddr }} + {{ end }}{{ end }} + {{ end }} + + {{if .AuthToken }} + {{ if eq .Protocol "tls" }}{{if .Hostname }} + hostname: {{ .Hostname }} + {{ end }}{{ end }} + {{ end }} + + {{if eq .Protocol "tcp" }} + {{if .RemoteAddr }} remote_addr: {{ .RemoteAddr }} - {{end}}{{end}} - {{end}} + {{ end }} + {{ end }} ` func GetNgrokURL(api string) (string, error) { From 7e6653cca5ed2860a0297828cc25eeb5e8f44e87 Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Sat, 4 Sep 2021 15:28:59 +0200 Subject: [PATCH 2/5] fix integration tests Signed-off-by: zufardhiyaulhaq --- .github/workflows/master.yml | 4 ++-- .github/workflows/pullrequest.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index ff6a58a..6e07044 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -94,8 +94,8 @@ jobs: - name: deploy charts run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci - name: deploy applications - run: kubectl apply -f examples/nginx + run: kubectl apply -f ./examples/nginx - name: deploy ngrok - run: kubectl apply -f examples/simple + run: kubectl apply -f ./examples/simple - run: sleep 120 - run: kubectl get ngrok -A diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 58e9614..e56b2d9 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -85,8 +85,8 @@ jobs: - name: deploy charts run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci - name: deploy applications - run: kubectl apply -f examples/nginx + run: kubectl apply -f ./examples/nginx - name: deploy ngrok - run: kubectl apply -f examples/simple + run: kubectl apply -f ./examples/simple - run: sleep 120 - run: kubectl get ngrok -A From 333973d9677bc5e0359e7c126704ed4242bb7b6a Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Sat, 4 Sep 2021 15:36:35 +0200 Subject: [PATCH 3/5] fix e2e tests Signed-off-by: zufardhiyaulhaq --- .github/workflows/master.yml | 6 +++--- .github/workflows/pullrequest.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6e07044..9066972 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -94,8 +94,8 @@ jobs: - name: deploy charts run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci - name: deploy applications - run: kubectl apply -f ./examples/nginx + run: kubectl apply -f ./examples/deployment - name: deploy ngrok - run: kubectl apply -f ./examples/simple - - run: sleep 120 + run: kubectl apply -f ./examples/http/simple + - run: sleep 180 - run: kubectl get ngrok -A diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index e56b2d9..2cd9015 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -85,8 +85,8 @@ jobs: - name: deploy charts run: helm install ngrok-operator ./charts/ngrok-operator --values ./charts/ngrok-operator/values.yaml --set operator.tag=dev-ci - name: deploy applications - run: kubectl apply -f ./examples/nginx + run: kubectl apply -f ./examples/deployment - name: deploy ngrok - run: kubectl apply -f ./examples/simple - - run: sleep 120 + run: kubectl apply -f ./examples/http/simple + - run: sleep 180 - run: kubectl get ngrok -A From b49ca8c57aebc082224dbaa746224f04388399ae Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Sat, 4 Sep 2021 15:55:04 +0200 Subject: [PATCH 4/5] add http free full configuration example Signed-off-by: zufardhiyaulhaq --- examples/http/simple/ngrok.yaml | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/examples/http/simple/ngrok.yaml b/examples/http/simple/ngrok.yaml index e89efb0..28c8b05 100644 --- a/examples/http/simple/ngrok.yaml +++ b/examples/http/simple/ngrok.yaml @@ -16,3 +16,47 @@ spec: # port section represent # the service port in the same namespace port: 80 +--- +apiVersion: ngrok.com/v1alpha1 +kind: Ngrok +metadata: + name: http-free-full-config + namespace: default +spec: + # protocol used, currently support http & tcp + # tcp is less tested, please create issue + # if there is an issue with tcp + protocol: http + + # region where ngrok run + # refer to the docs + # https://ngrok.com/docs + region: ap + + # Rewrite the HTTP Host header to this value + host_header: "foo.bar" + + # bind an HTTPS or HTTP endpoint or both + bind_tls: both + + # auth protect your http + # with user password combination + # : + auth: user:password + + # enable inspection + # only works for http protocol + inspect: true + + # service section represent + # the service name in the same namespace + service: nginx-service + + # port section represent + # the service port in the same namespace + port: 80 + + # define the image for the ngrok + # default to zufardhiyaulhaq/ngrok:latest + podSpec: + image: zufardhiyaulhaq/ngrok From f65c9ccda9d60247fd3c927646bc22cd507ee347 Mon Sep 17 00:00:00 2001 From: zufardhiyaulhaq Date: Sat, 4 Sep 2021 16:29:12 +0200 Subject: [PATCH 5/5] disable sidecar injection from service mesh Signed-off-by: zufardhiyaulhaq --- .github/workflows/master.yml | 6 ++++-- .github/workflows/pullrequest.yml | 6 ++++-- README.md | 2 +- charts/ngrok-operator/README.md | 2 +- charts/ngrok-operator/values.yaml | 2 +- charts/releases/ngrok-operator-1.1.0.tgz | Bin 4155 -> 4155 bytes examples/http/simple/ngrok.yaml | 5 ----- pkg/builder/pod_builder.go | 7 +++++++ pkg/utils/utils.go | 4 ++-- 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 9066972..d4d9b60 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -97,5 +97,7 @@ jobs: run: kubectl apply -f ./examples/deployment - name: deploy ngrok run: kubectl apply -f ./examples/http/simple - - run: sleep 180 - - run: kubectl get ngrok -A + - name: waiting ngrok-operator to start + run: sleep 180 + - name: check ngrok object + run: kubectl get ngrok -A diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 2cd9015..cb42944 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -88,5 +88,7 @@ jobs: run: kubectl apply -f ./examples/deployment - name: deploy ngrok run: kubectl apply -f ./examples/http/simple - - run: sleep 180 - - run: kubectl get ngrok -A + - name: waiting ngrok-operator to start + run: sleep 180 + - name: check ngrok object + run: kubectl get ngrok -A diff --git a/README.md b/README.md index c1b7eb3..3263e0c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ https://ngrok.zufardhiyaulhaq.com |-----|------|---------|-------------| | operator.image | string | `"zufardhiyaulhaq/ngrok-operator"` | | | operator.replica | int | `1` | | -| operator.tag | string | `"v1.1.0"` | | +| operator.tag | string | `"v1.2.0"` | | | resources.limits.cpu | string | `"200m"` | | | resources.limits.memory | string | `"100Mi"` | | | resources.requests.cpu | string | `"100m"` | | diff --git a/charts/ngrok-operator/README.md b/charts/ngrok-operator/README.md index c1b7eb3..3263e0c 100644 --- a/charts/ngrok-operator/README.md +++ b/charts/ngrok-operator/README.md @@ -40,7 +40,7 @@ https://ngrok.zufardhiyaulhaq.com |-----|------|---------|-------------| | operator.image | string | `"zufardhiyaulhaq/ngrok-operator"` | | | operator.replica | int | `1` | | -| operator.tag | string | `"v1.1.0"` | | +| operator.tag | string | `"v1.2.0"` | | | resources.limits.cpu | string | `"200m"` | | | resources.limits.memory | string | `"100Mi"` | | | resources.requests.cpu | string | `"100m"` | | diff --git a/charts/ngrok-operator/values.yaml b/charts/ngrok-operator/values.yaml index e253c55..6fca7f1 100644 --- a/charts/ngrok-operator/values.yaml +++ b/charts/ngrok-operator/values.yaml @@ -2,7 +2,7 @@ operator: # image of ngrok-operator image: "zufardhiyaulhaq/ngrok-operator" # tag of ngrok-operator image - tag: "v1.1.0" + tag: "v1.2.0" # number of replica for deployment replica: 1 diff --git a/charts/releases/ngrok-operator-1.1.0.tgz b/charts/releases/ngrok-operator-1.1.0.tgz index db5a6932afea2a8942558e0a18c0fd6936b9dca4..363330961ce7955677cc85a0db67312915a69384 100644 GIT binary patch delta 4118 zcmV+x5b5u`AiE%tOn>#Tooc4D>+58*oikwBMLPLumGq;sk6WR4gkJI zNq)tiHaZ_95o6Dvp%82k(5N)!31qpLnFf23V$RrLE-{mp)%Ei_Y35JA2KR2{@Po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okg;46Hmw7*0Vv9ooDo?hdH^aC8BU=(1{b@t%c`ukZ_GY*ORndVa*gs# zuski>#D|{9+Eu(X1Ao6M!O!i5punXEt zLhD|?iWZnwR|`dk{Pg_CH%Aw(Wa#6GIt%77-M+yBi*KjrKh{_6q)}CxqH5hYs>g5Z z(p0OUzZqVN2&FFKsVlSSG>i-OLCirfs4~8rM1|Z9Wv^}e#eWKrKYh zVl&>CC^bloM8fIEiniS_F@@SQHo8O84iZk7bKLBXDWqft5=|+P^9H@bw}Tf#B2YdT zttjTD+(sfzb58YYU`3G5axJ9s;g-k-iY7jh(SmA>bS`l~GU{8_xs}}@jSs7(lE1Zh zT^kGztblFl0e>TGrmIQ0%wlU%H?&DIt@G;H#p`O7#&$-x^=-S?8CBf{rokwmqja4( zmm;+^k;j>!Tsx1RQ5RRb2`ZnZRI6%c0$K!cW|bMtu(;w72k;|@Gm;`ZBMLuz2bh*t zzG>L&bwT%jZxgxjpc^%AT;uKOFDrf*8AdI6iBVB$Mt`(6-kX>=6lw|mQfh$YbySa? zbtyC0xPG_G_0}S-Wi1@?DP)Y$u4n@w&(rlx{s!za{^Ly;oKYUX)oiVOHkaMH*<2?# zFH|95wkw2k9yCImy$?aWNX7i%)n zWNht2b$|D{cT&EFzF9JAQavBGw&q6hhVnS+S_ZcrJT(^QXteenq&hp9+U;%|M~dvwy)x}`$nTN1}Nll0<1@P7^R6bl6%m%z7UvXfLEkY1;|ZnUhY zy3=e~td`*tGgHcKEmvQ$J6bH4J%jzmt<`e+%f#AG-_llViLU;QEA>hXX|-3KlFwQ< zGaFThKR$VNE08F{Ok@1AJHI+OXicK*Yb3av3#lpm`cKaljPaXtzGM;~dnUYxJ?vo* UUk?`iD*yoh|0Nca5&&=j00HkNTmS$7 diff --git a/examples/http/simple/ngrok.yaml b/examples/http/simple/ngrok.yaml index 28c8b05..18c11c9 100644 --- a/examples/http/simple/ngrok.yaml +++ b/examples/http/simple/ngrok.yaml @@ -39,11 +39,6 @@ spec: # bind an HTTPS or HTTP endpoint or both bind_tls: both - # auth protect your http - # with user password combination - # : - auth: user:password - # enable inspection # only works for http protocol inspect: true diff --git a/pkg/builder/pod_builder.go b/pkg/builder/pod_builder.go index 01b1fa0..efa0205 100644 --- a/pkg/builder/pod_builder.go +++ b/pkg/builder/pod_builder.go @@ -39,6 +39,13 @@ func (n *NgrokPodBuilder) Build() (*corev1.Pod, error) { "app": n.Name, "generated": "ngrok-operator", }, + Annotations: map[string]string{ + "sidecar.istio.io/inject": "false", + "linkerd.io/inject": "disabled", + "kuma.io/sidecar-injection": "disabled", + "appmesh.k8s.aws/sidecarInjectorWebhook": "disabled", + "injector.nsm.nginx.com/auto-inject": "false", + }, }, Spec: corev1.PodSpec{ Containers: []corev1.Container{ diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 63f98bf..6dcad2d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -29,9 +29,9 @@ tunnels: {{ if eq .Protocol "http" }} inspect: {{ .Inspect }} - {{if .Auth }} + {{if .AuthToken }}{{if .Auth }} auth: {{ .Auth }} - {{ end }} + {{ end }}{{ end }} {{if .HostHeader }} host_header: {{ .HostHeader }} {{ end }}