Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Don't make unnecessary local changes in make targets #1794

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ The repository structure MUST be compliant with `operator-sdk` scaffolding, whic

Refer to the [Operator SDK documentation](https://sdk.operatorframework.io/docs/building-operators/golang/) how to generate new APIs, Webhook and other parts of the project.

If you make any change to the api definitions, please run `make update-bundle` to update the bundle manifest accordingly.

### Local run

Build the manifests, install the CRD and run the operator as a local process:
```bash
make bundle install run
make install run
```

### Deployment with webhooks
Expand Down Expand Up @@ -66,7 +68,7 @@ When deploying the operator into the cluster using `make deploy`, an image in th
* `IMG`, to override the entire image specification

```bash
IMG=docker.io/${USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate bundle container container-push deploy
IMG=docker.io/${USER}/opentelemetry-operator:dev-$(git rev-parse --short HEAD)-$(date +%s) make generate container container-push deploy
```

Your operator will be available in the `opentelemetry-operator-system` namespace.
Expand Down
40 changes: 28 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ TARGETALLOCATOR_IMG ?= ${IMG_PREFIX}/${TARGETALLOCATOR_IMG_REPO}:$(addprefix v,$
OPERATOROPAMPBRIDGE_IMG_REPO ?= operator-opamp-bridge
OPERATOROPAMPBRIDGE_IMG ?= ${IMG_PREFIX}/${OPERATOROPAMPBRIDGE_IMG_REPO}:$(addprefix v,${VERSION})

# Kustomization directory for local manifests
# Whenever we need to make any changes over the default manifests, we put them here
KUSTOMIZATION_DIR = ./dist
KUSTOMIZATION_BASE = config/default

# Options for 'bundle-build'
ifneq ($(origin CHANNELS), undefined)
BUNDLE_CHANNELS := --channels=$(CHANNELS)
Expand Down Expand Up @@ -83,12 +88,10 @@ SED ?= $(shell which gsed 2>/dev/null || which sed)
.PHONY: ensure-generate-is-noop
ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION)
ensure-generate-is-noop: USER=open-telemetry
ensure-generate-is-noop: set-image-controller generate bundle
@# on make bundle config/manager/kustomization.yaml includes changes, which should be ignored for the below check
@git restore config/manager/kustomization.yaml
ensure-generate-is-noop: update-bundle
@git diff -s --exit-code apis/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && git diff && exit 1)
@git diff -s --exit-code bundle.Dockerfile || (echo "Build failed: the bundle.Dockerfile file has been changed. The file should be the same as generated one. Run 'make bundle' and update your PR." && git diff && exit 1)
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make update-bundle' and update your PR." && git diff && exit 1)
@git diff -s --exit-code bundle.Dockerfile || (echo "Build failed: the bundle.Dockerfile file has been changed. The file should be the same as generated one. Run 'make update-bundle' and update your PR." && git diff && exit 1)
@git diff -s --exit-code docs/api.md || (echo "Build failed: the api.md file has been changed but the generated api.md file isn't up to date. Run 'make api-docs' and update your PR." && git diff && exit 1)

.PHONY: all
Expand Down Expand Up @@ -134,25 +137,30 @@ uninstall: manifests kustomize

# Set the controller image parameters
.PHONY: set-image-controller
set-image-controller: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
set-image-controller: manifests kustomize create-kustomization
cd $(KUSTOMIZATION_DIR) && $(KUSTOMIZE) edit set image controller=${IMG}

# Deploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: deploy
deploy: set-image-controller
$(KUSTOMIZE) build config/default | kubectl apply -f -
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) | kubectl apply -f -
go run hack/check-operator-ready.go 300

# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: undeploy
undeploy: set-image-controller
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

# Generates the released manifests
.PHONY: release-artifacts
release-artifacts: set-image-controller
mkdir -p dist
$(KUSTOMIZE) build config/default -o dist/opentelemetry-operator.yaml
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) -o dist/opentelemetry-operator.yaml

.PHONY: create-kustomization
create-kustomization:
mkdir -p $(KUSTOMIZATION_DIR)
rm -f $(KUSTOMIZATION_DIR)/kustomization.yaml
cd $(KUSTOMIZATION_DIR) && $(KUSTOMIZE) create --resources ../$(KUSTOMIZATION_BASE)

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
Expand Down Expand Up @@ -436,10 +444,18 @@ operator-sdk:

# Generate bundle manifests and metadata, then validate generated files.
.PHONY: bundle
bundle: KUSTOMIZATION_BASE = config/manifests
bundle: kustomize operator-sdk manifests set-image-controller
$(OPERATOR_SDK) generate kustomize manifests -q
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(KUSTOMIZE) build $(KUSTOMIZATION_DIR) | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(OPERATOR_SDK) bundle validate ./bundle

# Update the bundle with semantic changes. This will intentionally ignore some changes to metadata, like creation time.
.PHONY: update-bundle
update-bundle: KUSTOMIZATION_BASE = config/manifests
update-bundle: VERSION = $(shell cat versions.txt | grep "operator=" | cut -d "=" -f 2) # the most recent release
update-bundle: USER = open-telemetry
update-bundle: bundle
./hack/ignore-createdAt-bundle.sh

# Build the bundle image, used only for local dev purposes
Expand Down
Loading