Skip to content

Commit

Permalink
Make webhookless installer generator work on CI
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Caparelli <[email protected]>
  • Loading branch information
LCaparelli committed Feb 4, 2021
1 parent cb1732a commit 244be89
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 16 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/nexus-operator-integration-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install yq
run: |
pip install yq
- name: Check Vet
run: |
make generate
Expand Down Expand Up @@ -66,6 +73,14 @@ jobs:
restore-keys: |
${{ runner.os }}-go-cache-
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install yq
run: |
pip install yq
- name: Cache Operator SDK
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -131,6 +146,13 @@ jobs:
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install yq
run: |
pip install yq
- name: Install Operator SDK
run: |
./hack/ci/install-operator-sdk.sh
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ run_with_image=true
pr-prep:
CREATE_NAMESPACE=$(create_namespace) RUN_WITH_IMAGE=$(run_with_image) ./hack/pr-prep.sh

# Generate the installer without webhook configs, secrets and what not
generate-webhookless-installer:
# first, let's filter out all manifests we don't care about
# then delete the volumes which would contain the certs
# then finally insert the env var which disables webhooks
# TODO <lcaparelli>: find a way to make this more readable
kustomize build config/default/ | yq -Y 'select(.kind != "ValidatingWebhookConfiguration" and .kind != "Issuer" and .kind != "Certificate" and .kind != "MutatingWebhookConfiguration" and .metadata.name != "nexus-operator-webhook-service")' | yq -Y 'del(.. | .volumes?, .volumeMounts?)' | yq -Y 'if .kind=="Deployment" then .spec.template.spec.containers[1].env[0]={"name":"USE_WEBHOOKS", "value":"FALSE"} else . end' > webhookless-nexus-operator.yaml
./hack/generate-webhookless-installer.sh
30 changes: 30 additions & 0 deletions hack/generate-webhookless-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright 2020 Nexus Operator and/or its authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

command -v yq > /dev/null || ( echo "Please install yq before proceeding (https://pypi.org/project/yq/)" && exit 1 )
command -v kustomize >/dev/null || go get sigs.k8s.io/kustomize/kustomize/[email protected] || exit 1

# first, let's filter out all manifests for kinds we don't care about
# 'select(.kind != "ValidatingWebhookConfiguration" and .kind != "Issuer" and .kind != "Certificate" and .kind != "MutatingWebhookConfiguration" and .metadata.name != "nexus-operator-webhook-service")'

# then delete the volumes which would contain the certs
# 'del(.. | .volumes?, .volumeMounts?)'

# then finally insert the env var which disables webhooks
# 'if .kind=="Deployment" then .spec.template.spec.containers[1].env[0]={"name":"USE_WEBHOOKS", "value":"FALSE"} else . end'

bin/kustomize build config/default/ | yq -Y 'select(.kind != "ValidatingWebhookConfiguration" and .kind != "Issuer" and .kind != "Certificate" and .kind != "MutatingWebhookConfiguration" and .metadata.name != "nexus-operator-webhook-service")' \
| yq -Y 'del(.. | .volumes?, .volumeMounts?)' \
| yq -Y 'if .kind=="Deployment" then .spec.template.spec.containers[1].env[0]={"name":"USE_WEBHOOKS", "value":"FALSE"} else . end' > webhookless-nexus-operator.yaml
21 changes: 10 additions & 11 deletions webhookless-nexus-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: nexus-operator-system/nexus-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: nexus.apps.m88i.io
spec:
additionalPrinterColumns:
Expand Down Expand Up @@ -694,16 +693,6 @@ spec:
control-plane: controller-manager
spec:
containers:
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: https
- args:
- --metrics-addr=127.0.0.1:8080
- --enable-leader-election
Expand All @@ -719,6 +708,16 @@ spec:
requests:
cpu: 100m
memory: 20Mi
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: https
env:
- name: USE_WEBHOOKS
value: 'FALSE'
Expand Down

0 comments on commit 244be89

Please sign in to comment.