Skip to content

Commit

Permalink
Merge pull request #3 from upbound/feature/p-t-function
Browse files Browse the repository at this point in the history
feat(function): switch to function, add renovate, bump providers
  • Loading branch information
haarchri authored Jan 3, 2024
2 parents b4d00ce + e3b0b64 commit 1751f89
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 100 deletions.
42 changes: 42 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
"helpers:pinGitHubActionDigests",
":semanticCommits"
],
"rebaseWhen": "conflicted",
"prConcurrentLimit": 5,
"baseBranches": ["main"],
"labels": ["automated"],
"customManagers": [
{
"customType": "regex",
"description": "Bump up version in the Makefile",
"fileMatch": ["^Makefile$"],
"matchStrings": [
"UP_VERSION = (?<currentValue>.*?)\\n"
],
"datasourceTemplate": "github-releases",
"depNameTemplate": "upbound/up",
}, {
"customType": "regex",
"description": "Bump uptest version in the Makefile",
"fileMatch": ["^Makefile$"],
"matchStrings": [
"UPTEST_VERSION = (?<currentValue>.*?)\\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=(?<datasource>[^\\s]+)\\s+depName=(?<depName>[^\\s]+)\\s*\\n\\s*version:\\s*\"(?<currentValue>[^\"]+)\""
],
"datasourceTemplate": "{{{datasource}}}",
"depNameTemplate": "{{{depName}}}",
}
],
}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PLATFORMS ?= linux_amd64

UP_VERSION = v0.21.0
UP_CHANNEL = stable
UPTEST_VERSION = v0.6.1
UPTEST_VERSION = v0.9.0

-include build/makelib/k8s_tools.mk
# ====================================================================================
Expand Down Expand Up @@ -61,7 +61,7 @@ build.init: $(UP)
# This target requires the following environment variables to be set:
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/flux-xr.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/flux-xr.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@$(OK) running automated tests

e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest
Expand Down
210 changes: 114 additions & 96 deletions apis/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,100 +9,118 @@ spec:
compositeTypeRef:
apiVersion: gitops.platform.upbound.io/v1alpha1
kind: XFlux
patchSets:
- name: Common
patches:
- type: FromCompositeFieldPath
fromFieldPath: metadata.labels
toFieldPath: metadata.labels
- type: FromCompositeFieldPath
fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
resources:
- name: releaseFlux
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
forProvider:
namespace: flux-system
chart:
name: flux2
values:
imageAutomationController:
create: false
imageReflectionController:
create: false
patches:
- type: PatchSet
patchSetName: Common
- fromFieldPath: spec.parameters.operators.flux.version
toFieldPath: spec.forProvider.chart.version
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: spec.parameters.operators.flux.version
strategy: string
string:
fmt: https://github.com/fluxcd-community/helm-charts/releases/download/flux2-%[1]s/flux2-%[1]s.tgz
toFieldPath: spec.forProvider.chart.url
mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: upbound-function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
patchSets:
- name: Common
patches:
- fromFieldPath: metadata.labels
toFieldPath: metadata.labels
type: FromCompositeFieldPath
- fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
type: FromCompositeFieldPath
resources:
- name: releaseFlux
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
forProvider:
chart:
name: flux2
namespace: flux-system
values:
imageAutomationController:
create: false
imageReflectionController:
create: false
patches:
- type: PatchSet
patchSetName: Common
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.operators.flux.version
toFieldPath: spec.forProvider.chart.version
- type: CombineFromComposite
combine:
strategy: string
string:
fmt: https://github.com/fluxcd-community/helm-charts/releases/download/flux2-%[1]s/flux2-%[1]s.tgz
variables:
- fromFieldPath: spec.parameters.operators.flux.version
toFieldPath: spec.forProvider.chart.url

- name: syncFlux
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
forProvider:
namespace: flux-system
chart:
name: flux2-sync
repository: https://fluxcd-community.github.io/helm-charts
values:
gitRepository:
spec:
gitImplementation: go-git
kustomization:
spec:
sourceRef:
kind: GitRepository
patches:
- type: PatchSet
patchSetName: Common
- fromFieldPath: spec.parameters.operators.flux-sync.version
toFieldPath: spec.forProvider.chart.version
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: metadata.annotations[crossplane.io/external-name]
- fromFieldPath: spec.parameters.source.git.timeout
toFieldPath: spec.forProvider.values.gitRepository.spec.timeout
- fromFieldPath: spec.parameters.source.git.interval
toFieldPath: spec.forProvider.values.gitRepository.spec.interval
- fromFieldPath: spec.parameters.source.git.interval
toFieldPath: spec.forProvider.values.kustomization.spec.interval
- fromFieldPath: spec.parameters.source.git.ref.name
toFieldPath: spec.forProvider.values.gitRepository.spec.ref.name
- fromFieldPath: spec.parameters.source.git.url
toFieldPath: spec.forProvider.values.gitRepository.spec.url
- fromFieldPath: spec.parameters.source.git.path
toFieldPath: spec.forProvider.values.kustomization.spec.path
- fromFieldPath: spec.parameters.kubeConfigSecretRef.name
toFieldPath: spec.forProvider.values.kustomization.spec.kubeConfig.secretRef.name
- fromFieldPath: spec.parameters.kubeConfigSecretRef.key
toFieldPath: spec.forProvider.values.kustomization.spec.kubeConfig.secretRef.key
# the sync helm-chart defines ref.branch master per default in values
# https://github.com/fluxcd-community/helm-charts/blob/flux2-sync-1.7.2/charts/flux2-sync/values.yaml#L46
# we want to use ref.name because server-side-apply is an issue when using ref.tag or ref.branch switch
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.forProvider.values.gitRepository.spec.ref.branch
transforms:
- type: match
match:
patterns:
- type: regexp
regexp: '.*'
result: ''
- name: syncFlux
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
forProvider:
chart:
name: flux2-sync
repository: https://fluxcd-community.github.io/helm-charts
namespace: flux-system
values:
gitRepository:
spec:
gitImplementation: go-git
kustomization:
spec:
sourceRef:
kind: GitRepository
patches:
- type: PatchSet
patchSetName: Common
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.operators.flux-sync.version
toFieldPath: spec.forProvider.chart.version
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: metadata.annotations[crossplane.io/external-name]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.timeout
toFieldPath: spec.forProvider.values.gitRepository.spec.timeout
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.interval
toFieldPath: spec.forProvider.values.gitRepository.spec.interval
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.interval
toFieldPath: spec.forProvider.values.kustomization.spec.interval
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.ref.name
toFieldPath: spec.forProvider.values.gitRepository.spec.ref.name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.url
toFieldPath: spec.forProvider.values.gitRepository.spec.url
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.source.git.path
toFieldPath: spec.forProvider.values.kustomization.spec.path
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.kubeConfigSecretRef.name
toFieldPath: spec.forProvider.values.kustomization.spec.kubeConfig.secretRef.name
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.kubeConfigSecretRef.key
toFieldPath: spec.forProvider.values.kustomization.spec.kubeConfig.secretRef.key
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.forProvider.values.gitRepository.spec.ref.branch
transforms:
- type: match
match:
fallbackValue: null
patterns:
- type: regexp
regexp: .*
result: ""
8 changes: 6 additions & 2 deletions crossplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ metadata:
that you can copy and customize to meet the exact needs of your organization!
spec:
crossplane:
version: ">=v1.13.2-0"
version: ">=v1.14.1-0"
dependsOn:
- provider: xpkg.upbound.io/crossplane-contrib/provider-helm
version: ">=v0.15.0"
# renovate: datasource=github-releases depName=crossplane-contrib/provider-helm
version: "v0.16.0"
- function: xpkg.upbound.io/upbound/function-patch-and-transform
# renovate: datasource=github-releases depName=upbound/function-patch-and-transform
version: "v0.2.1"

0 comments on commit 1751f89

Please sign in to comment.