From 32ded282f39f6989e178477b6ad61d6d38c260a5 Mon Sep 17 00:00:00 2001 From: Simon Lukasik Date: Mon, 27 Sep 2021 12:03:08 +0200 Subject: [PATCH] Automate manifest update out of README.md --- .github/workflows/go.yml | 2 +- Makefile | 5 ++++- .../falcon-operator.clusterserviceversion.yaml | 2 +- .../bases/falcon-operator.clusterserviceversion.yaml | 2 +- hack/update-manifest.sh | 10 ++++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100755 hack/update-manifest.sh diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2c307494..b40cb579 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -47,7 +47,7 @@ jobs: run: | go mod tidy make manifests generate - make bundle + touch README.md ; make bundle rm deploy/falcon-operator.yaml && make deploy/falcon-operator.yaml find ./bundle* -type f -exec sed -i -e 's/operator-sdk-v1.7.1+git/operator-sdk-v1.8.0/g' {} \; if [[ -n $(git status -s) ]] ; then diff --git a/Makefile b/Makefile index 0d1fb752..7a0d8d4c 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,7 @@ endef # Generate bundle manifests and metadata, then validate generated files. .PHONY: bundle -bundle: manifests kustomize operator-sdk +bundle: manifests kustomize operator-sdk config/manifests/bases/falcon-operator.clusterserviceversion.yaml operator-sdk generate kustomize manifests -q cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) $(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS) @@ -142,3 +142,6 @@ deploy/parts/crd-falconnodesensors.yaml: bundle/manifests/falcon.crowdstrike.com deploy/falcon-operator.yaml: deploy/parts/crd-falconcontainers.yaml deploy/parts/crd-falconnodesensors.yaml deploy/parts/ns.yaml deploy/parts/role.yaml deploy/parts/service_account.yaml deploy/parts/role_binding.yaml deploy/parts/operator.yaml cat $^ > $@ + +config/manifests/bases/falcon-operator.clusterserviceversion.yaml: README.md + hack/update-manifest.sh $@ $^ diff --git a/bundle/manifests/falcon-operator.clusterserviceversion.yaml b/bundle/manifests/falcon-operator.clusterserviceversion.yaml index fbc7daa1..58b7d163 100644 --- a/bundle/manifests/falcon-operator.clusterserviceversion.yaml +++ b/bundle/manifests/falcon-operator.clusterserviceversion.yaml @@ -52,7 +52,7 @@ spec: kind: FalconNodeSensor name: falconnodesensors.falcon.crowdstrike.com version: v1alpha1 - description: | + description: |- Falcon Operator installs CrowdStrike Falcon Container Sensor on the cluster. Falcon Operator is an open source project, not a CrowdStrike product. As such it carries no formal support, expressed or implied. diff --git a/config/manifests/bases/falcon-operator.clusterserviceversion.yaml b/config/manifests/bases/falcon-operator.clusterserviceversion.yaml index 5bee5933..b0b83d5f 100644 --- a/config/manifests/bases/falcon-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/falcon-operator.clusterserviceversion.yaml @@ -26,7 +26,7 @@ spec: kind: FalconNodeSensor name: falconnodesensors.falcon.crowdstrike.com version: v1alpha1 - description: | + description: |- Falcon Operator installs CrowdStrike Falcon Container Sensor on the cluster. Falcon Operator is an open source project, not a CrowdStrike product. As such it carries no formal support, expressed or implied. diff --git a/hack/update-manifest.sh b/hack/update-manifest.sh new file mode 100755 index 00000000..30bbd044 --- /dev/null +++ b/hack/update-manifest.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e -o pipefail + +readme="${2}" +last_banner_line=$(cat $readme | grep --line-number '\[!\[' | tail -n 1 | sed 's/:.*$//g') +let "first_readme_line=last_banner_line+1" +export content="$(tail -n +${first_readme_line} ${readme} | sed 's/(docs\//(https:\/\/github.com\/CrowdStrike\/falcon-operator\/tree\/main\/docs\//g' )" +yq -i e '.spec.description=strenv(content)' "${1}" +operator-sdk generate kustomize manifests -q