diff --git a/.goreleaser.yml b/.goreleaser.yml index df644a264..cfd6bd939 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -20,7 +20,7 @@ builds: - ppc64le - s390x - id: catalogd - main: ./catalogd/cmd/catalogd/ + main: ./cmd/catalogd/ binary: catalogd asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}" gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}" @@ -38,7 +38,7 @@ builds: dockers: - image_templates: - "{{ .Env.OPERATOR_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64" - dockerfile: Dockerfile + dockerfile: Dockerfile.operator-controller goos: linux goarch: amd64 use: buildx @@ -46,7 +46,7 @@ dockers: - "--platform=linux/amd64" - image_templates: - "{{ .Env.OPERATOR_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-arm64" - dockerfile: Dockerfile + dockerfile: Dockerfile.operator-controller goos: linux goarch: arm64 use: buildx @@ -54,7 +54,7 @@ dockers: - "--platform=linux/arm64" - image_templates: - "{{ .Env.OPERATOR_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-ppc64le" - dockerfile: Dockerfile + dockerfile: Dockerfile.operator-controller goos: linux goarch: ppc64le use: buildx @@ -62,7 +62,7 @@ dockers: - "--platform=linux/ppc64le" - image_templates: - "{{ .Env.OPERATOR_CONTROLLER_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-s390x" - dockerfile: Dockerfile + dockerfile: Dockerfile.operator-controller goos: linux goarch: s390x use: buildx @@ -70,7 +70,7 @@ dockers: - "--platform=linux/s390x" - image_templates: - "{{ .Env.CATALOGD_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64" - dockerfile: catalogd/Dockerfile + dockerfile: Dockerfile.catalogd goos: linux goarch: amd64 use: buildx @@ -78,7 +78,7 @@ dockers: - "--platform=linux/amd64" - image_templates: - "{{ .Env.CATALOGD_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-arm64" - dockerfile: catalogd/Dockerfile + dockerfile: Dockerfile.catalogd goos: linux goarch: arm64 use: buildx @@ -86,7 +86,7 @@ dockers: - "--platform=linux/arm64" - image_templates: - "{{ .Env.CATALOGD_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-ppc64le" - dockerfile: catalogd/Dockerfile + dockerfile: Dockerfile.catalogd goos: linux goarch: ppc64le use: buildx @@ -94,7 +94,7 @@ dockers: - "--platform=linux/ppc64le" - image_templates: - "{{ .Env.CATALOGD_IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-s390x" - dockerfile: catalogd/Dockerfile + dockerfile: Dockerfile.catalogd goos: linux goarch: s390x use: buildx diff --git a/catalogd/Dockerfile b/Dockerfile.catalogd similarity index 100% rename from catalogd/Dockerfile rename to Dockerfile.catalogd diff --git a/Dockerfile b/Dockerfile.operator-controller similarity index 100% rename from Dockerfile rename to Dockerfile.operator-controller diff --git a/Makefile b/Makefile index 935ef272e..e74165a3b 100644 --- a/Makefile +++ b/Makefile @@ -9,23 +9,28 @@ export ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) GOLANG_VERSION := $(shell sed -En 's/^go (.*)$$/\1/p' "go.mod") # Image URL to use all building/pushing image targets -ifeq ($(origin IMAGE_REPO), undefined) -IMAGE_REPO := quay.io/operator-framework/operator-controller +ifeq ($(origin IMG_NAMESPACE), undefined) +IMG_NAMESPACE := quay.io/operator-framework endif -export IMAGE_REPO +export IMG_NAMESPACE -ifeq ($(origin CATALOG_IMAGE_REPO), undefined) -CATALOG_IMAGE_REPO := quay.io/operator-framework/catalogd +ifeq ($(origin OPERATOR_CONTROLLER_IMAGE_REPO), undefined) +OPERATOR_CONTROLLER_IMAGE_REPO := $(IMG_NAMESPACE)/operator-controller endif -export CATALOG_IMAGE_REPO +export OPERATOR_CONTROLLER_IMAGE_REPO + +ifeq ($(origin CATALOGD_IMAGE_REPO), undefined) +CATALOGD_IMAGE_REPO := $(IMG_NAMESPACE)/catalogd +endif +export CATALOGD_IMAGE_REPO ifeq ($(origin IMAGE_TAG), undefined) IMAGE_TAG := devel endif export IMAGE_TAG -IMG := $(IMAGE_REPO):$(IMAGE_TAG) -CATALOGD_IMG := $(CATALOG_IMAGE_REPO):$(IMAGE_TAG) +OPERATOR_CONTROLLER_IMG := $(OPERATOR_CONTROLLER_IMAGE_REPO):$(IMAGE_TAG) +CATALOGD_IMG := $(CATALOGD_IMAGE_REPO):$(IMAGE_TAG) # Define dependency versions (use go.mod if we also use Go code from dependency) export CERT_MGR_VERSION := v1.15.3 @@ -263,8 +268,8 @@ e2e-coverage: .PHONY: kind-load kind-load: $(KIND) #EXHELP Loads the currently constructed images into the KIND cluster. - $(CONTAINER_RUNTIME) save $(IMG) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME) - IMAGE_REPO=$(CATALOG_IMAGE_REPO) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) $(MAKE) -C catalogd kind-load + $(CONTAINER_RUNTIME) save $(OPERATOR_CONTROLLER_IMG) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME) + $(CONTAINER_RUNTIME) save $(CATALOGD_IMG) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME) .PHONY: kind-deploy kind-deploy: export MANIFEST := ./operator-controller.yaml @@ -304,8 +309,9 @@ export GO_BUILD_FLAGS := export GO_BUILD_LDFLAGS := -s -w \ -X '$(VERSION_PATH).version=$(VERSION)' \ -BINARIES=operator-controller +BINARIES=operator-controller catalogd +.PHONY: $(BINARIES) $(BINARIES): go build $(GO_BUILD_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o $(BUILDBIN)/$@ ./cmd/$@ @@ -333,9 +339,9 @@ wait: kubectl wait --for=condition=Ready --namespace=$(CATALOGD_NAMESPACE) certificate/catalogd-service-cert # Avoid upgrade test flakes when reissuing cert .PHONY: docker-build -docker-build: build-linux #EXHELP Build docker image for operator-controller and catalog with GOOS=linux and local GOARCH. - $(CONTAINER_RUNTIME) build -t $(IMG) -f Dockerfile ./bin/linux - IMAGE_REPO=$(CATALOG_IMAGE_REPO) $(MAKE) -C catalogd build-container +docker-build: build-linux #EXHELP Build docker image for operator-controller and catalog with GOOS=linux and local GOARCH. + $(CONTAINER_RUNTIME) build -t $(OPERATOR_CONTROLLER_IMG) -f Dockerfile.operator-controller ./bin/linux + $(CONTAINER_RUNTIME) build -t $(CATALOGD_IMG) -f Dockerfile.catalogd ./bin/linux #SECTION Release ifeq ($(origin ENABLE_RELEASE_PIPELINE), undefined) @@ -350,7 +356,7 @@ export GORELEASER_ARGS .PHONY: release release: $(GORELEASER) #EXHELP Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release. - OPERATOR_CONTROLLER_IMAGE_REPO=$(IMAGE_REPO) CATALOGD_IMAGE_REPO=$(CATALOG_IMAGE_REPO) $(GORELEASER) $(GORELEASER_ARGS) + OPERATOR_CONTROLLER_IMAGE_REPO=$(OPERATOR_CONTROLLER_IMAGE_REPO) CATALOGD_IMAGE_REPO=$(CATALOGD_IMAGE_REPO) $(GORELEASER) $(GORELEASER_ARGS) .PHONY: quickstart quickstart: export MANIFEST := https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml diff --git a/Tiltfile b/Tiltfile index 6a77c9cf9..2d5e36381 100644 --- a/Tiltfile +++ b/Tiltfile @@ -15,9 +15,9 @@ catalogd = { 'image': 'quay.io/operator-framework/catalogd', 'yaml': 'config/overlays/tilt-local-dev/catalogd', 'binaries': { - './catalogd/cmd/catalogd': 'catalogd-controller-manager', + './cmd/catalogd': 'catalogd-controller-manager', }, - 'deps': ['api', 'catalogd/cmd/catalogd', 'internal/catalogd', 'internal/shared', 'go.mod', 'go.sum'], + 'deps': ['api', 'cmd/catalogd', 'internal/catalogd', 'internal/shared', 'go.mod', 'go.sum'], 'starting_debug_port': 20000, } diff --git a/catalogd/Makefile b/catalogd/Makefile deleted file mode 100644 index 19f60fb0e..000000000 --- a/catalogd/Makefile +++ /dev/null @@ -1,112 +0,0 @@ -# Setting SHELL to bash allows bash commands to be executed by recipes. -# Options are set to exit when a recipe line exits non-zero or a piped command fails. -SHELL := /usr/bin/env bash -o pipefail -.SHELLFLAGS := -ec - -ifeq ($(origin IMAGE_REPO), undefined) -IMAGE_REPO := quay.io/operator-framework/catalogd -endif -export IMAGE_REPO - -ifeq ($(origin IMAGE_TAG), undefined) -IMAGE_TAG := devel -endif -export IMAGE_TAG - -IMAGE := $(IMAGE_REPO):$(IMAGE_TAG) - -ifneq (, $(shell command -v docker 2>/dev/null)) -CONTAINER_RUNTIME := docker -else ifneq (, $(shell command -v podman 2>/dev/null)) -CONTAINER_RUNTIME := podman -else -$(warning Could not find docker or podman in path! This may result in targets requiring a container runtime failing!) -endif - -# bingo manages consistent tooling versions for things like kind, kustomize, etc. -include ./../.bingo/Variables.mk - -# Dependencies -export CERT_MGR_VERSION := v1.15.3 -ENVTEST_SERVER_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/') - -# Cluster configuration -ifeq ($(origin KIND_CLUSTER_NAME), undefined) -KIND_CLUSTER_NAME := catalogd -endif - -##@ General - -# The help target prints out all targets with their descriptions organized -# beneath their categories. The categories are represented by '##@' and the -# target descriptions by '##'. The awk commands is responsible for reading the -# entire set of makefiles included in this invocation, looking for lines of the -# file as xyz: ## something, and then pretty-format the target and help. Then, -# if there's a line with ##@ something, that gets pretty-printed as a category. -# More info on the usage of ANSI control characters for terminal formatting: -# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters -# More info on the awk command: -# http://linuxcommand.org/lc3_adv_awk.php - -.PHONY: help -help: ## Display this help. - awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -.DEFAULT_GOAL := help - -##@ Development - -clean: ## Remove binaries and test artifacts - rm -rf bin - -##@ Build - -BINARIES=catalogd -LINUX_BINARIES=$(join $(addprefix linux/,$(BINARIES)), ) - -# Build info -ifeq ($(origin VERSION), undefined) -VERSION := $(shell git describe --tags --always --dirty) -endif -export VERSION - -export VERSION_PKG := $(shell go list -m)/internal/shared/version - -export GIT_COMMIT := $(shell git rev-parse HEAD) -export GIT_VERSION := $(shell git describe --tags --always --dirty) -export GIT_TREE_STATE := $(shell [ -z "$(shell git status --porcelain)" ] && echo "clean" || echo "dirty") -export GIT_COMMIT_DATE := $(shell TZ=UTC0 git show --quiet --date=format:'%Y-%m-%dT%H:%M:%SZ' --format="%cd") - -export CGO_ENABLED := 0 -export GO_BUILD_ASMFLAGS := all=-trimpath=${PWD} -export GO_BUILD_LDFLAGS := -s -w \ - -X "$(VERSION_PKG).gitVersion=$(GIT_VERSION)" \ - -X "$(VERSION_PKG).gitCommit=$(GIT_COMMIT)" \ - -X "$(VERSION_PKG).gitTreeState=$(GIT_TREE_STATE)" \ - -X "$(VERSION_PKG).commitDate=$(GIT_COMMIT_DATE)" -export GO_BUILD_GCFLAGS := all=-trimpath=${PWD} -export GO_BUILD_TAGS := containers_image_openpgp - -BUILDCMD = go build -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o $(BUILDBIN)/$(notdir $@) ./cmd/$(notdir $@) - -.PHONY: build go-build-local $(BINARIES) -build: go-build-local ## Build binaries for current GOOS and GOARCH. -go-build-local: $(BINARIES) -$(BINARIES): BUILDBIN = bin -$(BINARIES): - $(BUILDCMD) - -.PHONY: build-linux go-build-linux $(LINUX_BINARIES) -build-linux: go-build-linux ## Build binaries for GOOS=linux and local GOARCH. -go-build-linux: $(LINUX_BINARIES) -$(LINUX_BINARIES): BUILDBIN = bin/linux -$(LINUX_BINARIES): - GOOS=linux $(BUILDCMD) - -.PHONY: build-container -build-container: build-linux ## Build docker image for catalogd. - $(CONTAINER_RUNTIME) build -f Dockerfile -t $(IMAGE) ./bin/linux - -.PHONY: kind-load -kind-load: $(KIND) ## Load the built images onto the local cluster - $(CONTAINER_RUNTIME) save $(IMAGE) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME) - diff --git a/catalogd/cmd/catalogd/main.go b/cmd/catalogd/main.go similarity index 100% rename from catalogd/cmd/catalogd/main.go rename to cmd/catalogd/main.go