From 093a94b02f735455a8a32e1f56029a41b0222e32 Mon Sep 17 00:00:00 2001 From: upbound-bot Date: Thu, 28 Nov 2024 10:30:14 +0000 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=94=84=20synced=20local=20'Makefile'?= =?UTF-8?q?=20with=20remote=20'shared/configurations/Makefile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 298 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 210 insertions(+), 88 deletions(-) diff --git a/Makefile b/Makefile index a61cd2c..5597e56 100644 --- a/Makefile +++ b/Makefile @@ -1,122 +1,244 @@ -# Project Setup -PROJECT_NAME := configuration-aws-eks -PROJECT_REPO := github.com/upbound/$(PROJECT_NAME) +# ==================================================================================== +# Crossplane Configuration Package Makefile +# ==================================================================================== -# NOTE(hasheddan): the platform is insignificant here as Configuration package -# images are not architecture-specific. We constrain to one platform to avoid -# needlessly pushing a multi-arch image. -PLATFORMS ?= linux_amd64 --include build/makelib/common.mk +# USAGE DOCUMENTATION +# ==================================================================================== +# +# This is a generic Makefile to be used across repositories building Crossplane +# configuration packages. It provides a comprehensive set of targets for development, +# testing, and deployment. +# +# PROJECT CONFIGURATION +# ------------------- +# Create a project.mk file in your repository to configure project-specific settings. +# Required variables: +# - PROJECT_NAME: Name of your Crossplane configuration package +# +# Example project.mk: +# PROJECT_NAME = custom-config +# UPTEST_DEFAULT_TIMEOUT = 3600s +# UPTEST_SKIP_IMPORT = true +# +# PRIMARY TARGETS +# -------------- +# +# Development Tools: +# ----------------- +# - `yamllint` +# Runs yamllint recursively on all files in the `api` folder to ensure YAML +# quality and consistency +# +# - `check-examples` +# Validates consistency between example configurations and dependencies: +# - Compares Function package versions in examples/ against crossplane.yaml +# - Ensures all Function versions in examples match dependency declarations +# - Helps prevent version mismatches that could cause deployment issues +# Example errors: +# - Example using function-foo:v1.2.0 while crossplane.yaml specifies v1.1.0 +# - Missing Function dependencies in crossplane.yaml that are used in examples +# Usage: Run before committing changes to ensure example validity +# +# Rendering and Validation: +# ----------------- +# - `render` +# Renders the composition output for rapid feedback during template development. +# Requirements: +# - Claims must have these annotations: +# render.crossplane.io/composition-path: apis/pat/composition.yaml +# render.crossplane.io/function-path: examples/functions.yaml +# Note: This only populates the cache. Use `render.show` to view output. +# +# - `render.show` +# Displays the rendered YAML output. Useful for: +# - Manual validation +# - Piping to validation tools, e.g.: +# make render.show | crossplane beta validate crossplane.yaml - +# +# Testing: +# ----------------- +# - `render.test` +# Executes kcl-unit tests on rendered manifests. Tests should be: +# - Located in the `test` folder +# - Written as standard kcl-tests +# This ensures the rendered output meets expected specifications. +# +# - `e2e` +# Comprehensive end-to-end testing, including: +# - Cluster creation +# - Configuration setup +# - Testing create, import, and delete operations +# +# Cloud Provider Requirements: +# For configurations creating cloud provider resources, set: +# UPTEST_CLOUD_CREDENTIALS - Provider-specific credentials: +# - AWS: export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials) +# - GCP: export UPTEST_CLOUD_CREDENTIALS=$(cat gcp-sa.json) +# - Azure: export UPTEST_CLOUD_CREDENTIALS=$(cat azure.json) +# +# Configuration Options: +# - UPTEST_SKIP_DELETE (default: false) +# Skip deletion testing of created resources +# - UPTEST_SKIP_UPDATE (default: false) +# Skip testing of claim updates +# - UPTEST_SKIP_IMPORT (default: false) +# Skip testing of resource imports +# +# Example Usage: +# make e2e UPTEST_SKIP_DELETE=true +# +# LANGUAGE-SPECIFIC OPTIONS +# ------------------------ +# +# KCL Support: +# - KCL_COMPOSITION_PATH +# Path to the KCL file generating composition.yaml +# Default: apis/kcl/generate.k +# +# NOTE: The platform setting is constrained to linux_amd64 as Configuration package +# images are not architecture-specific. This avoids unnecessary multi-arch image +# generation. # ==================================================================================== -# Setup Kubernetes tools +# Project Configuration +# ==================================================================================== + +# Include project.mk for project specific settings +include project.mk + +ifndef PROJECT_NAME + $(error PROJECT_NAME is not set. Please create `project.mk` and set it there.) +endif -UP_VERSION = v0.32.1 +# Project Configuration +# ------------------ +PROJECT_REPO := github.com/upbound/$(PROJECT_NAME) +PLATFORMS ?= linux_amd64 + +# Tool Versions +# ------------------ +UP_VERSION = v0.35.0 UP_CHANNEL = stable -UPTEST_VERSION = v0.11.1 -CROSSPLANE_CLI_VERSION=v1.16.0 +CROSSPLANE_CLI_VERSION = v1.18.0 +CROSSPLANE_VERSION = v1.18.0-up.1 +UPTEST_VERSION = v1.2.0 --include build/makelib/k8s_tools.mk -# ==================================================================================== -# Setup XPKG +# Crossplane Configuration +# ------------------ +CROSSPLANE_CHART_REPO = https://charts.upbound.io/stable +CROSSPLANE_CHART_NAME = universal-crossplane +CROSSPLANE_NAMESPACE = upbound-system +CROSSPLANE_ARGS = "--enable-usages" +KIND_CLUSTER_NAME ?= uptest-$(PROJECT_NAME) + +# XPKG Configuration +# ------------------ XPKG_DIR = $(shell pwd) -XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml +XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml,.cache/render/* XPKG_REG_ORGS ?= xpkg.upbound.io/upbound -# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are -# inferred. +# NOTE: Skip promoting on xpkg.upbound.io as channel tags are inferred XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/upbound XPKGS = $(PROJECT_NAME) --include build/makelib/xpkg.mk -CROSSPLANE_VERSION = 1.16.0-up.1 -CROSSPLANE_CHART_REPO = https://charts.upbound.io/stable -CROSSPLANE_CHART_NAME = universal-crossplane -CROSSPLANE_NAMESPACE = upbound-system -CROSSPLANE_ARGS = "--enable-usages" -KIND_CLUSTER_NAME = uptest-$(PROJECT_NAME) +# Testing Configuration +# ------------------ +UPTEST_LOCAL_DEPLOY_TARGET = local.xpkg.deploy.configuration.$(PROJECT_NAME) +UPTEST_DEFAULT_TIMEOUT ?= 2400s + +# KCL Configuration +# ------------------ +KCL_COMPOSITION_PATH ?= apis/kcl/generate.k +LANG_KCL := $(shell find ./apis -type f -name '*.k') + +# Include makelib files +# ------------------ +-include build/makelib/common.mk +-include build/makelib/k8s_tools.mk +-include build/makelib/xpkg.mk -include build/makelib/local.xpkg.mk -include build/makelib/controlplane.mk +-include build/makelib/uptest.mk # ==================================================================================== # Targets +# ==================================================================================== -# run `make help` to see the targets and options - +# Initial Setup +# ------------------ # We want submodules to be set up the first time `make` is run. # We manage the build/ folder and its Makefiles as a submodule. # The first time `make` is run, the includes of build/*.mk files will # all fail, and this target will be run. The next time, the default as defined # by the includes will be run instead. -fallthrough: submodules +fallthrough: submodules ## Initial setup and submodule initialization @echo Initial setup complete. Running make again . . . @make -submodules: ## Update the submodules, such as the common build scripts. +submodules: ## Update the submodules, including common build scripts @git submodule sync @git submodule update --init --recursive -# We must ensure up is installed in tool cache prior to build as including the k8s_tools machinery prior to the xpkg -# machinery sets UP to point to tool cache. -build.init: $(UP) kcl - -# ==================================================================================== -# End to End Testing - -# This target requires the following environment variables to be set: -# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials) -# - To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately. -# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl. -# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource -SKIP_DELETE ?= -uptest: $(UPTEST) $(KUBECTL) $(KUTTL) - @$(INFO) running automated tests - @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) CROSSPLANE_CLI=$(CROSSPLANE_CLI) $(UPTEST) e2e "${UPTEST_EXAMPLE_LIST}" --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 $(SKIP_DELETE) || $(FAIL) - @$(OK) running automated tests - -# This target requires the following environment variables to be set: -# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials) -# Use `make e2e SKIP_DELETE=--skip-delete` to skip deletion of resources created during the test. -e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest ## Run uptest together with all dependencies. Use `make e2e SKIP_DELETE=--skip-delete` to skip deletion of resources. - -kcl: $(KCL) ## Generate KCL-based Composition - $(KCL) apis/kcl/generate.k - -render: kcl $(CROSSPLANE_CLI) ${YQ} - @indir="./examples"; \ - for file in $$(find $$indir -type f -name '*.yaml' ); do \ - doc_count=$$(grep -c '^---' "$$file"); \ - if [[ $$doc_count -gt 0 ]]; then \ - continue; \ - fi; \ - COMPOSITION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/composition-path"' $$file); \ - FUNCTION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/function-path"' $$file); \ - ENVIRONMENT=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/environment-path"' $$file); \ - OBSERVE=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/observe-path"' $$file); \ - if [[ "$$ENVIRONMENT" == "null" ]]; then \ - ENVIRONMENT=""; \ - fi; \ - if [[ "$$OBSERVE" == "null" ]]; then \ - OBSERVE=""; \ - fi; \ - if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \ - continue; \ - fi; \ - ENVIRONMENT=$${ENVIRONMENT=="null" ? "" : $$ENVIRONMENT}; \ - OBSERVE=$${OBSERVE=="null" ? "" : $$OBSERVE}; \ - $(CROSSPLANE_CLI) beta render $$file $$COMPOSITION $$FUNCTION $${ENVIRONMENT:+-e $$ENVIRONMENT} $${OBSERVE:+-o $$OBSERVE} -x; \ +# Build Targets +# ------------------ +# We must ensure up is installed in tool cache prior to build as including the k8s_tools +# machinery prior to the xpkg machinery sets UP to point to tool cache. +build.init: $(UP) ## Initialize build requirements + +# KCL Targets +# ------------------ +ifdef LANG_KCL +kcl: $(KCL) ## Generate KCL-based Composition + @$(INFO) Generating kcl composition + @$(KCL) $(KCL_COMPOSITION_PATH) 1>/dev/null + @$(OK) Generated kcl composition + +render: kcl ## Render the composition output +build.init: kcl +.PHONY: kcl +endif + +# Testing Targets +# ------------------ +render.test: $(CROSSPLANE_CLI) $(KCL) render ## Test rendered compositions + @for RENDERED_COMPOSITION in $$(find .cache/render -maxdepth 1 -type f -name '*.yaml'); do \ + $(INFO) "Testing $${RENDERED_COMPOSITION}"; \ + export RENDERED_COMPOSITION; \ + $(KCL) test test/ && \ + $(OK) "Success testing \"$${RENDERED_COMPOSITION}\"!" || \ + ($(ERR) "Failure testing \"$${RENDERED_COMPOSITION}\"!" && exit 1); \ done -yamllint: ## Static yamllint check - @$(INFO) running yamllint - @yamllint ./apis || $(FAIL) - @$(OK) running yamllint - -kcllint: ## Static kcllint check - @$(INFO) running kcllint - @$(KCL) lint ./apis/kcl/ || $(FAIL) - @$(OK) running kcllint +check-examples: ## Validate package versions in examples match dependencies + @$(INFO) Checking if package versions in dependencies match examples + @FN_EXAMPLES=$$( \ + find examples -type f -name "*.yaml" | \ + xargs $(YQ) -r -o=json 'select(.kind == "Function" and (.apiVersion | test("^pkg.crossplane.io/"))) | .spec.package' | \ + sort -u); \ + FN_DEPS=$$( \ + $(YQ) '.spec.dependsOn[] | select(.function != null) | (.function + ":" + .version)' crossplane.yaml | \ + sort -u \ + ); \ + if [ "$$FN_EXAMPLES" != "$$FN_DEPS" ]; then \ + echo "Function package versions in examples and in crossplane.yaml don't match!"; \ + echo "" ; \ + echo "Versions in dependencies:"; \ + echo "---" ; \ + echo "$$FN_DEPS"; \ + echo "" ; \ + echo "Versions in examples:"; \ + echo "---" ; \ + echo "$$FN_EXAMPLES"; \ + exit 1; \ + fi; + @$(OK) Package versions are sane + +# Help Targets +# ------------------ +help: help.local ## Display this help message help.local: + @echo "Available targets:" + @echo @grep -E '^[a-zA-Z_-]+.*:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -.PHONY: uptest e2e render yamllint kcllint help.local +.PHONY: uptest e2e render yamllint help help.local check-examples render.test From 97b48e5d1beac1434a7ff022b17610a1118a5c4a Mon Sep 17 00:00:00 2001 From: upbound-bot Date: Thu, 28 Nov 2024 10:30:14 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=84=20synced=20local=20'.github/re?= =?UTF-8?q?novate.json5'=20with=20remote=20'shared/configurations/renovate?= =?UTF-8?q?.json5'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/renovate.json5 | 120 ++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 48 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 42f6442..feb2c0e 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,53 +1,77 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:recommended", - "helpers:pinGitHubActionDigests", - ":semanticCommits" + $schema: 'https://docs.renovatebot.com/renovate-schema.json', + extends: [ + 'config:recommended', + 'helpers:pinGitHubActionDigests', + ':semanticCommits', ], - "rebaseWhen": "conflicted", - "prConcurrentLimit": 5, - "baseBranches": ["main"], - "labels": ["automated"], - "customManagers": [ + rebaseWhen: 'conflicted', + prConcurrentLimit: 5, + baseBranches: [ + 'main', + ], + labels: [ + 'automated', + ], + packageRules: [ + { + matchFileNames: [ + '.github/**', + ], + groupName: 'github-actions dependencies', + }, + { + matchFileNames: [ + 'crossplane.yaml', + ], + groupName: 'crossplane dependencies', + }, + { + matchFileNames: [ + 'Makefile', + ], + groupName: 'Makefile dependencies', + }, + ], + customManagers: [ { - "customType": "regex", - "description": "Bump up version in the Makefile", - "fileMatch": ["^Makefile$"], - "matchStrings": [ - "UP_VERSION = (?.*?)\\n" - ], - "datasourceTemplate": "github-releases", - "depNameTemplate": "upbound/up", - }, { - "customType": "regex", - "description": "Bump uptest version in the Makefile", - "fileMatch": ["^Makefile$"], - "matchStrings": [ - "UPTEST_VERSION = (?.*?)\\n" - ], - "datasourceTemplate": "github-releases", - "depNameTemplate": "upbound/uptest", - }, { - "customType": "regex", - "description": "Bump Crossplane(UXP) version in the Makefile", - "fileMatch": ["^Makefile$"], - "matchStrings": [ - "CROSSPLANE_VERSION = (?.*?)\\n" - ], - "datasourceTemplate": "github-releases", - "versioningTemplate": "regex:^v?(?\\d+)\\.(?\\d+)\\.(?\\d+)-up.1$", - "extractVersionTemplate": "^v(?.*)$", - "depNameTemplate": "upbound/universal-crossplane", - }, { - "customType": "regex", - "description": "Bump providers/functions/configurations in crossplane.yaml", - "fileMatch": ["crossplane.yaml"], - "matchStrings": [ - "#\\s*renovate:\\s*datasource=(?[^\\s]+)\\s+depName=(?[^\\s]+)\\s*\\n\\s*version:\\s*\"(?[^\"]+)\"" - ], - "datasourceTemplate": "{{{datasource}}}", - "depNameTemplate": "{{{depName}}}", - } + customType: 'regex', + description: 'Bump up version in the Makefile', + fileMatch: [ + '^Makefile$', + ], + matchStrings: [ + 'UP_VERSION = (?.*?)\\n', + ], + datasourceTemplate: 'github-releases', + depNameTemplate: 'upbound/up', + }, + { + customType: 'regex', + description: 'Bump uptest version in the Makefile', + fileMatch: [ + '^Makefile$', + ], + matchStrings: [ + 'UPTEST_VERSION = (?.*?)\\n', + ], + datasourceTemplate: 'github-releases', + depNameTemplate: 'upbound/uptest', + }, + { + customType: 'regex', + description: 'Bump providers/functions/configurations in crossplane.yaml', + fileMatch: [ + 'crossplane.yaml', + ], + matchStrings: [ + '#\\s*renovate:\\s*datasource=(?[^\\s]+)\\s+depName=(?[^\\s]+)\\s*\\n\\s*version:\\s*"(?[^"]+)"', + ], + datasourceTemplate: '{{{datasource}}}', + depNameTemplate: '{{{depName}}}', + }, ], + "git-submodules": { + "enabled": true + } } From a18e2c6ff6ce6e14d4e6b450449127dc1e6396e3 Mon Sep 17 00:00:00 2001 From: upbound-bot Date: Thu, 28 Nov 2024 10:30:14 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=84=20synced=20local=20'.gitmodule?= =?UTF-8?q?s'=20with=20remote=20'shared/configurations/.gitmodules'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 8f84209..394e1ee 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "build"] path = build - url = https://github.com/crossplane/build + url = https://github.com/crossplane/build.git From 61bc5cd749200aef233874c2a167ed9bc4ac7b5a Mon Sep 17 00:00:00 2001 From: upbound-bot Date: Thu, 28 Nov 2024 10:30:14 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=94=84=20created=20local=20'.github/C?= =?UTF-8?q?ODEOWNERS'=20from=20remote=20'.github/CODEOWNERS'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..7e300e5 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @upbound/team-customer-success From 31cc4ba0931fdd1b4889f204063361e89ee1d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=A4sser?= Date: Thu, 28 Nov 2024 12:00:44 +0100 Subject: [PATCH 5/5] Update build-submodule and add project.mk --- build | 2 +- project.mk | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 project.mk diff --git a/build b/build index 6b79068..1ed1933 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 6b79068c8236de792804caf8957ba5bc9ffec246 +Subproject commit 1ed19332b947c449795fd016f3c21ee0a64930fd diff --git a/project.mk b/project.mk new file mode 100644 index 0000000..88a1805 --- /dev/null +++ b/project.mk @@ -0,0 +1,3 @@ +PROJECT_NAME := configuration-aws-eks +UPTEST_INPUT_MANIFESTS := examples/kcl/network-xr.yaml,examples/kcl/eks-xr.yaml,examples/pat/network-xr.yaml,examples/pat/eks-xr.yaml +UPTEST_SKIP_UPDATE := true