diff --git a/.gitignore b/.gitignore index d07b11ae2..5aea66e47 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ build/_output build/_test +# Temporary files for CRD schema patching +_output + # Generated mock go files used for testing pkg/mocks diff --git a/Makefile b/Makefile index 0c7d1c211..2591d8101 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,9 @@ vendor: .PHONY: manifests manifests: ./hack/update-manifests.sh + +include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \ + targets/openshift/crd-schema-gen.mk \ +) + +$(call add-crd-gen,config,./vendor/github.com/openshift/api/config/v1,./manifests,./manifests) diff --git a/go.mod b/go.mod index 4eff60678..0bac776c3 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.17.0 github.com/openshift/api v0.0.0-20210331193751-3acddb19d360 + github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7 github.com/openshift/client-go v0.0.0-20210331195552-cf6c2669e01f github.com/openshift/library-go v0.0.0-00010101000000-000000000000 github.com/operator-framework/api v0.11.1 diff --git a/go.sum b/go.sum index 6d1057057..2ad31798a 100644 --- a/go.sum +++ b/go.sum @@ -552,6 +552,7 @@ github.com/opencontainers/runc v0.0.0-20191031171055-b133feaeeb2e/go.mod h1:qT5X github.com/openshift/api v0.0.0-20200331152225-585af27e34fd h1:f4iPC9iCf1an7qEWpEFvp/swsM79vvBRsJ2twU4D30s= github.com/openshift/api v0.0.0-20200331152225-585af27e34fd/go.mod h1:RKMJ5CBnljLfnej+BJ/xnOWc3kZDvJUaIAEq2oKSPtE= github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc= +github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7 h1:mOq7Mg1Q9d7nIDxe1SJ6pluMBQsbVxa6olyAGmfYWTg= github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0 h1:kMiuiZXH1GdfbiMwsuAQOqGaMxlo9NCUk0wT4XAdfNM= github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0/go.mod h1:uUQ4LClRO+fg5MF/P6QxjMCb1C9f7Oh4RKepftDnEJE= diff --git a/manifests/00_operatorhub.crd.yaml b/manifests/00_operatorhub.crd.yaml new file mode 100644 index 000000000..2f4c7942a --- /dev/null +++ b/manifests/00_operatorhub.crd.yaml @@ -0,0 +1,107 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + api-approved.openshift.io: https://github.com/openshift/api/pull/470 + include.release.openshift.io/ibm-cloud-managed: "true" + include.release.openshift.io/self-managed-high-availability: "true" + include.release.openshift.io/single-node-developer: "true" + capability.openshift.io/name: "marketplace" + name: operatorhubs.config.openshift.io +spec: + group: config.openshift.io + names: + kind: OperatorHub + listKind: OperatorHubList + plural: operatorhubs + singular: operatorhub + scope: Cluster + versions: + - name: v1 + schema: + openAPIV3Schema: + description: OperatorHub is the Schema for the operatorhubs API. It can be + used to change the state of the default hub sources for OperatorHub on the + cluster from enabled to disabled and vice versa. + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: OperatorHubSpec defines the desired state of OperatorHub + type: object + properties: + disableAllDefaultSources: + description: disableAllDefaultSources allows you to disable all the + default hub sources. If this is true, a specific entry in sources + can be used to enable a default source. If this is false, a specific + entry in sources can be used to disable or enable a default source. + type: boolean + sources: + description: sources is the list of default hub sources and their + configuration. If the list is empty, it implies that the default + hub sources are enabled on the cluster unless disableAllDefaultSources + is true. If disableAllDefaultSources is true and sources is not + empty, the configuration present in sources will take precedence. + The list of default hub sources and their current state will always + be reflected in the status block. + type: array + items: + description: HubSource is used to specify the hub source and its + configuration + type: object + properties: + disabled: + description: disabled is used to disable a default hub source + on cluster + type: boolean + name: + description: name is the name of one of the default hub sources + type: string + maxLength: 253 + minLength: 1 + status: + description: OperatorHubStatus defines the observed state of OperatorHub. + The current state of the default hub sources will always be reflected + here. + type: object + properties: + sources: + description: sources encapsulates the result of applying the configuration + for each hub source + type: array + items: + description: HubSourceStatus is used to reflect the current state + of applying the configuration to a default source + type: object + properties: + disabled: + description: disabled is used to disable a default hub source + on cluster + type: boolean + message: + description: message provides more information regarding failures + type: string + name: + description: name is the name of one of the default hub sources + type: string + maxLength: 253 + minLength: 1 + status: + description: status indicates success or failure in applying + the configuration + type: string + served: true + storage: true + subresources: + status: {} diff --git a/tools.go b/tools.go index 6122381d9..ba90d670d 100644 --- a/tools.go +++ b/tools.go @@ -1,8 +1,10 @@ +//go:build tools // +build tools package tools import ( _ "github.com/mikefarah/yq/v3" + _ "github.com/openshift/build-machinery-go" _ "k8s.io/kube-openapi/cmd/openapi-gen" ) 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 000000000..261eeb9e9 --- /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 000000000..aa131b622 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/Makefile @@ -0,0 +1,61 @@ +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 +# $3 - output folder +# 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 +mkdir -p "$(3)" +set -o pipefail; $(MAKE) -j 1 -C "$(dir $(1))" -f "$(notdir $(1))" --no-print-directory --warn-undefined-variables $(2) 2>&1 | \ + sed 's/\.\(buildDate\|versionFromGit\|commitFromGit\|gitTreeState\)="[^"]*" /.\1="" /g' | \ + 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\.$$' | \ + tee "$(3)"/"$(notdir $(1))"$(subst ..,.,.$(2).log) + +endef + + +# $1 - makefile name relative to ./make/ folder +# $2 - target +# $3 - output folder +define check-makefile-log +$(call update-makefile-log,$(1),$(2),$(3)) +diff -N "$(1)$(subst ..,.,.$(2).log)" "$(3)/$(notdir $(1))$(subst ..,.,.$(2).log)" + +endef + +update-makefiles: + $(foreach f,$(makefiles),$(call check-makefile-log,$(f),help,$(dir $(f)))) + $(foreach f,$(examples),$(call check-makefile-log,$(f),,$(dir $(f)))) +.PHONY: update-makefiles + +verify-makefiles: tmp_dir:=$(shell mktemp -d) +verify-makefiles: + $(foreach f,$(makefiles),$(call check-makefile-log,$(f),help,$(tmp_dir)/$(dir $(f)))) + $(foreach f,$(examples),$(call check-makefile-log,$(f),,$(tmp_dir)/$(dir $(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 000000000..0db47be86 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/OWNERS @@ -0,0 +1,10 @@ +reviewers: + - tnozicka + - sttts + - mfojtik + - soltysh +approvers: + - tnozicka + - 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 000000000..3eaf6194c --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/README.md @@ -0,0 +1,37 @@ +# 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. 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 000000000..17577ae83 --- /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 000000000..fffc5b3a3 --- /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 000000000..05285660d --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/default.example.mk.help.log @@ -0,0 +1,24 @@ +The following make targets are available: +all +build +clean +clean-binaries +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-golint +verify-govet 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 000000000..30806edb1 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/default.mk @@ -0,0 +1,23 @@ +self_dir := $(dir $(lastword $(MAKEFILE_LIST))) + +# We extend the default verify/update for Golang + +verify: verify-codegen +verify: verify-bindata +.PHONY: verify + +update: update-codegen +update: update-bindata +.PHONY: update + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + targets/openshift/deps.mk \ + targets/openshift/images.mk \ + targets/openshift/bindata.mk \ + targets/openshift/codegen.mk \ + golang.mk \ +) 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 000000000..66ba5512e --- /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 000000000..aba2c4890 --- /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 000000000..a5cc906dd --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/golang.example.mk.help.log @@ -0,0 +1,14 @@ +The following make targets are available: +all +build +clean +clean-binaries +help +test +test-unit +update +update-gofmt +verify +verify-gofmt +verify-golint +verify-govet 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 000000000..15a0b49bc --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/golang.mk @@ -0,0 +1,28 @@ +all: build +.PHONY: all + +self_dir := $(dir $(lastword $(MAKEFILE_LIST))) + + +verify: verify-gofmt +verify: verify-govet +.PHONY: verify + +update: update-gofmt +.PHONY: update + + +test: test-unit +.PHONY: test + +clean: clean-binaries +.PHONY: clean + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + targets/help.mk \ + targets/golang/*.mk \ +) 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 000000000..66ba5512e --- /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 000000000..3841aff13 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/lib/golang.mk @@ -0,0 +1,63 @@ +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.14.4 +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 ?=$(shell git rev-parse --short "HEAD^{commit}" 2>/dev/null) +SOURCE_GIT_TREE_STATE ?=$(shell ( ( [ ! -d ".git/" ] || git diff --quiet ) && echo 'clean' ) || echo 'dirty') + +define version-ldflags +-X $(1).versionFromGit="$(SOURCE_GIT_TAG)" \ +-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 "-s -w $(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 000000000..a0fb65535 --- /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 000000000..66d03ead2 --- /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 000000000..7e6ff98d5 --- /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 000000000..8a45afadf --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/operator.example.mk.help.log @@ -0,0 +1,25 @@ +The following make targets are available: +all +build +clean +clean-binaries +help +image-ocp-openshift-apiserver-operator +images +telepresence +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-golint +verify-govet 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 000000000..d763df461 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/operator.mk @@ -0,0 +1,11 @@ +self_dir := $(dir $(lastword $(MAKEFILE_LIST))) + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + 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 000000000..66ba5512e --- /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 000000000..ecd150941 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk @@ -0,0 +1,29 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +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 + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ +) 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 000000000..66ba5512e --- /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 000000000..344487e7e --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/test-unit.mk @@ -0,0 +1,19 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +test-unit: +ifndef JUNITFILE + $(GO) test $(GO_MOD_FLAGS) $(GO_TEST_FLAGS) $(GO_TEST_PACKAGES) +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) | gotest2junit > $(JUNITFILE) +endif +.PHONY: test-unit + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ +) 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 000000000..abb541f9f --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/golang/verify-update.mk @@ -0,0 +1,36 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +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-govet + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ +) 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 000000000..55bfbac09 --- /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 000000000..04b534ac2 --- /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 000000000..247de9417 --- /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 000000000..c8dc0ac46 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/controller-gen.mk @@ -0,0 +1,31 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +CONTROLLER_GEN_VERSION ?=v0.2.5 +CONTROLLER_GEN ?=$(PERMANENT_TMP_GOPATH)/bin/controller-gen +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)") +endif +.PHONY: ensure-controller-gen + +clean-controller-gen: + $(RM) '$(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 + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) 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 000000000..3a24a57e1 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/crd-schema-gen.mk @@ -0,0 +1,90 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +# $1 - crd file +# $2 - patch file +define patch-crd-yq + $(YQ) m -i -x '$(1)' '$(2)' + +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 := + +define diff-file + diff -Naup '$(1)' '$(2)' + +endef + +# $1 - apis +# $2 - manifests +# $3 - output +define run-crd-gen + '$(CONTROLLER_GEN)' \ + schemapatch:manifests="$(2)" \ + paths="$(subst $(empty) ,;,$(1))" \ + output:dir="$(3)" + $$(foreach p,$$(wildcard $(2)/*.crd.yaml-merge-patch),$$(call patch-crd-yq,$$(subst $(2),$(3),$$(basename $$(p))).yaml,$$(p))) + $$(foreach p,$$(wildcard $(2)/*.crd.yaml-patch),$$(call patch-crd-yaml-patch,$$(subst $(2),$(3),$$(basename $$(p))).yaml,$$(p))) +endef + + +# $1 - target name +# $2 - apis +# $3 - manifests +# $4 - output +define add-crd-gen-internal + +update-codegen-crds-$(1): ensure-controller-gen ensure-yq ensure-yaml-patch + $(call run-crd-gen,$(2),$(3),$(4)) +.PHONY: update-codegen-crds-$(1) + +update-codegen-crds: update-codegen-crds-$(1) +.PHONY: update-codegen-crds + +verify-codegen-crds-$(1): VERIFY_CODEGEN_CRD_TMP_DIR:=$$(shell mktemp -d) +verify-codegen-crds-$(1): ensure-controller-gen ensure-yq ensure-yaml-patch + $(call run-crd-gen,$(2),$(3),$$(VERIFY_CODEGEN_CRD_TMP_DIR)) + $$(foreach p,$$(wildcard $(3)/*crd.yaml),$$(call diff-file,$$(p),$$(subst $(3),$$(VERIFY_CODEGEN_CRD_TMP_DIR),$$(p)))) +.PHONY: verify-codegen-crds-$(1) + +verify-codegen-crds: verify-codegen-crds-$(1) +.PHONY: verify-codegen-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),$(4))) +endef + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ + ../../targets/openshift/controller-gen.mk \ + ../../targets/openshift/yq.mk \ + ../../targets/openshift/yaml-patch.mk \ +) 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 000000000..fafa8f9da --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-glide.mk @@ -0,0 +1,35 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) +scripts_dir :=$(self_dir)/../../../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 000000000..6b08b6cd9 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps-gomod.mk @@ -0,0 +1,41 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +# 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 \ + ) +.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 + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ +) 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 000000000..956698c2a --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/deps.mk @@ -0,0 +1,13 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +deps_gomod_mkfile := $(self_dir)/deps-gomod.mk +deps_glide_mkfile := $(self_dir)/deps-glide.mk +include $(addprefix $(self_dir), \ + ../../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 000000000..66ba5512e --- /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/images.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/images.mk new file mode 100644 index 000000000..00e76ac26 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/images.mk @@ -0,0 +1,29 @@ +# 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): + $(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/operator/doc.go b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/doc.go new file mode 100644 index 000000000..66ba5512e --- /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/release.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/release.mk new file mode 100644 index 000000000..07fc5605a --- /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 000000000..966778b16 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/operator/telepresence.mk @@ -0,0 +1,12 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) +scripts_dir :=$(shell realpath $(self_dir)../../../../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 000000000..3f20bb1ca --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/rpm.mk @@ -0,0 +1,41 @@ +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 + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ +) 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 000000000..d6569e609 --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yaml-patch.mk @@ -0,0 +1,32 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +YAML_PATCH ?=$(PERMANENT_TMP_GOPATH)/bin/yaml-patch +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/krishicks/yaml-patch/releases/download/v0.0.10/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)' + 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 + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) 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 000000000..2679e3add --- /dev/null +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/yq.mk @@ -0,0 +1,32 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +YQ ?=$(PERMANENT_TMP_GOPATH)/bin/yq +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/2.4.0/yq_$(GOHOSTOS)_$(GOHOSTARCH) -o '$(YQ)' + chmod +x '$(YQ)'; +else + $(info Using existing yq from "$(YQ)") +endif +.PHONY: ensure-yq + +clean-yq: + $(RM) '$(YQ)' + if [ -d '$(yq_dir)' ]; then rmdir --ignore-fail-on-non-empty -p '$(yq_dir)'; fi +.PHONY: clean-yq + +clean: clean-yq + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to use self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) 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 000000000..66ba5512e --- /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 000000000..d167465b1 --- /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 000000000..46812e939 --- /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/modules.txt b/vendor/modules.txt index 976394635..8a5505f79 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -175,6 +175,16 @@ github.com/onsi/gomega/types ## explicit; go 1.13 github.com/openshift/api/config/v1 github.com/openshift/api/operator/v1 +# github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7 +## 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 # github.com/openshift/client-go v0.0.0-20210331195552-cf6c2669e01f => github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0 ## explicit; go 1.13 github.com/openshift/client-go/config/clientset/versioned/scheme