From f689969a19c78879941adbbfdde82e2a8b650c16 Mon Sep 17 00:00:00 2001 From: Christopher Haar Date: Mon, 31 Jul 2023 12:15:25 +0200 Subject: [PATCH] feat(rootGroup): make the rootGroup for crds configurable via prepare.sh (#50) Signed-off-by: Christopher Haar --- config/provider.go | 1 + hack/prepare.sh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/config/provider.go b/config/provider.go index a8bc30d..685b1a3 100644 --- a/config/provider.go +++ b/config/provider.go @@ -27,6 +27,7 @@ var providerMetadata string // GetProvider returns provider configuration func GetProvider() *ujconfig.Provider { pc := ujconfig.NewProvider([]byte(providerSchema), resourcePrefix, modulePath, []byte(providerMetadata), + ujconfig.WithRootGroup("template.upbound.io"), ujconfig.WithIncludeList(ExternalNameConfigured()), ujconfig.WithFeaturesPackage("internal/features"), ujconfig.WithDefaultResourceOptions( diff --git a/hack/prepare.sh b/hack/prepare.sh index 8afe7ef..d365a1d 100755 --- a/hack/prepare.sh +++ b/hack/prepare.sh @@ -4,6 +4,7 @@ set -euox pipefail read -r -p "Lower case provider name (ex. github): " PROVIDER_NAME_LOWER read -r -p "Normal case provider name (ex. GitHub): " PROVIDER_NAME_NORMAL read -r -p "Organization (ex. upbound, my-org-name): " ORGANIZATION_NAME +read -r -p "CRD rootGroup (ex. upbound.io, crossplane.io): " CRD_ROOT_GROUP REPLACE_FILES='./* ./.github :!build/** :!go.* :!hack/prepare.sh' # shellcheck disable=SC2086 @@ -14,6 +15,11 @@ git grep -l 'template' -- ${REPLACE_FILES} | xargs sed -i.bak "s/template/${PROV git grep -l "upbound/provider-${PROVIDER_NAME_LOWER}" -- ${REPLACE_FILES} | xargs sed -i.bak "s|upbound/provider-${PROVIDER_NAME_LOWER}|${ORGANIZATION_NAME}/provider-${PROVIDER_NAME_LOWER}|g" # shellcheck disable=SC2086 git grep -l 'Template' -- ${REPLACE_FILES} | xargs sed -i.bak "s/Template/${PROVIDER_NAME_NORMAL}/g" +# shellcheck disable=SC2086 +git grep -l "upbound.io" -- "apis/v1*" | xargs sed -i.bak "s|upbound.io|${CRD_ROOT_GROUP}|g" +# shellcheck disable=SC2086 +git grep -l "ujconfig\.WithRootGroup(\"template.upbound\.io\")" -- "config/provider.go" | xargs sed -i.bak "s|ujconfig.WithRootGroup(\"template.upbound.io\")|ujconfig.WithRootGroup(\"${CRD_ROOT_GROUP}\")|g" + # We need to be careful while replacing "template" keyword in go.mod as it could tamper # some imported packages under require section. sed -i.bak "s|upbound/upjet-provider-template|${ORGANIZATION_NAME}/provider-${PROVIDER_NAME_LOWER}|g" go.mod