Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use oc kustomize instead of kustomize to build the docs #897

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ docs-clean:
rm -r docs_build

.PHONY: docs-examples
docs-kustomize-examples: export KUSTOMIZE_VERSION=v5.0.1
docs-kustomize-examples: yq kustomize ## Generate updated docs from examples using kustomize
KUSTOMIZE=$(KUSTOMIZE) LOCALBIN=$(LOCALBIN) ./docs/kustomize_to_docs.sh
docs-kustomize-examples: oc yq ## Generate updated docs from examples using kustomize
LOCALBIN=$(LOCALBIN) ./docs/kustomize_to_docs.sh

##@ General

Expand Down Expand Up @@ -270,6 +269,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.11.1
CRD_MARKDOWN_VERSION ?= v0.0.3
KUTTL_VERSION ?= 0.17.0
GOTOOLCHAIN_VERSION ?= go1.21.0
OC_VERSION ?= 4.14.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down Expand Up @@ -363,11 +363,17 @@ endif
endif

.PHONY: yq
yq: ## Download and install yq in local env
yq: $(LOCALBIN) ## Download and install yq in local env
test -s $(LOCALBIN)/yq || ( cd $(LOCALBIN) &&\
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64.tar.gz -O - |\
tar xz && mv yq_linux_amd64 $(LOCALBIN)/yq )

.PHONY: oc
oc: $(LOCALBIN) ## Download and install oc in local env
test -s $(LOCALBIN)/oc || ( cd $(LOCALBIN) &&\
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/$(OC_VERSION)/openshift-client-linux-$(OC_VERSION).tar.gz -O - |\
tar xz)

# Build make variables to export for shell
MAKE_ENV := $(shell echo '$(.VARIABLES)' | awk -v RS=' ' '/^(IMAGE)|.*?(REGISTRY)$$/')
SHELL_EXPORT = $(foreach v,$(MAKE_ENV),$(v)='$($(v))')
Expand Down
4 changes: 2 additions & 2 deletions docs/kustomize_to_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BAREMETAL=docs/assemblies/ref_example-OpenStackDataPlaneNodeSet-CR-for-bare-meta
FOOTER=$(sed '0,/----/d' $BAREMETAL | sed -e '0,/----/d')
sed -i '/----/q' $BAREMETAL
sed -i 's/preprovisioned/baremetal/' config/samples/dataplane/no_vars_from/kustomization.yaml
$KUSTOMIZE --load-restrictor LoadRestrictionsNone build config/samples/dataplane/no_vars_from | $LOCALBIN/yq ' select(.kind == "OpenStackDataPlaneNodeSet")' >> $BAREMETAL
$LOCALBIN/oc kustomize --load-restrictor LoadRestrictionsNone config/samples/dataplane/no_vars_from | $LOCALBIN/yq ' select(.kind == "OpenStackDataPlaneNodeSet")' >> $BAREMETAL
sed -i 's/\/baremetal/\/preprovisioned/' config/samples/dataplane/no_vars_from/kustomization.yaml
echo -e "----\n$FOOTER" >> $BAREMETAL

Expand All @@ -32,7 +32,7 @@ done
PREPROVISIONED=docs/assemblies/ref_example-OpenStackDataPlaneNodeSet-CR-for-preprovisioned-nodes.adoc
FOOTER=$(sed '0,/----/d' $PREPROVISIONED | sed -e '0,/----/d')
sed -i '/----/q' $PREPROVISIONED
$KUSTOMIZE --load-restrictor LoadRestrictionsNone build config/samples/dataplane/no_vars_from | $LOCALBIN/yq ' select(.kind == "OpenStackDataPlaneNodeSet")' >> $PREPROVISIONED
$LOCALBIN/oc kustomize --load-restrictor LoadRestrictionsNone config/samples/dataplane/no_vars_from | $LOCALBIN/yq ' select(.kind == "OpenStackDataPlaneNodeSet")' >> $PREPROVISIONED
echo -e "----\n$FOOTER" >> $PREPROVISIONED

COUNT=1
Expand Down
Loading