From 83f8c2fb916cf369552bce2f0572b81378688bc6 Mon Sep 17 00:00:00 2001 From: yati1998 Date: Mon, 14 Aug 2023 09:50:09 +0530 Subject: [PATCH 01/15] collect events in a sorted order This commit is to collect the events in sorted order and also collect yamls and describe of oc events resource Signed-off-by: yati1998 --- must-gather/collection-scripts/gather_namespaced_resources | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/must-gather/collection-scripts/gather_namespaced_resources b/must-gather/collection-scripts/gather_namespaced_resources index 03b1681..6bb0101 100755 --- a/must-gather/collection-scripts/gather_namespaced_resources +++ b/must-gather/collection-scripts/gather_namespaced_resources @@ -41,7 +41,6 @@ commands_get+=("subscription") commands_get+=("csv") commands_get+=("catalogsource") commands_get+=("installplan") -commands_get+=("events") commands_get+=("all -o wide") commands_get+=("role") commands_get+=("hpa") @@ -113,6 +112,12 @@ done { oc get storagesystem -n "${INSTALL_NAMESPACE}" -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/storagesystem.yaml" 2>&1 { oc get storageconsumer -n "${INSTALL_NAMESPACE}" -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/storageconsumer.yaml" 2>&1 +# Collect oc get events with sorted timestamp +dbglog "collecting output of oc get events with sorted timestamp" +{ oc get event -o custom-columns="LAST SEEN:{lastTimestamp},FIRST SEEN:{firstTimestamp},COUNT:{count},NAME:{metadata.name},KIND:{involvedObject.kind},SUBOBJECT:{involvedObject.fieldPath},TYPE:{type},REASON:{reason},SOURCE:{source.component},MESSAGE:{message}" --sort-by=lastTimestamp -nopenshift-storage; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_get" 2>&1 +{ oc describe events -n openshift-storage --sort-by=lastTimestamp; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc" 2>&1 +{ oc get events -n openshift-storage -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_yaml" 2>&1 + # Create the dir for data from all namespaces mkdir -p "${BASE_COLLECTION_PATH}/namespaces/all/" From f585902f0b7063f8df1595afb1c28a3d41ff6ee1 Mon Sep 17 00:00:00 2001 From: yati1998 Date: Fri, 25 Aug 2023 11:32:06 +0530 Subject: [PATCH 02/15] remove sort-by flag from events desc This commit removes the sort-by flag from oc describe events collection Signed-off-by: yati1998 --- must-gather/collection-scripts/gather_namespaced_resources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/must-gather/collection-scripts/gather_namespaced_resources b/must-gather/collection-scripts/gather_namespaced_resources index 6bb0101..a7bc3c5 100755 --- a/must-gather/collection-scripts/gather_namespaced_resources +++ b/must-gather/collection-scripts/gather_namespaced_resources @@ -115,7 +115,7 @@ done # Collect oc get events with sorted timestamp dbglog "collecting output of oc get events with sorted timestamp" { oc get event -o custom-columns="LAST SEEN:{lastTimestamp},FIRST SEEN:{firstTimestamp},COUNT:{count},NAME:{metadata.name},KIND:{involvedObject.kind},SUBOBJECT:{involvedObject.fieldPath},TYPE:{type},REASON:{reason},SOURCE:{source.component},MESSAGE:{message}" --sort-by=lastTimestamp -nopenshift-storage; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_get" 2>&1 -{ oc describe events -n openshift-storage --sort-by=lastTimestamp; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc" 2>&1 +{ oc describe events -n openshift-storage; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc" 2>&1 { oc get events -n openshift-storage -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_yaml" 2>&1 # Create the dir for data from all namespaces From 505c9611ba04a748c1290b2a4a15437293f94240 Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Mon, 28 Aug 2023 11:47:44 +0530 Subject: [PATCH 03/15] [gather-ns-resources] Delimit BASE_COLLECTION_PATH and add missing space after the namespace flag. Signed-off-by: black-dragon74 --- .../collection-scripts/gather_namespaced_resources | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/must-gather/collection-scripts/gather_namespaced_resources b/must-gather/collection-scripts/gather_namespaced_resources index a7bc3c5..b1583be 100755 --- a/must-gather/collection-scripts/gather_namespaced_resources +++ b/must-gather/collection-scripts/gather_namespaced_resources @@ -108,15 +108,15 @@ for INSTALL_NAMESPACE in $PRODUCT_NAMESPACE $INSTALL_NAMESPACES $MANAGED_FUSION_ done # NOTE: This is a temporary fix for collecting the storagecluster as we are not able to collect the storagecluster using the inspect command -{ oc get storageclusters -n "${INSTALL_NAMESPACE}" -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/storagecluster.yaml" 2>&1 -{ oc get storagesystem -n "${INSTALL_NAMESPACE}" -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/storagesystem.yaml" 2>&1 -{ oc get storageconsumer -n "${INSTALL_NAMESPACE}" -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/storageconsumer.yaml" 2>&1 +{ oc get storageclusters -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storagecluster.yaml" 2>&1 +{ oc get storagesystem -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storagesystem.yaml" 2>&1 +{ oc get storageconsumer -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storageconsumer.yaml" 2>&1 # Collect oc get events with sorted timestamp dbglog "collecting output of oc get events with sorted timestamp" -{ oc get event -o custom-columns="LAST SEEN:{lastTimestamp},FIRST SEEN:{firstTimestamp},COUNT:{count},NAME:{metadata.name},KIND:{involvedObject.kind},SUBOBJECT:{involvedObject.fieldPath},TYPE:{type},REASON:{reason},SOURCE:{source.component},MESSAGE:{message}" --sort-by=lastTimestamp -nopenshift-storage; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_get" 2>&1 -{ oc describe events -n openshift-storage; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc" 2>&1 -{ oc get events -n openshift-storage -o yaml; } >"$BASE_COLLECTION_PATH/namespaces/${INSTALL_NAMESPACE}/oc_output/events_yaml" 2>&1 +{ oc get event -o custom-columns="LAST SEEN:{lastTimestamp},FIRST SEEN:{firstTimestamp},COUNT:{count},NAME:{metadata.name},KIND:{involvedObject.kind},SUBOBJECT:{involvedObject.fieldPath},TYPE:{type},REASON:{reason},SOURCE:{source.component},MESSAGE:{message}" --sort-by=lastTimestamp -n openshift-storage; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_get" 2>&1 +{ oc describe events -n openshift-storage; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc" 2>&1 +{ oc get events -n openshift-storage -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_yaml" 2>&1 # Create the dir for data from all namespaces mkdir -p "${BASE_COLLECTION_PATH}/namespaces/all/" From 172586dda57c992b90911ce88a2c771bc763b8e0 Mon Sep 17 00:00:00 2001 From: Manish M Yathnalli Date: Tue, 5 Sep 2023 17:10:55 +0530 Subject: [PATCH 04/15] Fix readme to point to correct must gather image * The image pointed to did not exist. * Signed-off-by: Manish M Yathnalli --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71e64fa..ebd9bd1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ that expands its capabilities to gather Openshift Container Storage for informat ### Usage ```sh -oc adm must-gather --image=quay.io/rhceph-dev/odf4-odf-must-gather-rhel9:latest-4.13 +oc adm must-gather --image=registry.redhat.io/odf4/odf-must-gather-rhel9:v4.13 ``` The command above will create a local directory with a dump of the ocs state. From 465deb9897ba992481176c53d543744d87c14940 Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Thu, 21 Sep 2023 16:45:07 +0530 Subject: [PATCH 05/15] [ci] Fix github workflows Signed-off-by: black-dragon74 --- .github/workflows/odf-must-gather-ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/odf-must-gather-ci.yaml b/.github/workflows/odf-must-gather-ci.yaml index c872c60..206dfbb 100644 --- a/.github/workflows/odf-must-gather-ci.yaml +++ b/.github/workflows/odf-must-gather-ci.yaml @@ -18,6 +18,8 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master + with: + scandir: './collection-scripts' env: SHELLCHECK_OPTS: -e SC2181 @@ -34,4 +36,5 @@ jobs: check_filenames: true check_hidden: true ignore_words_list: xdescribe,contails,shouldnot + path: collection-scripts From c270f5d343d9373fee018bd39b9cc7571bc79a37 Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Thu, 21 Sep 2023 16:31:53 +0530 Subject: [PATCH 06/15] [refrac] Use go build tools for building Necessary changes required for ci-operator integration. This patch should be merged before merging the one in the openshift/release repo. This patch does not modify any of the exisiting functionality. Signed-off-by: black-dragon74 --- .ci-operator.yaml | 4 + Dockerfile | 17 ++ Makefile | 30 +-- .../gather | 0 .../gather_ceph_resources | 0 .../gather_clusterscoped_resources | 0 .../gather_common_ceph_resources | 0 .../gather_namespaced_resources | 0 .../gather_noobaa_resources | 0 .../post-uninstall.sh | 0 .../pre-install.sh | 0 .../utils.sh | 0 .../functests => functests}/functests.sh | 0 .../integration/command_output_test.sh | 0 go.mod | 5 + go.sum | 2 + must-gather/Dockerfile | 9 - pkg/tools/tools.go | 7 + .../templates => templates}/noobaa.template | 0 .../templates => templates}/pod.template | 0 .../build-machinery-go/.ci-operator.yaml | 4 + .../Dockerfile.commitchecker | 14 ++ .../openshift/build-machinery-go/LICENSE | 201 ++++++++++++++++++ .../openshift/build-machinery-go/Makefile | 57 +++++ .../openshift/build-machinery-go/OWNERS | 9 + .../openshift/build-machinery-go/README.md | 44 ++++ .../openshift/build-machinery-go/doc.go | 14 ++ .../make/default.example.mk | 40 ++++ .../make/default.example.mk.help.log | 27 +++ .../build-machinery-go/make/default.mk | 17 ++ .../openshift/build-machinery-go/make/doc.go | 3 + .../build-machinery-go/make/golang.example.mk | 14 ++ .../make/golang.example.mk.help.log | 16 ++ .../build-machinery-go/make/golang.mk | 22 ++ .../build-machinery-go/make/lib/doc.go | 3 + .../build-machinery-go/make/lib/golang.mk | 69 ++++++ .../build-machinery-go/make/lib/tmp.mk | 2 + .../build-machinery-go/make/lib/version.mk | 14 ++ .../make/operator.example.mk | 42 ++++ .../make/operator.example.mk.help.log | 34 +++ .../build-machinery-go/make/operator.mk | 4 + .../build-machinery-go/make/targets/doc.go | 3 + .../make/targets/golang/build.mk | 24 +++ .../make/targets/golang/doc.go | 3 + .../make/targets/golang/test-unit.mk | 14 ++ .../make/targets/golang/verify-update.mk | 31 +++ .../make/targets/golang/version.mk | 58 +++++ .../make/targets/golang/vulncheck.mk | 31 +++ .../build-machinery-go/make/targets/help.mk | 6 + .../make/targets/openshift/bindata.mk | 65 ++++++ .../make/targets/openshift/codegen.mk | 41 ++++ .../make/targets/openshift/controller-gen.mk | 44 ++++ .../make/targets/openshift/crd-schema-gen.mk | 109 ++++++++++ .../make/targets/openshift/deps-glide.mk | 34 +++ .../make/targets/openshift/deps-gomod.mk | 36 ++++ .../make/targets/openshift/deps.mk | 15 ++ .../make/targets/openshift/doc.go | 3 + .../make/targets/openshift/imagebuilder.mk | 25 +++ .../make/targets/openshift/images.mk | 33 +++ .../make/targets/openshift/kustomize.mk | 32 +++ .../make/targets/openshift/operator/doc.go | 3 + .../openshift/operator/profile-manifests.mk | 80 +++++++ .../targets/openshift/operator/release.mk | 7 + .../openshift/operator/telepresence.mk | 11 + .../make/targets/openshift/rpm.mk | 38 ++++ .../make/targets/openshift/yaml-patch.mk | 32 +++ .../make/targets/openshift/yq.mk | 32 +++ .../build-machinery-go/scripts/doc.go | 3 + .../scripts/run-telepresence.sh | 195 +++++++++++++++++ .../build-machinery-go/scripts/update-deps.sh | 27 +++ .../build-machinery-go/scripts/vulncheck.sh | 22 ++ vendor/modules.txt | 10 + 72 files changed, 1768 insertions(+), 23 deletions(-) create mode 100644 .ci-operator.yaml create mode 100644 Dockerfile rename {must-gather/collection-scripts => collection-scripts}/gather (100%) rename {must-gather/collection-scripts => collection-scripts}/gather_ceph_resources (100%) rename {must-gather/collection-scripts => collection-scripts}/gather_clusterscoped_resources (100%) rename {must-gather/collection-scripts => collection-scripts}/gather_common_ceph_resources (100%) rename {must-gather/collection-scripts => collection-scripts}/gather_namespaced_resources (100%) rename {must-gather/collection-scripts => collection-scripts}/gather_noobaa_resources (100%) rename {must-gather/collection-scripts => collection-scripts}/post-uninstall.sh (100%) rename {must-gather/collection-scripts => collection-scripts}/pre-install.sh (100%) rename {must-gather/collection-scripts => collection-scripts}/utils.sh (100%) rename {must-gather/functests => functests}/functests.sh (100%) rename {must-gather/functests => functests}/integration/command_output_test.sh (100%) create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 must-gather/Dockerfile create mode 100644 pkg/tools/tools.go rename {must-gather/templates => templates}/noobaa.template (100%) rename {must-gather/templates => templates}/pod.template (100%) create mode 100644 vendor/github.com/openshift/build-machinery-go/.ci-operator.yaml create mode 100644 vendor/github.com/openshift/build-machinery-go/Dockerfile.commitchecker create mode 100644 vendor/github.com/openshift/build-machinery-go/LICENSE create mode 100644 vendor/github.com/openshift/build-machinery-go/Makefile create mode 100644 vendor/github.com/openshift/build-machinery-go/OWNERS create mode 100644 vendor/github.com/openshift/build-machinery-go/README.md create mode 100644 vendor/github.com/openshift/build-machinery-go/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/default.example.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/default.example.mk.help.log create mode 100644 vendor/github.com/openshift/build-machinery-go/make/default.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/golang.example.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/golang.example.mk.help.log create mode 100644 vendor/github.com/openshift/build-machinery-go/make/golang.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/lib/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/lib/tmp.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/lib/version.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/operator.example.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/operator.example.mk.help.log create mode 100644 vendor/github.com/openshift/build-machinery-go/make/operator.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/golang/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/golang/test-unit.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/golang/verify-update.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/golang/vulncheck.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/help.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/codegen.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/controller-gen.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/crd-schema-gen.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-glide.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-gomod.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/imagebuilder.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/images.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/kustomize.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/profile-manifests.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/release.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/telepresence.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/rpm.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yaml-patch.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yq.mk create mode 100644 vendor/github.com/openshift/build-machinery-go/scripts/doc.go create mode 100644 vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh create mode 100644 vendor/github.com/openshift/build-machinery-go/scripts/update-deps.sh create mode 100644 vendor/github.com/openshift/build-machinery-go/scripts/vulncheck.sh create mode 100644 vendor/modules.txt diff --git a/.ci-operator.yaml b/.ci-operator.yaml new file mode 100644 index 0000000..5973e0a --- /dev/null +++ b/.ci-operator.yaml @@ -0,0 +1,4 @@ +build_root_image: + name: release + namespace: openshift + tag: rhel-8-release-golang-1.20-openshift-4.14 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5eb0f40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# Builder stage +FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.20-openshift-4.14 AS builder +WORKDIR /go/src/github.com/red-hat-storage/odf-must-gather + +COPY . . +ENV GO_PACKAGE github.com/red-hat-storage/odf-must-gather + +# Prod stage +FROM registry.ci.openshift.org/ocp/4.14:cli + +RUN mkdir -p /templates +COPY --from=builder /go/src/github.com/red-hat-storage/odf-must-gather/collection-scripts/* /usr/bin/ +COPY --from=builder /go/src/github.com/red-hat-storage/odf-must-gather/templates/* /templates + +RUN yum install --setopt=tsflags=nodocs -y jq && yum clean all && rm -rf /var/cache/yum/* + +ENTRYPOINT /usr/bin/gather \ No newline at end of file diff --git a/Makefile b/Makefile index b9a38b8..159d083 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,20 @@ -IMAGE_REGISTRY ?= "quay.io" -REGISTRY_NAMESPACE ?= "ocs-dev" -IMAGE_TAG ?= "latest" -MUST_GATHER_IMAGE_NAME ?= "ocs-must-gather" +all: images +.PHONY: all -MUST_GATHER_IMAGE_NAME ?= $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/$(MUST_GATHER_IMAGE_NAME):$(IMAGE_TAG) +# Include the library makefile +include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \ + golang.mk \ + targets/openshift/images.mk \ +) -OCS_MUST_GATHER_DIR ?= "${OCS_MUST_GATHER_DIR:-ocs-must-gather}" -OCP_MUST_GATHER_DIR ?= "${OCP_MUST_GATHER_DIR:-ocp-must-gather}" +IMAGE_REGISTRY :=registry.svc.ci.openshift.org -PLATFORM ?= "docker" +# This will call a macro called "build-image" which will generate image specific targets based on the parameters: +# $0 - macro name +# $1 - target name +# $2 - image ref +# $3 - Dockerfile path +# $4 - context directory for image build +$(call build-image,odf-must-gather,$(IMAGE_REGISTRY)/ocp/4.14:odf-must-gather, ./Dockerfile,.) -.PHONY: \ - odf-must-gather - -odf-must-gather: - @echo "Building the ocs-must-gather image" - ${PLATFORM} build -f must-gather/Dockerfile -t ${MUST_GATHER_IMAGE_NAME} must-gather/ +$(call verify-golang-versions,Dockerfile) \ No newline at end of file diff --git a/must-gather/collection-scripts/gather b/collection-scripts/gather similarity index 100% rename from must-gather/collection-scripts/gather rename to collection-scripts/gather diff --git a/must-gather/collection-scripts/gather_ceph_resources b/collection-scripts/gather_ceph_resources similarity index 100% rename from must-gather/collection-scripts/gather_ceph_resources rename to collection-scripts/gather_ceph_resources diff --git a/must-gather/collection-scripts/gather_clusterscoped_resources b/collection-scripts/gather_clusterscoped_resources similarity index 100% rename from must-gather/collection-scripts/gather_clusterscoped_resources rename to collection-scripts/gather_clusterscoped_resources diff --git a/must-gather/collection-scripts/gather_common_ceph_resources b/collection-scripts/gather_common_ceph_resources similarity index 100% rename from must-gather/collection-scripts/gather_common_ceph_resources rename to collection-scripts/gather_common_ceph_resources diff --git a/must-gather/collection-scripts/gather_namespaced_resources b/collection-scripts/gather_namespaced_resources similarity index 100% rename from must-gather/collection-scripts/gather_namespaced_resources rename to collection-scripts/gather_namespaced_resources diff --git a/must-gather/collection-scripts/gather_noobaa_resources b/collection-scripts/gather_noobaa_resources similarity index 100% rename from must-gather/collection-scripts/gather_noobaa_resources rename to collection-scripts/gather_noobaa_resources diff --git a/must-gather/collection-scripts/post-uninstall.sh b/collection-scripts/post-uninstall.sh similarity index 100% rename from must-gather/collection-scripts/post-uninstall.sh rename to collection-scripts/post-uninstall.sh diff --git a/must-gather/collection-scripts/pre-install.sh b/collection-scripts/pre-install.sh similarity index 100% rename from must-gather/collection-scripts/pre-install.sh rename to collection-scripts/pre-install.sh diff --git a/must-gather/collection-scripts/utils.sh b/collection-scripts/utils.sh similarity index 100% rename from must-gather/collection-scripts/utils.sh rename to collection-scripts/utils.sh diff --git a/must-gather/functests/functests.sh b/functests/functests.sh similarity index 100% rename from must-gather/functests/functests.sh rename to functests/functests.sh diff --git a/must-gather/functests/integration/command_output_test.sh b/functests/integration/command_output_test.sh similarity index 100% rename from must-gather/functests/integration/command_output_test.sh rename to functests/integration/command_output_test.sh diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..95e1848 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/red-hat-storage/odf-must-gather + +go 1.20 + +require github.com/openshift/build-machinery-go v0.0.0-20230824093055-6a18da01283c diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..efbf435 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/openshift/build-machinery-go v0.0.0-20230824093055-6a18da01283c h1:H5k87xq6hGgR1YCF/8hLv3j5jWd64Eh3ZhqF9WUJ15Q= +github.com/openshift/build-machinery-go v0.0.0-20230824093055-6a18da01283c/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= diff --git a/must-gather/Dockerfile b/must-gather/Dockerfile deleted file mode 100644 index ff5b8f6..0000000 --- a/must-gather/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM quay.io/openshift/origin-cli:latest - -# copy all collection scripts to /usr/bin -COPY collection-scripts /usr/bin/ - -RUN mkdir -p /templates -COPY templates /templates - -ENTRYPOINT /usr/bin/gather diff --git a/pkg/tools/tools.go b/pkg/tools/tools.go new file mode 100644 index 0000000..de3f8c8 --- /dev/null +++ b/pkg/tools/tools.go @@ -0,0 +1,7 @@ +// *build tools + +package tools + +import ( + _ "github.com/openshift/build-machinery-go" +) \ No newline at end of file diff --git a/must-gather/templates/noobaa.template b/templates/noobaa.template similarity index 100% rename from must-gather/templates/noobaa.template rename to templates/noobaa.template diff --git a/must-gather/templates/pod.template b/templates/pod.template similarity index 100% rename from must-gather/templates/pod.template rename to templates/pod.template diff --git a/vendor/github.com/openshift/build-machinery-go/.ci-operator.yaml b/vendor/github.com/openshift/build-machinery-go/.ci-operator.yaml new file mode 100644 index 0000000..00d7adf --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/.ci-operator.yaml @@ -0,0 +1,4 @@ +build_root_image: + name: release + namespace: openshift + tag: rhel-8-release-golang-1.17-openshift-4.10 diff --git a/vendor/github.com/openshift/build-machinery-go/Dockerfile.commitchecker b/vendor/github.com/openshift/build-machinery-go/Dockerfile.commitchecker new file mode 100644 index 0000000..334e492 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/Dockerfile.commitchecker @@ -0,0 +1,14 @@ +# This Dockerfile must be on the top-level of this repo, because it needs to copy +# both commitchecker/ and make/ into the build container. + +FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.20-openshift-4.14 AS builder +WORKDIR /go/src/github.com/openshift/build-machinery-go +COPY . . +RUN make -C commitchecker + +FROM registry.ci.openshift.org/ocp/4.14:base +COPY --from=builder /go/src/github.com/openshift/build-machinery-go/commitchecker/commitchecker /usr/bin/ +RUN yum update -y && \ + yum install --setopt=tsflags=nodocs -y git && \ + yum clean all && rm -rf /var/cache/yum/* +ENTRYPOINT ["/usr/bin/commitchecker"] diff --git a/vendor/github.com/openshift/build-machinery-go/LICENSE b/vendor/github.com/openshift/build-machinery-go/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/openshift/build-machinery-go/Makefile b/vendor/github.com/openshift/build-machinery-go/Makefile new file mode 100644 index 0000000..5dfb188 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/Makefile @@ -0,0 +1,57 @@ +SHELL :=/bin/bash +all: verify +.PHONY: all + +makefiles :=$(wildcard ./make/*.example.mk) +examples :=$(wildcard ./make/examples/*/Makefile.test) + +# $1 - makefile name relative to ./make/ folder +# $2 - target +# We need to change dir to the final makefile directory or relative paths won't match. +# Dynamic values are replaced with "" so we can do diff against checkout versions. +# Avoid comparing local paths by stripping the prefix. +# Delete lines referencing temporary files and directories +# Unify make error output between versions +# Ignore old cp errors on centos7 +# Ignore different make output with `-k` option +define update-makefile-log +set -o pipefail; $(MAKE) -j 1 -C "$(dir $(1))" -f "$(notdir $(1))" --no-print-directory --warn-undefined-variables $(2) > "$(1)$(subst ..,.,.$(2).log.raw)" 2>&1 || (cat "$(1)$(subst ..,.,.$(2).log.raw)" && exit 1) +sed 's/\.\(buildDate\|versionFromGit\|commitFromGit\|gitTreeState\)="[^"]*" /.\1="" /g' "$(1)$(subst ..,.,.$(2).log.raw)" | \ + sed -E 's~/[^ ]*/(github.com/openshift/build-machinery-go/[^ ]*)~/\1~g' | \ + sed '/\/tmp\/tmp./d' | \ + sed '/git checkout -b/d' | \ + sed -E 's~^[<> ]*((\+\+\+|\-\-\-) \./(testing/)?manifests/.*.yaml).*~\1~' | \ + sed -E 's/^(make\[2\]: \*\*\* \[).*: (.*\] Error 1)/\1\2/' | \ + grep -v 'are the same file' | \ + grep -E -v -e '^make\[2\]: Target `.*'"'"' not remade because of errors\.$$' \ + > "$(1)$(subst ..,.,.$(2).log)" + +endef + + +# $1 - makefile name relative to ./make/ folder +# $2 - target +define check-makefile-log +$(call update-makefile-log,$(1),$(2)) +git diff --exit-code + +endef + +update-makefiles: + $(foreach f,$(makefiles),$(call check-makefile-log,$(f),help)) + $(foreach f,$(examples),$(call check-makefile-log,$(f),)) +.PHONY: update-makefiles + +verify-makefiles: + $(foreach f,$(makefiles),$(call check-makefile-log,$(f),help)) + $(foreach f,$(examples),$(call check-makefile-log,$(f),)) +.PHONY: verify-makefiles + +verify: verify-makefiles +.PHONY: verify + +update: update-makefiles +.PHONY: update + + +include ./make/targets/help.mk diff --git a/vendor/github.com/openshift/build-machinery-go/OWNERS b/vendor/github.com/openshift/build-machinery-go/OWNERS new file mode 100644 index 0000000..e016cc3 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/OWNERS @@ -0,0 +1,9 @@ +reviewers: + - sttts + - mfojtik + - soltysh + - 2uasimojo +approvers: + - sttts + - mfojtik + - soltysh diff --git a/vendor/github.com/openshift/build-machinery-go/README.md b/vendor/github.com/openshift/build-machinery-go/README.md new file mode 100644 index 0000000..66862f6 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/README.md @@ -0,0 +1,44 @@ +# library-go/build-machinery-go +These are the building blocks for this and many of our other repositories to share code for Makefiles, helper scripts and other build related machinery. + +## Makefiles +`make/` directory contains several predefined makefiles `(*.mk)` to choose from and include one of them as a base in your final `Makefile`. These are the predefined flows providing you with e.g. `build`, `test` or `verify` targets. To start with it is recommended you base Makefile on the corresponding `*.example.mk` using copy&paste. + +As some advanced targets are generated, every Makefile contains `make help` target listing all the available ones. All of the "example" makefiles have a corresponding `.help` file listing all the targets available there. + +Also for advanced use and if none of the predefined flows doesn't fit your needs, you can compose the flow from modules in similar way to how the predefined flows do, + +### Golang +Standard makefile for building pure Golang projects. + - [make/golang.mk](make/golang.mk) + - [make/golang.example.mk](make/golang.example.mk) + - [make/golang.example.mk.help](make/golang.example.mk.help) + +### Default +Standard makefile for OpenShift Golang projects. + +Extends [#Golang](). + + - [make/default.mk](make/default.mk) + - [make/default.example.mk](make/default.example.mk) + - [make/default.example.mk.help](make/default.example.mk.help) + +### Operator +Standard makefile for OpenShift Golang projects. + +Extends [#Default](). + + - [make/operator.mk](make/operator.mk) + - [make/operator.example.mk](make/operator.example.mk) + - [make/operator.example.mk.help](make/operator.example.mk.help) + + +## Scripts +`scripts` contain more complicated logic that is used in some make targets. + +## Contributing +### Updating generated files +We track the log output from the makefile tests to make sure any change is visible and can be audited. Unfortunately due to subtle linux tooling differences in distributions and versions, `make update` may not get you the exact output as the CI. To avoid it, just run the command in the same container as CI: +``` +podman run -it --rm --pull=always -v $( pwd ):/go/src/$( go list -m ) --workdir=/go/src/$( go list -m ) registry.ci.openshift.org/openshift/release:rhel-8-release-golang-1.15-openshift-4.7 make update +``` diff --git a/vendor/github.com/openshift/build-machinery-go/doc.go b/vendor/github.com/openshift/build-machinery-go/doc.go new file mode 100644 index 0000000..17577ae --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/doc.go @@ -0,0 +1,14 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery + +// this is a dependency magnet to make it easier to pull in the build-machinery. We want a single import to pull all of it in. +import ( + _ "github.com/openshift/build-machinery-go/make" + _ "github.com/openshift/build-machinery-go/make/lib" + _ "github.com/openshift/build-machinery-go/make/targets" + _ "github.com/openshift/build-machinery-go/make/targets/golang" + _ "github.com/openshift/build-machinery-go/make/targets/openshift" + _ "github.com/openshift/build-machinery-go/make/targets/openshift/operator" + _ "github.com/openshift/build-machinery-go/scripts" +) diff --git a/vendor/github.com/openshift/build-machinery-go/make/default.example.mk b/vendor/github.com/openshift/build-machinery-go/make/default.example.mk new file mode 100644 index 0000000..fffc5b3 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/default.example.mk @@ -0,0 +1,40 @@ +all: build +.PHONY: all + +# You can customize go tools depending on the directory layout. +# example: +GO_BUILD_PACKAGES :=./pkg/... +# You can list all the golang related variables by: +# $ make -n --print-data-base | grep ^GO + +# Include the library makefile +include ./default.mk +# All the available targets are listed in .help +# or you can list it live by using `make help` + +# Codegen module needs setting these required variables +CODEGEN_OUTPUT_PACKAGE :=github.com/openshift/cluster-openshift-apiserver-operator/pkg/generated +CODEGEN_API_PACKAGE :=github.com/openshift/cluster-openshift-apiserver-operator/pkg/apis +CODEGEN_GROUPS_VERSION :=openshiftapiserver:v1alpha1 +# You can list all codegen related variables by: +# $ make -n --print-data-base | grep ^CODEGEN + +# This will call a macro called "build-image" which will generate image specific targets based on the parameters: +# $1 - target name +# $2 - image ref +# $3 - Dockerfile path +# $4 - context +# It will generate target "image-$(1)" for builing the image an binding it as a prerequisite to target "images". +$(call build-image,ocp-cli,registry.svc.ci.openshift.org/ocp/4.2:cli,./images/cli/Dockerfile.rhel,.) + +# This will call a macro called "add-bindata" which will generate bindata specific targets based on the parameters: +# $0 - macro name +# $1 - target suffix +# $2 - input dirs +# $3 - prefix +# $4 - pkg +# $5 - output +# It will generate targets {update,verify}-bindata-$(1) logically grouping them in unsuffixed versions of these targets +# and also hooked into {update,verify}-generated for broader integration. +$(call add-bindata,v3.11.0,./bindata/v3.11.0/...,bindata,v311_00_assets,pkg/operator/v311_00_assets/bindata.go) + diff --git a/vendor/github.com/openshift/build-machinery-go/make/default.example.mk.help.log b/vendor/github.com/openshift/build-machinery-go/make/default.example.mk.help.log new file mode 100644 index 0000000..713d8c7 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/default.example.mk.help.log @@ -0,0 +1,27 @@ +The following make targets are available: +all +build +clean +clean-binaries +ensure-imagebuilder +help +image-ocp-cli +images +test +test-unit +update +update-bindata +update-codegen +update-deps-overrides +update-generated +update-gofmt +verify +verify-bindata +verify-codegen +verify-deps +verify-generated +verify-gofmt +verify-golang-versions +verify-golint +verify-govet +vulncheck diff --git a/vendor/github.com/openshift/build-machinery-go/make/default.mk b/vendor/github.com/openshift/build-machinery-go/make/default.mk new file mode 100644 index 0000000..08cd6a1 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/default.mk @@ -0,0 +1,17 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + targets/openshift/deps.mk \ + targets/openshift/images.mk \ + targets/openshift/bindata.mk \ + targets/openshift/codegen.mk \ + golang.mk \ +) + +# We extend the default verify/update for Golang + +verify: verify-codegen +verify: verify-bindata +.PHONY: verify + +update: update-codegen +update: update-bindata +.PHONY: update diff --git a/vendor/github.com/openshift/build-machinery-go/make/doc.go b/vendor/github.com/openshift/build-machinery-go/make/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk b/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk new file mode 100644 index 0000000..aba2c48 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk @@ -0,0 +1,14 @@ +all: build +.PHONY: all + + +# You can customize go tools depending on the directory layout. +# example: +GO_BUILD_PACKAGES :=./pkg/... +# You can list all the golang related variables by: +# $ make -n --print-data-base | grep ^GO + +# Include the library makefile +include ./golang.mk +# All the available targets are listed in .help +# or you can list it live by using `make help` diff --git a/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk.help.log b/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk.help.log new file mode 100644 index 0000000..1265d97 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk.help.log @@ -0,0 +1,16 @@ +The following make targets are available: +all +build +clean +clean-binaries +help +test +test-unit +update +update-gofmt +verify +verify-gofmt +verify-golang-versions +verify-golint +verify-govet +vulncheck diff --git a/vendor/github.com/openshift/build-machinery-go/make/golang.mk b/vendor/github.com/openshift/build-machinery-go/make/golang.mk new file mode 100644 index 0000000..e0bb616 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/golang.mk @@ -0,0 +1,22 @@ +all: build +.PHONY: all + +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + targets/help.mk \ + targets/golang/*.mk \ +) + +verify: verify-gofmt +verify: verify-govet +verify: verify-golang-versions +.PHONY: verify + +update: update-gofmt +.PHONY: update + + +test: test-unit +.PHONY: test + +clean: clean-binaries +.PHONY: clean diff --git a/vendor/github.com/openshift/build-machinery-go/make/lib/doc.go b/vendor/github.com/openshift/build-machinery-go/make/lib/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/lib/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk b/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk new file mode 100644 index 0000000..d08f74a --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk @@ -0,0 +1,69 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + version.mk \ +) + +GO ?=go + +GOPATH ?=$(shell $(GO) env GOPATH) +GOOS ?=$(shell $(GO) env GOOS) +GOHOSTOS ?=$(shell $(GO) env GOHOSTOS) +GOARCH ?=$(shell $(GO) env GOARCH) +GOHOSTARCH ?=$(shell $(GO) env GOHOSTARCH) +GOEXE ?=$(shell $(GO) env GOEXE) +GOFLAGS ?=$(shell $(GO) env GOFLAGS) + +GOFMT ?=gofmt +GOFMT_FLAGS ?=-s -l +GOLINT ?=golint + +go_version :=$(shell $(GO) version | sed -E -e 's/.*go([0-9]+.[0-9]+(.[0-9]+)?).*/\1/') +GO_REQUIRED_MIN_VERSION ?=1.15.2 +ifneq "$(GO_REQUIRED_MIN_VERSION)" "" +$(call require_minimal_version,$(GO),GO_REQUIRED_MIN_VERSION,$(go_version)) +endif + +# Projects not using modules can clear the variable, but by default we want to prevent +# our projects with modules to unknowingly ignore vendor folder until golang is fixed to use +# vendor folder by default if present. +# +# Conditional to avoid Go 1.13 bug on false double flag https://github.com/golang/go/issues/32471 +# TODO: Drop the contitional when golang is fixed so we can see the flag being explicitelly set in logs. +ifeq "$(findstring -mod=vendor,$(GOFLAGS))" "-mod=vendor" +GO_MOD_FLAGS ?= +else +GO_MOD_FLAGS ?=-mod=vendor +endif + +GO_PACKAGE ?=$(shell $(GO) list $(GO_MOD_FLAGS) -m -f '{{ .Path }}' || echo 'no_package_detected') +GO_PACKAGES ?=./... +GO_TEST_PACKAGES ?=$(GO_PACKAGES) +GO_FILES ?=$(shell find . -name '*.go' -not -path '*/vendor/*' -not -path '*/_output/*' -print) + + +GO_BUILD_PACKAGES ?=./cmd/... +GO_BUILD_PACKAGES_EXPANDED ?=$(shell $(GO) list $(GO_MOD_FLAGS) $(GO_BUILD_PACKAGES)) +go_build_binaries =$(notdir $(GO_BUILD_PACKAGES_EXPANDED)) +GO_BUILD_FLAGS ?=-trimpath +GO_BUILD_BINDIR ?= + +GO_TEST_FLAGS ?=-race + +GO_LD_EXTRAFLAGS ?= + +SOURCE_GIT_TAG ?=$(shell git describe --long --tags --abbrev=7 --match 'v[0-9]*' || echo 'v0.0.0-unknown-$(SOURCE_GIT_COMMIT)') +SOURCE_GIT_COMMIT ?=$(shell git rev-parse --short "HEAD^{commit}" 2>/dev/null) +SOURCE_GIT_TREE_STATE ?=$(shell ( ( [ ! -d ".git/" ] || git diff --quiet ) && echo 'clean' ) || echo 'dirty') + +# OS_GIT_VERSION is populated by ART +# If building out of the ART pipeline, fallback to SOURCE_GIT_TAG +ifndef OS_GIT_VERSION + OS_GIT_VERSION = $(SOURCE_GIT_TAG) +endif + +define version-ldflags +-X $(1).versionFromGit="$(OS_GIT_VERSION)" \ +-X $(1).commitFromGit="$(SOURCE_GIT_COMMIT)" \ +-X $(1).gitTreeState="$(SOURCE_GIT_TREE_STATE)" \ +-X $(1).buildDate="$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')" +endef +GO_LD_FLAGS ?=-ldflags "$(call version-ldflags,$(GO_PACKAGE)/pkg/version) $(GO_LD_EXTRAFLAGS)" diff --git a/vendor/github.com/openshift/build-machinery-go/make/lib/tmp.mk b/vendor/github.com/openshift/build-machinery-go/make/lib/tmp.mk new file mode 100644 index 0000000..a0fb655 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/lib/tmp.mk @@ -0,0 +1,2 @@ +PERMANENT_TMP :=_output +PERMANENT_TMP_GOPATH :=$(PERMANENT_TMP)/tools diff --git a/vendor/github.com/openshift/build-machinery-go/make/lib/version.mk b/vendor/github.com/openshift/build-machinery-go/make/lib/version.mk new file mode 100644 index 0000000..66d03ea --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/lib/version.mk @@ -0,0 +1,14 @@ +# $1 - required version +# $2 - current version +define is_equal_or_higher_version +$(strip $(filter $(2),$(firstword $(shell set -euo pipefail && printf '%s\n%s' '$(1)' '$(2)' | sort -V -r -b)))) +endef + +# $1 - program name +# $2 - required version variable name +# $3 - current version string +define require_minimal_version +$(if $($(2)),\ +$(if $(strip $(call is_equal_or_higher_version,$($(2)),$(3))),,$(error `$(1)` is required with minimal version "$($(2))", detected version "$(3)". You can override this check by using `make $(2):=`)),\ +) +endef diff --git a/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk b/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk new file mode 100644 index 0000000..7e6ff98 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk @@ -0,0 +1,42 @@ +all: build +.PHONY: all + + +# You can customize go tools depending on the directory layout. +# example: +GO_BUILD_PACKAGES :=./pkg/... +# You can list all the golang related variables by: +# $ make -n --print-data-base | grep ^GO + +# Include the library makefile +include ./operator.mk +# All the available targets are listed in .help +# or you can list it live by using `make help` + + +# Codegen module needs setting these required variables +CODEGEN_OUTPUT_PACKAGE :=github.com/openshift/cluster-openshift-apiserver-operator/pkg/generated +CODEGEN_API_PACKAGE :=github.com/openshift/cluster-openshift-apiserver-operator/pkg/apis +CODEGEN_GROUPS_VERSION :=openshiftapiserver:v1alpha1 +# You can list all codegen related variables by: +# $ make -n --print-data-base | grep ^CODEGEN + +# This will call a macro called "build-image" which will generate image specific targets based on the parameters: +# $1 - target name +# $2 - image ref +# $3 - Dockerfile path +# $4 - context +# It will generate target "image-$(1)" for builing the image an binding it as a prerequisite to target "images". +$(call build-image,ocp-openshift-apiserver-operator,registry.svc.ci.openshift.org/ocp/4.2:openshift-apiserver-operator,./Dockerfile.rhel,.) + +# This will call a macro called "add-bindata" which will generate bindata specific targets based on the parameters: +# $0 - macro name +# $1 - target suffix +# $2 - input dirs +# $3 - prefix +# $4 - pkg +# $5 - output +# It will generate targets {update,verify}-bindata-$(1) logically grouping them in unsuffixed versions of these targets +# and also hooked into {update,verify}-generated for broader integration. +$(call add-bindata,v3.11.0,./bindata/v3.11.0/...,bindata,v311_00_assets,pkg/operator/v311_00_assets/bindata.go) + diff --git a/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk.help.log b/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk.help.log new file mode 100644 index 0000000..47b04e6 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk.help.log @@ -0,0 +1,34 @@ +The following make targets are available: +all +build +clean +clean-binaries +clean-yaml-patch +clean-yq +ensure-imagebuilder +ensure-yaml-patch +ensure-yq +help +image-ocp-openshift-apiserver-operator +images +telepresence +test +test-unit +update +update-bindata +update-codegen +update-deps-overrides +update-generated +update-gofmt +update-profile-manifests +verify +verify-bindata +verify-codegen +verify-deps +verify-generated +verify-gofmt +verify-golang-versions +verify-golint +verify-govet +verify-profile-manifests +vulncheck diff --git a/vendor/github.com/openshift/build-machinery-go/make/operator.mk b/vendor/github.com/openshift/build-machinery-go/make/operator.mk new file mode 100644 index 0000000..549c1f4 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/operator.mk @@ -0,0 +1,4 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + default.mk \ + targets/openshift/operator/*.mk \ +) diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/doc.go b/vendor/github.com/openshift/build-machinery-go/make/targets/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk new file mode 100644 index 0000000..e13028b --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk @@ -0,0 +1,24 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ +) + +define build-package + $(if $(GO_BUILD_BINDIR),mkdir -p '$(GO_BUILD_BINDIR)',) + $(strip $(GO) build $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) \ + $(if $(GO_BUILD_BINDIR),-o '$(GO_BUILD_BINDIR)/$(notdir $(1))$(GOEXE)',) \ + $(1)) + +endef + +# We need to build each package separately so go build creates appropriate binaries +build: + $(if $(strip $(GO_BUILD_PACKAGES_EXPANDED)),,$(error no packages to build: GO_BUILD_PACKAGES_EXPANDED var is empty)) + $(foreach package,$(GO_BUILD_PACKAGES_EXPANDED),$(call build-package,$(package))) +.PHONY: build + +clean-binaries: + $(RM) $(go_build_binaries) +.PHONY: clean-binaries + +clean: clean-binaries +.PHONY: clean diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/doc.go b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/test-unit.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/test-unit.mk new file mode 100644 index 0000000..5b3fa52 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/test-unit.mk @@ -0,0 +1,14 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ +) + +test-unit: +ifndef JUNITFILE + $(GO) test $(GO_MOD_FLAGS) $(GO_TEST_FLAGS) $(GO_TEST_PACKAGES) $(GO_TEST_ARGS) +else +ifeq (, $(shell which gotest2junit 2>/dev/null)) + $(error gotest2junit not found! Get it by `go get -mod='' -u github.com/openshift/release/tools/gotest2junit`.) +endif + set -o pipefail; $(GO) test $(GO_MOD_FLAGS) $(GO_TEST_FLAGS) -json $(GO_TEST_PACKAGES) $(GO_TEST_ARGS) | gotest2junit > $(JUNITFILE) +endif +.PHONY: test-unit diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/verify-update.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/verify-update.mk new file mode 100644 index 0000000..3b71e29 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/verify-update.mk @@ -0,0 +1,31 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ +) + +go_files_count :=$(words $(GO_FILES)) + +verify-gofmt: + $(info Running `$(GOFMT) $(GOFMT_FLAGS)` on $(go_files_count) file(s).) + @TMP=$$( mktemp ); \ + $(GOFMT) $(GOFMT_FLAGS) $(GO_FILES) | tee $${TMP}; \ + if [ -s $${TMP} ]; then \ + echo "$@ failed - please run \`make update-gofmt\`"; \ + exit 1; \ + fi; +.PHONY: verify-gofmt + +update-gofmt: + $(info Running `$(GOFMT) $(GOFMT_FLAGS) -w` on $(go_files_count) file(s).) + @$(GOFMT) $(GOFMT_FLAGS) -w $(GO_FILES) +.PHONY: update-gofmt + + +# FIXME: go vet needs to use $(GO_MOD_FLAGS) when this is fixed https://github.com/golang/go/issues/35955 +# It will be enforced in CI by setting the env var there, so this remains to fix the dev experience +verify-govet: + $(GO) vet $(GO_MOD_FLAGS) $(GO_PACKAGES) +.PHONY: verify-govet + +verify-golint: + $(GOLINT) $(GO_PACKAGES) +.PHONY: verify-golint diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk new file mode 100644 index 0000000..f84ceb9 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/version.mk @@ -0,0 +1,58 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) + +.empty-golang-versions-files: + @rm -f "$(PERMANENT_TMP)/golang-versions" "$(PERMANENT_TMP)/named-golang-versions" +.PHONY: .empty-golang-versions-files + +verify-golang-versions: + @if [ -f "$(PERMANENT_TMP)/golang-versions" ]; then \ + LINES=$$(cat "$(PERMANENT_TMP)/golang-versions" | sort | uniq | wc -l); \ + if [ $${LINES} -gt 1 ]; then \ + echo "Golang version mismatch:"; \ + cat "$(PERMANENT_TMP)/named-golang-versions" | sort | sed 's/^/- /'; \ + false; \ + fi; \ + fi +.PHONY: verify-golang-versions + +# $1 - filename (symbolic, used as postfix in Makefile target) +# $2 - golang version +define verify-golang-version-reference-internal +verify-golang-versions-$(1): .empty-golang-versions-files +verify-golang-versions-$(1): + @mkdir -p "$(PERMANENT_TMP)" + @echo "$(1): $(2)" >> "$(PERMANENT_TMP)/named-golang-versions" + @echo "$(2)" >> "$(PERMANENT_TMP)/golang-versions" +.PHONY: verify-golang-versions-$(1) + +verify-golang-versions: verify-golang-versions-$(1) +endef + +# $1 - filename (symbolic, used as postfix in Makefile target) +# $2 - golang version +define verify-golang-version-reference +$(eval $(call verify-golang-version-reference-internal,$(1),$(2))) +endef + +# $1 - Dockerfile filename (symbolic, used as postfix in Makefile target) +define verify-Dockerfile-builder-golang-version +$(call verify-golang-version-reference,$(1),$(shell grep "AS builder" "$(1)" | sed 's/.*golang-\([[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*\).*/\1/')) +endef + +define verify-go-mod-golang-version +$(call verify-golang-version-reference,go.mod,$(shell grep -e 'go [[:digit:]]*\.[[:digit:]]*' go.mod 2>/dev/null | sed 's/go //')) +endef + +define verify-buildroot-golang-version +$(call verify-golang-version-reference,.ci-operator.yaml,$(shell grep -e 'tag: .*golang-[[:digit:]]*\.[[:digit:]]' .ci-operator.yaml 2>/dev/null | sed 's/.*golang-\([[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*\).*/\1/')) +endef + +# $1 - optional Dockerfile filename (symbolic, used as postfix in Makefile target) +define verify-golang-versions +$(if $(1),$(call verify-Dockerfile-builder-golang-version,$(1))) \ +$(if $(wildcard ./.ci-operator.yaml),$(if $(shell grep 'build_root_image:' .ci-operator.yaml 2>/dev/null),$(call verify-buildroot-golang-version))) \ +$(if $(wildcard ./go.mod),$(call verify-go-mod-golang-version)) +endef diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/golang/vulncheck.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/vulncheck.mk new file mode 100644 index 0000000..963a979 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/vulncheck.mk @@ -0,0 +1,31 @@ +scripts_dir :=$(shell realpath $(dir $(lastword $(MAKEFILE_LIST)))../../../scripts) + +# `make vulncheck` will emit a report similar to: +# +# [ +# "golang.org/x/net", +# "v0.5.0", +# "v0.7.0" +# ] +# [ +# "stdlib", +# "go1.19.3", +# "go1.20.1" +# ] +# [ +# "stdlib", +# "go1.19.3", +# "go1.19.4" +# ] +# +# Each stanza lists +# - where the vulnerability exists +# - the version it was found in +# - the version it's fixed in +# +# If the report contains any entries that are not in stdlib, the check +# will fail (exit nonzero). Otherwise it will succeed -- i.e. the stdlib +# entries are only warnings. +vulncheck: + bash $(scripts_dir)/vulncheck.sh +.PHONY: vulncheck diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/help.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/help.mk new file mode 100644 index 0000000..55bfbac --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/help.mk @@ -0,0 +1,6 @@ +help: + $(info The following make targets are available:) + @$(MAKE) -f $(firstword $(MAKEFILE_LIST)) --print-data-base --question no-such-target 2>&1 | grep -v 'no-such-target' | \ + grep -v -e '^no-such-target' -e '^makefile' | \ + awk '/^[^.%][-A-Za-z0-9_]*:/ { print substr($$1, 1, length($$1)-1) }' | sort -u +.PHONY: help diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk new file mode 100644 index 0000000..04b534a --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk @@ -0,0 +1,65 @@ +TMP_GOPATH :=$(shell mktemp -d) + + +.ensure-go-bindata: + ln -s $(abspath ./vendor) "$(TMP_GOPATH)/src" + export GO111MODULE=off && export GOPATH=$(TMP_GOPATH) && export GOBIN=$(TMP_GOPATH)/bin && go install "./vendor/github.com/go-bindata/go-bindata/..." + +# $1 - input dirs +# $2 - prefix +# $3 - pkg +# $4 - output +# $5 - output prefix +define run-bindata + $(TMP_GOPATH)/bin/go-bindata -nocompress -nometadata \ + -prefix "$(2)" \ + -pkg "$(3)" \ + -o "$(5)$(4)" \ + -ignore "OWNERS" \ + $(1) && \ + gofmt -s -w "$(5)$(4)" +endef + +# $1 - name +# $2 - input dirs +# $3 - prefix +# $4 - pkg +# $5 - output +define add-bindata-internal +update-bindata-$(1): .ensure-go-bindata + $(call run-bindata,$(2),$(3),$(4),$(5),) +.PHONY: update-bindata-$(1) + +update-bindata: update-bindata-$(1) +.PHONY: update-bindata + + +verify-bindata-$(1): .ensure-go-bindata +verify-bindata-$(1): TMP_DIR := $$(shell mktemp -d) +verify-bindata-$(1): + $(call run-bindata,$(2),$(3),$(4),$(5),$$(TMP_DIR)/) && \ + diff -Naup {.,$$(TMP_DIR)}/$(5) +.PHONY: verify-bindata-$(1) + +verify-bindata: verify-bindata-$(1) +.PHONY: verify-bindata +endef + + +update-generated: update-bindata +.PHONY: update-bindata + +update: update-generated +.PHONY: update + + +verify-generated: verify-bindata +.PHONY: verify-bindata + +verify: verify-generated +.PHONY: verify + + +define add-bindata +$(eval $(call add-bindata-internal,$(1),$(2),$(3),$(4),$(5))) +endef diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/codegen.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/codegen.mk new file mode 100644 index 0000000..247de94 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/codegen.mk @@ -0,0 +1,41 @@ +CODEGEN_PKG ?=./vendor/k8s.io/code-generator/ +CODEGEN_GENERATORS ?=all +CODEGEN_OUTPUT_BASE ?=../../.. +CODEGEN_GO_HEADER_FILE ?=/dev/null + +CODEGEN_API_PACKAGE ?=$(error CODEGEN_API_PACKAGE is required) +CODEGEN_GROUPS_VERSION ?=$(error CODEGEN_GROUPS_VERSION is required) +CODEGEN_OUTPUT_PACKAGE ?=$(error CODEGEN_OUTPUT_PACKAGE is required) + +define run-codegen +$(CODEGEN_PKG)/generate-groups.sh \ + "$(CODEGEN_GENERATORS)" \ + "$(CODEGEN_OUTPUT_PACKAGE)" \ + "$(CODEGEN_API_PACKAGE)" \ + "$(CODEGEN_GROUPS_VERSION)" \ + --output-base $(CODEGEN_OUTPUT_BASE) \ + --go-header-file $(CODEGEN_GO_HEADER_FILE) \ + $1 +endef + + +verify-codegen: + $(call run-codegen,--verify-only) +.PHONY: verify-codegen + +verify-generated: verify-codegen +.PHONY: verify-generated + +verify: verify-generated +.PHONY: verify + + +update-codegen: + $(call run-codegen) +.PHONY: update-codegen + +update-generated: update-codegen +.PHONY: update-generated + +update: update-generated +.PHONY: update diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/controller-gen.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/controller-gen.mk new file mode 100644 index 0000000..4e15c77 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/controller-gen.mk @@ -0,0 +1,44 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) + +# NOTE: The release binary specified here needs to be built properly so that +# `--version` works correctly. Just using `go build` will result in it +# reporting `(devel)`. To build for a given platform: +# GOOS=xxx GOARCH=yyy go install sigs.k8s.io/controller-tools/cmd/controller-gen@$version +# e.g. +# GOOS=darwin GOARCH=amd64 go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2 +# +# If GOOS and GOARCH match your current go env, this will install the binary at +# $(go env GOPATH)/bin/controller-gen +# Otherwise (when cross-compiling) it will install the binary at +# $(go env GOPATH)/bin/${GOOS}_${GOARCH}/conroller-gen +# e.g. +# /home/efried/.gvm/pkgsets/go1.16/global/bin/darwin_amd64/controller-gen +CONTROLLER_GEN_VERSION ?=v0.9.2 +CONTROLLER_GEN ?=$(PERMANENT_TMP_GOPATH)/bin/controller-gen-$(CONTROLLER_GEN_VERSION) +ifneq "" "$(wildcard $(CONTROLLER_GEN))" +_controller_gen_installed_version = $(shell $(CONTROLLER_GEN) --version | awk '{print $$2}') +endif +controller_gen_dir :=$(dir $(CONTROLLER_GEN)) + +ensure-controller-gen: +ifeq "" "$(wildcard $(CONTROLLER_GEN))" + $(info Installing controller-gen into '$(CONTROLLER_GEN)') + mkdir -p '$(controller_gen_dir)' + curl -s -f -L https://github.com/openshift/kubernetes-sigs-controller-tools/releases/download/$(CONTROLLER_GEN_VERSION)/controller-gen-$(GOHOSTOS)-$(GOHOSTARCH) -o '$(CONTROLLER_GEN)' + chmod +x '$(CONTROLLER_GEN)'; +else + $(info Using existing controller-gen from "$(CONTROLLER_GEN)") + @[[ "$(_controller_gen_installed_version)" == $(CONTROLLER_GEN_VERSION) ]] || \ + echo "Warning: Installed controller-gen version $(_controller_gen_installed_version) does not match expected version $(CONTROLLER_GEN_VERSION)." +endif +.PHONY: ensure-controller-gen + +clean-controller-gen: + $(RM) $(controller_gen_dir)controller-gen* + if [ -d '$(controller_gen_dir)' ]; then rmdir --ignore-fail-on-non-empty -p '$(controller_gen_dir)'; fi +.PHONY: clean-controller-gen + +clean: clean-controller-gen diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/crd-schema-gen.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/crd-schema-gen.mk new file mode 100644 index 0000000..bce780d --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/crd-schema-gen.mk @@ -0,0 +1,109 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ + ../../targets/openshift/controller-gen.mk \ + ../../targets/openshift/yq.mk \ + ../../targets/openshift/yaml-patch.mk \ +) + +# $1 - crd file +# $2 - patch file +define patch-crd-yq + $(YQ) m -i -x '$(1)' '$(2)' + +endef + +# $1 - crd file +define format-yaml + cat '$(1)' | $(YQ) read - > t.yaml + mv t.yaml '$(1)' +endef + +# $1 - crd file +# $2 - patch file +define patch-crd-yaml-patch + $(YAML_PATCH) -o '$(2)' < '$(1)' > '$(1).patched' + mv '$(1).patched' '$(1)' + +endef + +empty := + +# $1 - apis +# $2 - manifests +define run-crd-gen + '$(CONTROLLER_GEN)' \ + schemapatch:manifests="$(2)" \ + paths="$(subst $(empty) ,;,$(1))" \ + 'output:dir="$(2)"' + $$(foreach p,$$(wildcard $(2)/*.crd.yaml-merge-patch),$$(call patch-crd-yq,$$(basename $$(p)).yaml,$$(p))) + $$(foreach p,$$(wildcard $(2)/*.crd.yaml-patch),$$(call patch-crd-yaml-patch,$$(basename $$(p)).yaml,$$(p))) + $$(foreach p,$$(wildcard $(2)/*.crd.yaml),$$(call patch-crd-yq,$$(basename $$(p)).yaml,$$(p))) +endef + + +# $1 - target name +# $2 - apis +# $3 - manifests +define add-crd-gen-internal + +update-codegen-crds-$(1): ensure-controller-gen ensure-yq ensure-yaml-patch + $(call run-crd-gen,$(2),$(3)) +.PHONY: update-codegen-crds-$(1) + +update-codegen-crds: update-codegen-crds-$(1) +.PHONY: update-codegen-crds + +verify-codegen-crds-$(1): update-codegen-crds-$(1) + git diff --exit-code +.PHONY: verify-codegen-crds-$(1) + +verify-codegen-crds: verify-codegen-crds-$(1) +.PHONY: verify-codegen-crds + +endef + + +# $1 - target name +# $2 - apis +# $3 - manifests +# $4 - featureSet +define add-crd-gen-for-featureset-internal + +update-codegen-$(4)-crds-$(1): ensure-controller-gen ensure-yq ensure-yaml-patch + OPENSHIFT_REQUIRED_FEATURESET=$(4) $(call run-crd-gen,$(2),$(3)) +.PHONY: update-codegen-$(4)-crds-$(1) + +update-codegen-$(4)-crds: update-codegen-$(4)-crds-$(1) +.PHONY: update-codegen-$(4)-crds + +verify-codegen-$(4)-crds-$(1): update-codegen-$(4)-crds-$(1) + git diff --exit-code +.PHONY: verify-codegen-$(4)-crds-$(1) + +verify-codegen-$(4)-crds: verify-codegen-$(4)-crds-$(1) +.PHONY: verify-codegen-$(4)-crds + +endef + +update-generated: update-codegen-crds +.PHONY: update-generated + +update: update-generated +.PHONY: update + +verify-generated: verify-codegen-crds +.PHONY: verify-generated + +verify: verify-generated +.PHONY: verify + + +define add-crd-gen +$(eval $(call add-crd-gen-internal,$(1),$(2),$(3))) +endef + +define add-crd-gen-for-featureset +$(eval $(call add-crd-gen-for-featureset-internal,$(1),$(2),$(3),$(5))) +endef + diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-glide.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-glide.mk new file mode 100644 index 0000000..c178d84 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-glide.mk @@ -0,0 +1,34 @@ +scripts_dir :=$(dir $(lastword $(MAKEFILE_LIST)))/../../../scripts + +# We need to force localle so different envs sort files the same way for recursive traversals +deps_diff :=LC_COLLATE=C diff --no-dereference -N + +update-deps: + $(scripts_dir)/$@.sh +.PHONY: update-deps + +# $1 - temporary directory to restore vendor dependencies from glide.lock +define restore-deps + ln -s $(abspath ./) "$(1)"/current + cp -R -H ./ "$(1)"/updated + $(RM) -r "$(1)"/updated/vendor + cd "$(1)"/updated && glide install --strip-vendor && find ./vendor -name '.hg_archival.txt' -delete + cd "$(1)" && $(deps_diff) -r {current,updated}/vendor/ > updated/glide.diff || true +endef + +verify-deps: tmp_dir:=$(shell mktemp -d) +verify-deps: + $(call restore-deps,$(tmp_dir)) + @echo $(deps_diff) '$(tmp_dir)'/{current,updated}/glide.diff + @ $(deps_diff) '$(tmp_dir)'/{current,updated}/glide.diff || ( \ + echo "ERROR: Content of 'vendor/' directory doesn't match 'glide.lock' and the overrides in 'glide.diff'!" && \ + echo "If this is an intentional change (a carry patch) please update the 'glide.diff' using 'make update-deps-overrides'." && \ + exit 1 \ + ) +.PHONY: verify-deps + +update-deps-overrides: tmp_dir:=$(shell mktemp -d) +update-deps-overrides: + $(call restore-deps,$(tmp_dir)) + cp "$(tmp_dir)"/{updated,current}/glide.diff +.PHONY: update-deps-overrides diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-gomod.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-gomod.mk new file mode 100644 index 0000000..9731e4d --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-gomod.mk @@ -0,0 +1,36 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ +) + +# We need to force localle so different envs sort files the same way for recursive traversals +deps_diff :=LC_COLLATE=C diff --no-dereference -N + +# $1 - temporary directory +define restore-deps + ln -s $(abspath ./) "$(1)"/current + cp -R -H ./ "$(1)"/updated + $(RM) -r "$(1)"/updated/vendor + cd "$(1)"/updated && $(GO) mod tidy && $(GO) mod vendor && $(GO) mod verify + cd "$(1)" && $(deps_diff) -r {current,updated}/vendor/ > updated/deps.diff || true +endef + +verify-deps: tmp_dir:=$(shell mktemp -d) +verify-deps: + $(call restore-deps,$(tmp_dir)) + $(deps_diff) "$(tmp_dir)"/{current,updated}/go.mod || ( echo '`go.mod` content is incorrect - did you run `go mod tidy`?' && false ) + $(deps_diff) "$(tmp_dir)"/{current,updated}/go.sum || ( echo '`go.sum` content is incorrect - did you run `go mod tidy`?' && false ) + @echo $(deps_diff) '$(tmp_dir)'/{current,updated}/deps.diff + @ $(deps_diff) '$(tmp_dir)'/{current,updated}/deps.diff || ( \ + echo "ERROR: Content of 'vendor/' directory doesn't match 'go.mod' configuration and the overrides in 'deps.diff'!" && \ + echo 'Did you run `go mod vendor`?' && \ + echo "If this is an intentional change (a carry patch) please update the 'deps.diff' using 'make update-deps-overrides'." && \ + false \ + ) + rm -rf $(tmp_dir) +.PHONY: verify-deps + +update-deps-overrides: tmp_dir:=$(shell mktemp -d) +update-deps-overrides: + $(call restore-deps,$(tmp_dir)) + cp "$(tmp_dir)"/{updated,current}/deps.diff +.PHONY: update-deps-overrides diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps.mk new file mode 100644 index 0000000..adb575b --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps.mk @@ -0,0 +1,15 @@ +# Use a unique variable name to avoid conflicting with generic +# `self_dir` elsewhere. +_self_dir_openshift_deps :=$(dir $(lastword $(MAKEFILE_LIST))) + +deps_gomod_mkfile := $(_self_dir_openshift_deps)/deps-gomod.mk +deps_glide_mkfile := $(_self_dir_openshift_deps)/deps-glide.mk +include $(addprefix $(_self_dir_openshift_deps), \ + ../../lib/golang.mk \ +) + +ifneq "$(GO) list $(GO_MOD_FLAGS) -m" "" +include $(deps_gomod_mkfile) +else +include $(deps_glide_mkfile) +endif diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/doc.go b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/imagebuilder.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/imagebuilder.mk new file mode 100644 index 0000000..2163151 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/imagebuilder.mk @@ -0,0 +1,25 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) + +IMAGEBUILDER_VERSION ?=1.2.1 + +IMAGEBUILDER ?= $(shell which imagebuilder 2>/dev/null) +ifneq "" "$(IMAGEBUILDER)" +_imagebuilder_installed_version = $(shell $(IMAGEBUILDER) --version) +endif + +# NOTE: We would like to +# go get github.com/openshift/imagebuilder/cmd/imagebuilder@v$(IMAGEBUILDER_VERSION) +# ...but `go get` is too unreliable. So instead we use this to make the +# "you don't have imagebuilder" error useful. +ensure-imagebuilder: +ifeq "" "$(IMAGEBUILDER)" + $(error imagebuilder not found! Get it with: `go get github.com/openshift/imagebuilder/cmd/imagebuilder@v$(IMAGEBUILDER_VERSION)`) +else + $(info Using existing imagebuilder from $(IMAGEBUILDER)) + @[[ "$(_imagebuilder_installed_version)" == $(IMAGEBUILDER_VERSION) ]] || \ + echo "Warning: Installed imagebuilder version $(_imagebuilder_installed_version) does not match expected version $(IMAGEBUILDER_VERSION)." +endif +.PHONY: ensure-imagebuilder diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/images.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/images.mk new file mode 100644 index 0000000..c53c3f1 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/images.mk @@ -0,0 +1,33 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + imagebuilder.mk \ +) + +# IMAGE_BUILD_EXTRA_FLAGS lets you add extra flags for imagebuilder +# e.g. to mount secrets and repo information into base image like: +# make images IMAGE_BUILD_EXTRA_FLAGS='-mount ~/projects/origin-repos/4.2/:/etc/yum.repos.d/' +IMAGE_BUILD_DEFAULT_FLAGS ?=--allow-pull +IMAGE_BUILD_EXTRA_FLAGS ?= + +# $1 - target name +# $2 - image ref +# $3 - Dockerfile path +# $4 - context +define build-image-internal +image-$(1): ensure-imagebuilder + $(strip \ + imagebuilder \ + $(IMAGE_BUILD_DEFAULT_FLAGS) \ + -t $(2) + -f $(3) \ + $(IMAGE_BUILD_EXTRA_FLAGS) \ + $(4) \ + ) +.PHONY: image-$(1) + +images: image-$(1) +.PHONY: images +endef + +define build-image +$(eval $(call build-image-internal,$(1),$(2),$(3),$(4))) +endef diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/kustomize.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/kustomize.mk new file mode 100644 index 0000000..79c26f9 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/kustomize.mk @@ -0,0 +1,32 @@ +# We need to include this before we use PERMANENT_TMP_GOPATH +# (indirectly) from ifeq. +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/tmp.mk \ +) + +KUSTOMIZE_VERSION ?= 4.1.3 +KUSTOMIZE ?= $(PERMANENT_TMP_GOPATH)/bin/kustomize-$(KUSTOMIZE_VERSION) +kustomize_dir := $(dir $(KUSTOMIZE)) + +ensure-kustomize: +ifeq "" "$(wildcard $(KUSTOMIZE))" + $(info Installing kustomize into '$(KUSTOMIZE)') + mkdir -p '$(kustomize_dir)' + @# install_kustomize.sh lays down the binary as `kustomize`, and will + @# also fail if a file of that name already exists. Remove it for + @# backward compatibility (older b-m-gs used the raw file name). + rm -f $(kustomize_dir)/kustomize + @# NOTE: Pinning script to a tag rather than `master` for security reasons + curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/kustomize/v$(KUSTOMIZE_VERSION)/hack/install_kustomize.sh" | bash -s $(KUSTOMIZE_VERSION) $(kustomize_dir) + mv $(kustomize_dir)/kustomize $(KUSTOMIZE) +else + $(info Using existing kustomize from "$(KUSTOMIZE)") +endif +.PHONY: ensure-kustomize + +clean-kustomize: + $(RM) $(kustomize_dir)kustomize* + if [ -d '$(kustomize_dir)' ]; then rmdir --ignore-fail-on-non-empty -p '$(kustomize_dir)'; fi +.PHONY: clean-kustomize + +clean: clean-kustomize diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/doc.go b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/profile-manifests.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/profile-manifests.mk new file mode 100644 index 0000000..96e0594 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/profile-manifests.mk @@ -0,0 +1,80 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../../lib/tmp.mk \ + ../yq.mk \ + ../yaml-patch.mk \ +) + +# Merge yaml patch using mikefarah/yq +# $1 - patch file +# $2 - manifest file +# $3 - output file +define patch-manifest-yq + ( echo '# *** AUTOMATICALLY GENERATED FILE - DO NOT EDIT ***'; \ + $(YQ) m -x '$(2)' '$(1)' ) > '$(3)' + +endef + +# Apply yaml-patch using krishicks/yaml-patch +# $1 - patch file +# $2 - manifest file +# $3 - output file +define patch-manifest-yaml-patch + ( echo '# *** AUTOMATICALLY GENERATED FILE - DO NOT EDIT ***'; \ + $(YAML_PATCH) -o '$(1)' < '$(2)' ) > '$(3)' + +endef + +profile-yaml-patches = $(sort $(shell find $(1) -type f -name '*.yaml-patch')) +profile-yaml-merge-patches = $(sort $(shell find $(1) -type f -name '*.yaml-merge-patch')) + +# Apply profile patches to manifests +# $1 - patch dir +# $2 - manifests dir +define apply-profile-manifest-patches + $$(foreach p,$$(call profile-yaml-patches,$(1)),$$(call patch-manifest-yaml-patch,$$(p),$$(realpath $(2))/$$(basename $$(notdir $$(p))).yaml,$$(realpath $(2))/$$(basename $$(notdir $$(p)))-$$(notdir $$(realpath $$(dir $$(p)))).yaml)) + $$(foreach p,$$(call profile-yaml-merge-patches,$(1)),$$(call patch-manifest-yq,$$(p),$$(realpath $(2))/$$(basename $$(notdir $$(p))).yaml,$$(realpath $(2))/$$(basename $$(notdir $$(p)))-$$(notdir $$(realpath $$(dir $$(p)))).yaml)) +endef + +# $1 - target name +# $2 - patch dir +# $3 - manifest dir +define add-profile-manifests-internal + +update-profile-manifests-$(1): ensure-yq ensure-yaml-patch + $(call apply-profile-manifest-patches,$(2),$(3)) +.PHONY: update-profile-manifests-$(1) + +update-profile-manifests: update-profile-manifests-$(1) +.PHONY: update-profile-manifests + +verify-profile-manifests-$(1): VERIFY_PROFILE_MANIFESTS_TMP_DIR:=$$(shell mktemp -d) +verify-profile-manifests-$(1): ensure-yq ensure-yaml-patch + cp -R $(3)/* $$(VERIFY_PROFILE_MANIFESTS_TMP_DIR)/ + $(call apply-profile-manifest-patches,$(2),$$(VERIFY_PROFILE_MANIFESTS_TMP_DIR)) + diff -Naup $(3) $$(VERIFY_PROFILE_MANIFESTS_TMP_DIR) +.PHONY: verify-profile-manifests-$(1) + +verify-profile-manifests: verify-profile-manifests-$(1) +.PHONY: verify-profile-manifests + +update-generated: update-profile-manifests +.PHONY: update-generated + +update: update-generated +.PHONY: update + +verify-generated: verify-profile-manifests +.PHONY: verify-generated + +verify: verify-generated +.PHONY: verify + +endef + + +# $1 - target name +# $2 - profile patches dir +# $3 - manifests dir +define add-profile-manifests +$(eval $(call add-profile-manifests-internal,$(1),$(2),$(3))) +endef diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/release.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/release.mk new file mode 100644 index 0000000..07fc560 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/release.mk @@ -0,0 +1,7 @@ +# If we need unified behaviour specific to operators, this folder is the place. + +# It seems that our previous origin-release jq based replacement is suppose to be done +# with `oc adm release new` so it might drop this target. +#origin-release: +# $(error Not implemented.) +#.PHONY: origin-release diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/telepresence.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/telepresence.mk new file mode 100644 index 0000000..ef0b379 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/telepresence.mk @@ -0,0 +1,11 @@ +scripts_dir :=$(shell realpath $(dir $(lastword $(MAKEFILE_LIST)))../../../../scripts) + +telepresence: + $(info Running operator locally against a remote cluster using telepresence (https://telepresence.io)) + $(info ) + $(info To override the operator log level, set TP_VERBOSITY=) + $(info To debug the operator, set TP_DEBUG=y (requires the delve debugger)) + $(info See the run-telepresence.sh script for more usage and configuration details) + $(info ) + bash $(scripts_dir)/run-telepresence.sh +.PHONY: telepresence diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/rpm.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/rpm.mk new file mode 100644 index 0000000..c444df8 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/rpm.mk @@ -0,0 +1,38 @@ +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ +) + +RPM_OUTPUT_DIR ?=_output +RPM_TOPDIR ?=$(abspath ./) +RPM_BUILDDIR ?=$(RPM_TOPDIR) +RPM_BUILDROOT ?=$(RPM_TOPDIR) +RPM_SOURCEDIR ?=$(RPM_TOPDIR) +RPM_SPECDIR ?=$(RPM_TOPDIR) +RPM_RPMDIR ?=$(RPM_TOPDIR)/$(RPM_OUTPUT_DIR)/rpms +RPM_SRCRPMDIR ?=$(RPM_TOPDIR)/$(RPM_OUTPUT_DIR)/srpms + +RPM_SPECFILES ?=$(wildcard *.spec) +RPM_BUILDFLAGS ?=-ba +RPM_EXTRAFLAGS ?= + +rpm-build: + $(strip \ + rpmbuild $(RPM_BUILDFLAGS) \ + --define "_topdir $(RPM_TOPDIR)" \ + --define "_builddir $(RPM_BUILDDIR)" \ + --define "_buildrootdir $(RPM_BUILDROOT)" \ + --define "_rpmdir $(RPM_RPMDIR)" \ + --define "_srcrpmdir $(RPM_SRCRPMDIR)" \ + --define "_specdir $(RPM_SPECDIR)" \ + --define "_sourcedir $(RPM_SOURCEDIR)" \ + --define "go_package $(GO_PACKAGE)" \ + $(RPM_EXTRAFLAGS) \ + $(RPM_SPECFILES) \ + ) + +clean-rpms: + $(RM) -r '$(RPM_RPMDIR)' '$(RPM_SRCRPMDIR)' + if [ -d '$(RPM_OUTPUT_DIR)' ]; then rmdir --ignore-fail-on-non-empty '$(RPM_OUTPUT_DIR)'; fi +.PHONY: clean-rpms + +clean: clean-rpms diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yaml-patch.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yaml-patch.mk new file mode 100644 index 0000000..4a65f7b --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yaml-patch.mk @@ -0,0 +1,32 @@ +ifndef _YAML_PATCH_MK_ +_YAML_PATCH_MK_ := defined + +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) + +YAML_PATCH_VERSION ?=v0.0.11 +YAML_PATCH ?=$(PERMANENT_TMP_GOPATH)/bin/yaml-patch-$(YAML_PATCH_VERSION) +yaml_patch_dir :=$(dir $(YAML_PATCH)) + + +ensure-yaml-patch: +ifeq "" "$(wildcard $(YAML_PATCH))" + $(info Installing yaml-patch into '$(YAML_PATCH)') + mkdir -p '$(yaml_patch_dir)' + curl -s -f -L https://github.com/pivotal-cf/yaml-patch/releases/download/$(YAML_PATCH_VERSION)/yaml_patch_$(GOHOSTOS) -o '$(YAML_PATCH)' + chmod +x '$(YAML_PATCH)'; +else + $(info Using existing yaml-patch from "$(YAML_PATCH)") +endif +.PHONY: ensure-yaml-patch + +clean-yaml-patch: + $(RM) $(yaml_patch_dir)yaml-patch* + if [ -d '$(yaml_patch_dir)' ]; then rmdir --ignore-fail-on-non-empty -p '$(yaml_patch_dir)'; fi +.PHONY: clean-yaml-patch + +clean: clean-yaml-patch + +endif diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yq.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yq.mk new file mode 100644 index 0000000..07726d8 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yq.mk @@ -0,0 +1,32 @@ +ifndef _YQ_MK_ +_YQ_MK_ := defined + +include $(addprefix $(dir $(lastword $(MAKEFILE_LIST))), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) + +YQ_VERSION ?=2.4.0 +YQ ?=$(PERMANENT_TMP_GOPATH)/bin/yq-$(YQ_VERSION) +yq_dir :=$(dir $(YQ)) + + +ensure-yq: +ifeq "" "$(wildcard $(YQ))" + $(info Installing yq into '$(YQ)') + mkdir -p '$(yq_dir)' + curl -s -f -L https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(GOHOSTOS)_$(GOHOSTARCH) -o '$(YQ)' + chmod +x '$(YQ)'; +else + $(info Using existing yq from "$(YQ)") +endif +.PHONY: ensure-yq + +clean-yq: + $(RM) $(yq_dir)yq* + if [ -d '$(yq_dir)' ]; then rmdir --ignore-fail-on-non-empty -p '$(yq_dir)'; fi +.PHONY: clean-yq + +clean: clean-yq + +endif diff --git a/vendor/github.com/openshift/build-machinery-go/scripts/doc.go b/vendor/github.com/openshift/build-machinery-go/scripts/doc.go new file mode 100644 index 0000000..66ba551 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/scripts/doc.go @@ -0,0 +1,3 @@ +// required for gomod to pull in packages. + +package alpha_build_machinery diff --git a/vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh b/vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh new file mode 100644 index 0000000..d167465 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh @@ -0,0 +1,195 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +# This script executes telepresence against an operator deployment. +# +# KUBECONFIG=... TP_DEPLOYMENT_YAML=... TP_CMD_PATH=... run-telepresence.sh +# +# The script is parameterized by env vars prefixed with 'TP_'. +# +# Dependencies: +# +# - oc +# - jq (fedora: dnf install jq; macos: brew install jq) +# - telepresence (https://www.telepresence.io/reference/install) +# - >= 0.105 is compatible with OCP +# - delve (go get github.com/go-delve/delve/cmd/dlv) + +KUBECONFIG="${KUBECONFIG:-}" +if [[ "${KUBECONFIG}" == "" ]]; then + >&2 echo "KUBECONFIG is not set" + exit 1 +fi + +# The yaml defining the operator's deployment resource. Will be parsed +# for configuration like resource name, namespace, and command. +TP_DEPLOYMENT_YAML="${TP_DEPLOYMENT_YAML:-}" +if [[ ! "${TP_DEPLOYMENT_YAML}" ]]; then + >&2 echo "TP_DEPLOYMENT_YAML is not set" + exit 1 +fi + +# The path to the golang package to run or debug +# (e.g. `/my/project/cmd/operator`) +TP_CMD_PATH="${TP_CMD_PATH:-}" +if [[ ! "${TP_CMD_PATH}" ]]; then + >&2 echo "TP_CMD_PATH is not set" + exit 1 +fi + +# By default the operator will be run via 'go run'. Providing TP_DEBUG=y +# will run `dlv debug` instead. +TP_DEBUG="${TP_DEBUG:-}" + +# Whether to add an entry in /etc/hosts for the api server host. This +# is necessary if targeting a cluster deployed in aws. +TP_ADD_AWS_HOST_ENTRY="${TP_ADD_AWS_HOST_ENTRY:-y}" + +# The arguments for the command that will be executed will be parsed +# from the deployment by default, but can be overridden by setting +# this var. The name of the command itself is implicitly determined by +# `go run` or `dlv debug` from TP_CMD_PATH. +TP_CMD_ARGS="${TP_CMD_ARGS:-}" + +# Will add a -v= argument to the command to set the logging +# verbosity. If a verbosity argument was already supplied, this value +# will override it. +TP_VERBOSITY="${TP_VERBOSITY:-}" + +# The command telepresence should run in the local deployment +# environment. By default it will run or debug the operator but it can +# be useful to run a shell (e.g. `bash`) for troubleshooting. +TP_RUN_CMD="${TP_RUN_CMD:-}" +if [[ ! "${TP_RUN_CMD}" ]]; then + # Default to a recursive call + TP_RUN_CMD="${0}" + if [[ ! -x "${TP_RUN_CMD}" ]]; then + # Prefix the recursive call with bash if the script is not + # executable as will be the case when build-machinery-go is + # vendored. + TP_RUN_CMD="bash ${TP_RUN_CMD}" + fi +fi + +# Whether this script should run telepresence or is being run by +# telepresence. Used as an internal control var, not necessary to set +# manually. +_TP_INTERNAL_RUN="${_TP_INTERNAL_RUN:-}" + +# Some operators (e.g. auth operator) specify build flags to generate +# different binaries for ocp or okd. +TP_BUILD_FLAGS="${TP_BUILD_FLAGS:-}" + +# Simplify querying the deployment yaml with jq +function jq_deployment () { + local jq_arg="${1}" + cat "${TP_DEPLOYMENT_YAML}"\ + | python -c 'import json, sys, yaml ; y=yaml.safe_load(sys.stdin.read()) ; print(json.dumps(y))'\ + | jq -r "${jq_arg}" +} + +NAMESPACE="$(jq_deployment '.metadata.namespace')" +NAME="$(jq_deployment '.metadata.name')" + +# If not provided, the lock configmap will be defaulted to the name of +# the deployment suffixed by `-lock`. +TP_LOCK_CONFIGMAP="${TP_LOCK_CONFIGMAP:-${NAME}-lock}" + +if [ "${_TP_INTERNAL_RUN}" ]; then + # Delete the leader election lock to ensure that the local process + # becomes the leader as quickly as possible. + oc delete configmap "${TP_LOCK_CONFIGMAP}" --namespace "${NAMESPACE}" --ignore-not-found=true + + if [[ ! "${TP_CMD_ARGS}" ]]; then + # Parse the arguments from the deployment + TP_CMD_ARGS="$(jq_deployment '.spec.template.spec.containers[0].command[1:] | join(" ")' )" + TP_CMD_ARGS+=" $(jq_deployment '.spec.template.spec.containers[0].args | join(" ")' )" + fi + + if [[ "${TP_VERBOSITY}" ]]; then + # Setting log level last ensures that any existing -v argument will be overridden. + TP_CMD_ARGS+=" -v=${TP_VERBOSITY}" + fi + + pushd "${TP_CMD_PATH}" > /dev/null + if [[ "${TP_DEBUG}" ]]; then + if [[ "${TP_BUILD_FLAGS}" ]]; then + TP_BUILD_FLAGS="--build-flags=${TP_BUILD_FLAGS}" + fi + dlv debug ${TP_BUILD_FLAGS} -- ${TP_CMD_ARGS} + else + go run ${TP_BUILD_FLAGS} . ${TP_CMD_ARGS} + fi + popd > /dev/null +else + if [[ "${TP_ADD_AWS_HOST_ENTRY}" ]]; then + # Add an entry in /etc/hosts for the api endpoint in the configured + # KUBECONFIG (which is assumed to have at most one server). + # + # This supports using telepresence with kube clusters running in + # aws. telepresence will proxy dns requests to the cluster and will + # return an internal aws address for the api endpoint otherwise. + SERVER_HOST="$(grep server "${KUBECONFIG}" | sed -e 's+ server: https://\(.*\):.*+\1+')" + SERVER_IP="$(dig "${SERVER_HOST}" +short | head -n 1)" + ENTRY="${SERVER_IP} ${SERVER_HOST}" + if ! grep "${ENTRY}" /etc/hosts > /dev/null; then + >&2 echo "Attempting to add '${ENTRY}' to /etc/hosts to ensure access to an aws cluster. This requires sudo." + >&2 echo "If this cluster is not in aws, specify TP_ADD_AWS_HOST_ENTRY=" + grep -q "${SERVER_HOST}" /etc/hosts && \ + (cp -f /etc/hosts /tmp/etc-hosts && \ + sed -i 's+.*'"${SERVER_HOST}"'$+'"${ENTRY}"'+' /tmp/etc-hosts && \ + sudo cp /tmp/etc-hosts /etc/hosts)\ + || echo "${ENTRY}" | sudo tee -a /etc/hosts > /dev/null + fi + fi + + # Ensure pod volumes are symlinked to the expected location + if [[ ! -L '/var/run/configmaps' ]]; then + >&2 echo "Attempting to symlink /tmp/tel_root/var/run/configmaps to /var/run/configmaps. This requires sudo." + sudo ln -s /tmp/tel_root/var/run/configmaps /var/run/configmaps + fi + if [[ ! -L '/var/run/secrets' ]]; then + >&2 echo "Attempting to symlink /tmp/tel_root/var/run/secrets to /var/run/secrets. This requires sudo." + sudo ln -s /tmp/tel_root/var/run/secrets /var/run/secrets + fi + + KIND="$(jq_deployment '.kind')" + GROUP="$(jq_deployment '.apiVersion')" + + # Ensure the operator is not managed by CVO + oc patch clusterversion/version --type='merge' -p "$(cat <<- EOF +spec: + overrides: + - group: ${GROUP} + kind: ${KIND} + name: ${NAME} + namespace: ${NAMESPACE} + unmanaged: true +EOF +)" + + # Ensure the operator is managed again on shutdown + function cleanup { + oc patch clusterversion/version --type='merge' -p "$(cat <<- EOF +spec: + overrides: + - group: ${GROUP} + kind: ${KIND} + name: ${NAME} + namespace: ${NAMESPACE} + unmanaged: false +EOF +)" + } + trap cleanup EXIT + + # Ensure that traffic for all machines in the cluster is also + # proxied so that the local operator will be able to access them. + ALSO_PROXY="$(oc get machines -A -o json | jq -jr '.items[] | .status.addresses[0].address | @text "--also-proxy=\(.) "')" + + TELEPRESENCE_USE_OCP_IMAGE=NO _TP_INTERNAL_RUN=y telepresence --namespace="${NAMESPACE}"\ + --swap-deployment "${NAME}" ${ALSO_PROXY} --mount=/tmp/tel_root --run ${TP_RUN_CMD} +fi diff --git a/vendor/github.com/openshift/build-machinery-go/scripts/update-deps.sh b/vendor/github.com/openshift/build-machinery-go/scripts/update-deps.sh new file mode 100644 index 0000000..46812e9 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/scripts/update-deps.sh @@ -0,0 +1,27 @@ +#!/bin/bash -e + +readonly GLIDE_MINOR_VERSION="13" +readonly REQUIRED_GLIDE_VERSION="0.$GLIDE_MINOR_VERSION" + +function verify_glide_version() { + if ! command -v glide &> /dev/null; then + echo "[FATAL] Glide was not found in \$PATH. Please install version ${REQUIRED_GLIDE_VERSION} or newer." + exit 1 + fi + + local glide_version + glide_version=($(glide --version)) + if ! echo "${glide_version[2]#v}" | awk -F. -v min=$GLIDE_MINOR_VERSION '{ exit $2 < min }'; then + echo "Detected glide version: ${glide_version[*]}." + echo "Please install Glide version ${REQUIRED_GLIDE_VERSION} or newer." + exit 1 + fi +} + +verify_glide_version + +glide update --strip-vendor + +# glide doesn't handle mercurial properly and leaves internal files (equivalent of .git/) laying around +# Given those files differ by mercurial version it was cloned with, verify-deps would break +find ./vendor -name '.hg_archival.txt' -delete diff --git a/vendor/github.com/openshift/build-machinery-go/scripts/vulncheck.sh b/vendor/github.com/openshift/build-machinery-go/scripts/vulncheck.sh new file mode 100644 index 0000000..71dfe72 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/scripts/vulncheck.sh @@ -0,0 +1,22 @@ +#!/bin/bash -e + +### Use govulncheck to check for known vulnerabilities in the project. +### Fail if vulnerabilities are found in module dependencies. +### Warn (but do not fail) on stdlib vulnerabilities. +### TODO: Include useful information (ID, URL) about the vulnerability. + +go install golang.org/x/vuln/cmd/govulncheck@latest + +report=`mktemp` +trap "rm $report" EXIT + +govulncheck -json ./... > $report + +modvulns=$(jq -r '.Vulns[].Modules[] | select(.Path != "stdlib") | [.Path, .FoundVersion, .FixedVersion]' < $report) +libvulns=$(jq -r '.Vulns[].Modules[] | select(.Path == "stdlib") | [.Path, .FoundVersion, .FixedVersion]' < $report) + +echo "$modvulns" +echo "$libvulns" + +# Exit nonzero iff there are any vulnerabilities in module dependencies +test -z "$modvulns" diff --git a/vendor/modules.txt b/vendor/modules.txt new file mode 100644 index 0000000..e0635c9 --- /dev/null +++ b/vendor/modules.txt @@ -0,0 +1,10 @@ +# github.com/openshift/build-machinery-go v0.0.0-20230824093055-6a18da01283c +## explicit; go 1.13 +github.com/openshift/build-machinery-go +github.com/openshift/build-machinery-go/make +github.com/openshift/build-machinery-go/make/lib +github.com/openshift/build-machinery-go/make/targets +github.com/openshift/build-machinery-go/make/targets/golang +github.com/openshift/build-machinery-go/make/targets/openshift +github.com/openshift/build-machinery-go/make/targets/openshift/operator +github.com/openshift/build-machinery-go/scripts From 39f55e65dc613a9e3ccc58d7825cad05afebd945 Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Wed, 27 Sep 2023 15:01:32 +0530 Subject: [PATCH 07/15] Remove jq to fix local builds Signed-off-by: black-dragon74 --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5eb0f40..79cf1b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,9 @@ RUN mkdir -p /templates COPY --from=builder /go/src/github.com/red-hat-storage/odf-must-gather/collection-scripts/* /usr/bin/ COPY --from=builder /go/src/github.com/red-hat-storage/odf-must-gather/templates/* /templates -RUN yum install --setopt=tsflags=nodocs -y jq && yum clean all && rm -rf /var/cache/yum/* +# We do not need it as of now +# jq is not preinstalled on openshift/origin-cli either +# Removing this step makes local development easier. +# RUN yum install --setopt=tsflags=nodocs -y jq && yum clean all && rm -rf /var/cache/yum/* ENTRYPOINT /usr/bin/gather \ No newline at end of file From e76db8a860ce86dc8d08e7b124997e51fc247603 Mon Sep 17 00:00:00 2001 From: Amit Prinz Setter Date: Mon, 21 Aug 2023 14:36:33 +0300 Subject: [PATCH 08/15] Copy postgres log files for noobaa/mcg Signed-off-by: Amit Prinz Setter --- collection-scripts/gather_noobaa_resources | 1 + 1 file changed, 1 insertion(+) diff --git a/collection-scripts/gather_noobaa_resources b/collection-scripts/gather_noobaa_resources index 781109d..d2899f8 100755 --- a/collection-scripts/gather_noobaa_resources +++ b/collection-scripts/gather_noobaa_resources @@ -68,6 +68,7 @@ NOOBAA_POSTGRES_LABEL='noobaa-db in (postgres)' for pod in $(oc -n "${ns}" get pods -l "${NOOBAA_POSTGRES_LABEL}" | grep -v NAME | awk '{print $1}'); do dbglog "collecting noobaa db pod logs from ${ns}" { timeout 120 oc -n "${ns}" logs --all-containers "${pod}" &>"${LOG_DIR}"/"${pod}".log; } >>"${BASE_COLLECTION_PATH}"/gather-debug.log 2>&1 + { timeout 120 oc -n "${ns}" cp "${pod}":/var/lib/pgsql/data/userdata/log "${LOG_DIR}"/"${pod}"/pg_log; } >>"${BASE_COLLECTION_PATH}"/gather-debug.log 2>&1 done # Add important notifications to a notifications.txt file at the root of the noobaa collection path From 0ddda6090356f41bdc24af3ad723394e9f367748 Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Mon, 9 Oct 2023 15:04:36 +0530 Subject: [PATCH 09/15] Add black-dragon74 to OWNERS Signed-off-by: black-dragon74 --- OWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OWNERS b/OWNERS index d410400..c326ec6 100644 --- a/OWNERS +++ b/OWNERS @@ -9,6 +9,7 @@ approvers: - nb-ohad - yati1998 - iamniting + - black-dragon74 # review == this code is good /lgtm reviewers: - jarrpa @@ -20,4 +21,5 @@ reviewers: - nb-ohad - yati1998 - iamniting + - black-dragon74 \ No newline at end of file From ed3081eb5dfe664f509f6533733c919ce879017d Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Thu, 12 Oct 2023 14:03:36 +0530 Subject: [PATCH 10/15] Add instructions to build locally Signed-off-by: black-dragon74 --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index ebd9bd1..065fe60 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,35 @@ You will get a dump of: In order to get data about other parts of the cluster (not specific to OCS) you should run `oc adm must-gather` (without passing a custom image). Run `oc adm must-gather -h` to see more options. +### Building locally for testing +You need to be autheticated against the OpenShift registry CI, registry.ci.openshift.org in order to be able to pull the images in the `Dockerfile`. + +Before proceeding make sure you have `oc` (OpenShift cli) and `jq` (optional) installed. + +Follow these steps to authenticate: + +- Navigate to the OpenShift console for `app.ci` cluster located [here](https://console-openshift-console.apps.ci.l2s4.p1.openshiftapps.com/). +- Login using SSO +- Go to your profile name in the top right and select "Copy login command". +- Login to the cluster using: `oc login --token= --server=` +- Login to the registry using: `oc registry login --registry registry.ci.openshift.org` + +You should now be successfully authenticated. You can verify by running: + +```sh +cat ~/.docker/config.json | jq '.auths["registry.ci.openshift.org"]' +``` + +You should get an output like: + +```json +{ + "auth": "" +} +``` + +Now you can build normally like: `docker build . -t --platform=linux/amd64` + ### How to Contribute - Refer and follow the standards mentioned in [ODF-MUST-GATHER How to Contribute](./CONTRIBUTING.md) From 393098737da57984355ec9bc2c4f0baa51b88b1b Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Thu, 26 Oct 2023 17:26:29 +0530 Subject: [PATCH 11/15] [Makefile] Allow local builds by using `make local` Note: You still need to export `ODF_MG_TOKEN`. Example: `ODF_MG_TOKEN= make local` This builds and tags the image as "odf-mg". You can override it using `IMG_TAG` environment variable. P.S: If using rancher, just export RANCHER variable in the ENV. Extended example: `RANCHER=yes ODF_MG_TOKEN= IMG_TAG=my-custom-tag make local` Signed-off-by: black-dragon74 --- Makefile | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 159d083..3573038 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: images -.PHONY: all +.PHONY: all local docker-rancher-build docker-engine-build # Include the library makefile include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \ @@ -8,6 +8,7 @@ include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \ ) IMAGE_REGISTRY :=registry.svc.ci.openshift.org +IMG_TAG ?= odf-mg # This will call a macro called "build-image" which will generate image specific targets based on the parameters: # $0 - macro name @@ -17,4 +18,34 @@ IMAGE_REGISTRY :=registry.svc.ci.openshift.org # $4 - context directory for image build $(call build-image,odf-must-gather,$(IMAGE_REGISTRY)/ocp/4.14:odf-must-gather, ./Dockerfile,.) -$(call verify-golang-versions,Dockerfile) \ No newline at end of file +$(call verify-golang-versions,Dockerfile) + +docker-rancher-build: + docker context use rancher-desktop + docker build . -t $(IMG_TAG) --platform=linux/amd64 + +docker-engine-build: + docker build . -t $(IMG_TAG) --platform=linux/amd64 + +local: +ifndef ODF_MG_TOKEN + @echo "ERROR: The ODF_MG_TOKEN environment variable is not set." + @exit 1 +endif + + @echo "Logging in to the cluster with token: $(ODF_MG_TOKEN)" + @oc login --token=$(ODF_MG_TOKEN) --server=https://api.ci.l2s4.p1.openshiftapps.com:6443 1>/dev/null + + @echo "Logging into the CI image registry..." + @oc registry login --registry registry.ci.openshift.org &>/dev/null + + @echo "Will be using $(IMG_TAG) as the image tag, you can change this using IMG_TAG env var." + + @echo "Building the image..." + +ifdef RANCHER + @make docker-rancher-build +else + @make docker-engine-build +endif + From 4a6a01e90dc9b92bd81bd35412bd90208d7f4f7c Mon Sep 17 00:00:00 2001 From: black-dragon74 Date: Thu, 26 Oct 2023 17:40:29 +0530 Subject: [PATCH 12/15] [Doc] Update README for local builds using make Fixes: #78 Signed-off-by: black-dragon74 --- README.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 065fe60..0483a0b 100644 --- a/README.md +++ b/README.md @@ -46,31 +46,17 @@ run `oc adm must-gather` (without passing a custom image). Run `oc adm must-gath ### Building locally for testing You need to be autheticated against the OpenShift registry CI, registry.ci.openshift.org in order to be able to pull the images in the `Dockerfile`. -Before proceeding make sure you have `oc` (OpenShift cli) and `jq` (optional) installed. +Before proceeding make sure you have `oc` (OpenShift cli) installed. Follow these steps to authenticate: - Navigate to the OpenShift console for `app.ci` cluster located [here](https://console-openshift-console.apps.ci.l2s4.p1.openshiftapps.com/). - Login using SSO - Go to your profile name in the top right and select "Copy login command". -- Login to the cluster using: `oc login --token= --server=` -- Login to the registry using: `oc registry login --registry registry.ci.openshift.org` - -You should now be successfully authenticated. You can verify by running: +- Copy the displayed TOKEN +- Run `ODF_MG_TOKEN=YOUR_TOKEN_HERE make local`. -```sh -cat ~/.docker/config.json | jq '.auths["registry.ci.openshift.org"]' -``` - -You should get an output like: - -```json -{ - "auth": "" -} -``` - -Now you can build normally like: `docker build . -t --platform=linux/amd64` +See [here](https://github.com/red-hat-storage/odf-must-gather/pull/76) for more options on building locally. ### How to Contribute From bdc9577786766e45fa6647b28a5c112ab7de860f Mon Sep 17 00:00:00 2001 From: yati1998 Date: Tue, 21 Nov 2023 13:54:17 +0530 Subject: [PATCH 13/15] sort event_desc and yaml with time this commit sorts the oc describe and yaml events according to last seen timestamp. Signed-off-by: yati1998 --- collection-scripts/gather_namespaced_resources | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/collection-scripts/gather_namespaced_resources b/collection-scripts/gather_namespaced_resources index b1583be..759a1cb 100755 --- a/collection-scripts/gather_namespaced_resources +++ b/collection-scripts/gather_namespaced_resources @@ -115,8 +115,11 @@ done # Collect oc get events with sorted timestamp dbglog "collecting output of oc get events with sorted timestamp" { oc get event -o custom-columns="LAST SEEN:{lastTimestamp},FIRST SEEN:{firstTimestamp},COUNT:{count},NAME:{metadata.name},KIND:{involvedObject.kind},SUBOBJECT:{involvedObject.fieldPath},TYPE:{type},REASON:{reason},SOURCE:{source.component},MESSAGE:{message}" --sort-by=lastTimestamp -n openshift-storage; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_get" 2>&1 -{ oc describe events -n openshift-storage; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc" 2>&1 -{ oc get events -n openshift-storage -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_yaml" 2>&1 +events=$(timeout 60 oc get events -n openshift-storage -o custom-columns="NAME:{metadata.name}" --sort-by=lastTimestamp --no-headers) +for event in "${events[@]}"; do + { oc describe events "${event}" -n openshift-storage >> "${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_desc"; } + { oc get events "${event}" -n openshift-storage -o yaml >> "${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_yaml"; } +done # Create the dir for data from all namespaces mkdir -p "${BASE_COLLECTION_PATH}/namespaces/all/" From c599ec6bbf226c0e72a82e53e83e2ed8b808d5e9 Mon Sep 17 00:00:00 2001 From: mrudraia Date: Wed, 25 Oct 2023 16:02:45 +0530 Subject: [PATCH 14/15] Collect ODF Provider and Client resources Signed-off-by: mrudraia Signed-off-by: mrudraia Signed-off-by: mrudraia Signed-off-by: mrudraia Signed-off-by: mrudraia Signed-off-by: mrudraia Signed-off-by: mrudraia Signed-off-by: mrudraia --- collection-scripts/gather | 1 + .../gather_namespaced_resources | 2 + .../collection-scripts/gather_odf_client | 111 ++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100755 must-gather/collection-scripts/gather_odf_client diff --git a/collection-scripts/gather b/collection-scripts/gather index 56fecf2..87e00e0 100755 --- a/collection-scripts/gather +++ b/collection-scripts/gather @@ -22,6 +22,7 @@ pre-install.sh ${BASE_COLLECTION_PATH} gather_namespaced_resources ${BASE_COLLECTION_PATH} gather_clusterscoped_resources ${BASE_COLLECTION_PATH} gather_noobaa_resources ${BASE_COLLECTION_PATH} +gather_odf_client ${BASE_COLLECTION_PATH} namespace=$(oc get deploy --all-namespaces -o go-template --template='{{range .items}}{{if .metadata.labels}}{{printf "%s %v" .metadata.namespace (index .metadata.labels "olm.owner")}} {{printf "\n"}}{{end}}{{end}}' | grep ocs-operator | awk '{print $1}' | uniq) storageClusterPresent=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') diff --git a/collection-scripts/gather_namespaced_resources b/collection-scripts/gather_namespaced_resources index 759a1cb..8250555 100755 --- a/collection-scripts/gather_namespaced_resources +++ b/collection-scripts/gather_namespaced_resources @@ -48,6 +48,7 @@ commands_get+=("secrets") commands_get+=("configmap") commands_get+=("rolebinding") commands_get+=("storageconsumer") +commands_get+=("storageprofiles") commands_get+=("storageclassrequest") commands_get+=("alertmanager") commands_get+=("alertmanagerconfig") @@ -61,6 +62,7 @@ commands_desc+=("hpa") commands_desc+=("subscription") commands_desc+=("storagecluster") commands_desc+=("storageconsumer") +commands_desc+=("storageprofiles") commands_desc+=("storageclassrequest") commands_desc+=("alertmanager") commands_desc+=("prometheus") diff --git a/must-gather/collection-scripts/gather_odf_client b/must-gather/collection-scripts/gather_odf_client new file mode 100755 index 0000000..326daef --- /dev/null +++ b/must-gather/collection-scripts/gather_odf_client @@ -0,0 +1,111 @@ +#!/usr/bin/env bash + +# Expect base collection path as an exported variable +# If it is not defined, use PWD instead +BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"} + + +STORAGE_CLIENT_NAMESPACE=$(oc get storageclients -A --no-headers | awk '{print $1}') +CLIENT_OPERATOR_NAMESPACE=$(oc get subscriptions -A --no-headers | grep ocs-client-operator | awk '{print $1}') + +# collection path for OC commands +mkdir -p "${BASE_COLLECTION_PATH}/odf-client/oc_output/" + +# Command List +commands_get=() +commands_get+=("pods") +commands_get+=("deployments") +commands_get+=("secrets") +commands_get+=("configmaps") +commands_get+=("cronjobs") +commands_get+=("subscription") + +client_commands_get=() +client_commands_get+=("storageclients") +client_commands_get+=("storageclassclaims") + +# YAML List +oc_yamls=() +oc_yamls+=("pods") +oc_yamls+=("deployments") +oc_yamls+=("secrets") +oc_yamls+=("configmaps") +oc_yamls+=("cronjobs") +oc_yamls+=("subscription") + +client_oc_yamls=() +client_oc_yamls+=("storageclients") +client_oc_yamls+=("storageclassclaims") + +# OC desc List +commands_desc=() +commands_desc+=("pods") +commands_desc+=("deployments") +commands_desc+=("secrets") +commands_desc+=("configmaps") +commands_desc+=("cronjobs") +commands_desc+=("subscription") +commands_desc+=("storageclients") + +client_commands_desc=() +client_commands_desc+=("storageclients") +client_commands_desc+=("storageclassclaims") + + +for INSTALL_NAMESPACE in $CLIENT_OPERATOR_NAMESPACE ; do + dbglog "collecting dump of namespace ${INSTALL_NAMESPACE}" + { oc adm --dest-dir="${BASE_COLLECTION_PATH}" inspect ns/"${INSTALL_NAMESPACE}" --"${SINCE_TIME}" 2>&1; } | dbglog + # Run the Collection of oc yaml outputs + for oc_yaml in "${oc_yamls[@]}"; do + # shellcheck disable=SC2129 + { oc adm --dest-dir="${BASE_COLLECTION_PATH}" inspect "${oc_yaml}" -n "${INSTALL_NAMESPACE}" --"${SINCE_TIME}" 2>&1; } | dbglog + done + + # Create the dir for oc_output + mkdir -p "${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/" + + # Run the Collection of Resources to list + for command_get in "${commands_get[@]}"; do + dbglog "collecting oc command ${command_get}" + COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/${command_get// /_} + # shellcheck disable=SC2086 + { oc get ${command_get} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}" + done + + # Run the Collection of OC desc commands + for command_desc in "${commands_desc[@]}"; do + dbglog "collecting oc describe command ${command_desc}" + COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/${command_desc// /_} + # shellcheck disable=SC2086 + { oc describe ${command_desc} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}" + done +done + +for INSTALL_NAMESPACE in $STORAGE_CLIENT_NAMESPACE ; do + dbglog "collecting dump of namespace ${INSTALL_NAMESPACE}" + { oc adm --dest-dir="${BASE_COLLECTION_PATH}" inspect ns/"${INSTALL_NAMESPACE}" --"${SINCE_TIME}" 2>&1; } | dbglog + # Run the Collection of oc yaml outputs + for oc_yaml in "${client_oc_yamls[@]}"; do + # shellcheck disable=SC2129 + { oc adm --dest-dir="${BASE_COLLECTION_PATH}" inspect "${oc_yaml}" -n "${INSTALL_NAMESPACE}" --"${SINCE_TIME}" 2>&1; } | dbglog + done + + # Create the dir for oc_output + mkdir -p "${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/" + + # Run the Collection of Resources to list + for command_get in "${client_commands_get[@]}"; do + dbglog "collecting oc command ${command_get}" + COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/${command_get// /_} + # shellcheck disable=SC2086 + { oc get ${command_get} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}" + done + + # Run the Collection of OC desc commands + for command_desc in "${client_commands_desc[@]}"; do + dbglog "collecting oc describe command ${command_desc}" + COMMAND_OUTPUT_FILE=${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/${command_desc// /_} + # shellcheck disable=SC2086 + { oc describe ${command_desc} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}" + done +done From a04c5f7c9cfdac826e577bde7331b028325f2e77 Mon Sep 17 00:00:00 2001 From: oviner Date: Mon, 4 Dec 2023 17:09:00 +0200 Subject: [PATCH 15/15] Running all gather scripts in background Signed-off-by: oviner --- collection-scripts/gather | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/collection-scripts/gather b/collection-scripts/gather index 87e00e0..7d9825d 100755 --- a/collection-scripts/gather +++ b/collection-scripts/gather @@ -19,10 +19,10 @@ dbglog "collection started at: ${START_TIME}" pre-install.sh ${BASE_COLLECTION_PATH} # Call other gather scripts -gather_namespaced_resources ${BASE_COLLECTION_PATH} -gather_clusterscoped_resources ${BASE_COLLECTION_PATH} -gather_noobaa_resources ${BASE_COLLECTION_PATH} -gather_odf_client ${BASE_COLLECTION_PATH} +gather_namespaced_resources ${BASE_COLLECTION_PATH} & +gather_clusterscoped_resources ${BASE_COLLECTION_PATH} & +gather_noobaa_resources ${BASE_COLLECTION_PATH} & +gather_odf_client ${BASE_COLLECTION_PATH} & namespace=$(oc get deploy --all-namespaces -o go-template --template='{{range .items}}{{if .metadata.labels}}{{printf "%s %v" .metadata.namespace (index .metadata.labels "olm.owner")}} {{printf "\n"}}{{end}}{{end}}' | grep ocs-operator | awk '{print $1}' | uniq) storageClusterPresent=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}') @@ -31,16 +31,19 @@ reconcileStrategy=$(oc get storagecluster -n "${namespace}" -o go-template='{{ra if [ "${externalStorageClusterPresent}" = "true" ]; then dbglog "Collecting limited ceph logs since external cluster is present" - gather_common_ceph_resources "${BASE_COLLECTION_PATH}" + gather_common_ceph_resources "${BASE_COLLECTION_PATH}" & elif [ -z "${storageClusterPresent}" ]; then dbglog "Skipping ceph collection as Storage Cluster is not present" elif [ "${reconcileStrategy}" = "standalone" ]; then dbglog "Skipping ceph collection as this is a MCG only cluster" else dbglog "Collecting entire ceph logs" - gather_ceph_resources ${BASE_COLLECTION_PATH} + gather_ceph_resources ${BASE_COLLECTION_PATH} & fi +# Wait until gather scripts finish +wait + # Call post-uninstall.sh post-uninstall.sh