diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000..f43c59f --- /dev/null +++ b/.github/renovate.json5 @@ -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 = (?.*?)\\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}}}", + } + ], +} diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..669c864 --- /dev/null +++ b/.yamllint @@ -0,0 +1,5 @@ +extends: default + +rules: + line-length: disable + document-start: disable diff --git a/Makefile b/Makefile index 4022409..debee46 100644 --- a/Makefile +++ b/Makefile @@ -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 # ==================================================================================== @@ -61,9 +61,17 @@ 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/argocd-xr.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL) + @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/argocd-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 -.PHONY: uptest e2e \ No newline at end of file +render: + crossplane beta render examples/argocd-xr.yaml apis/composition.yaml examples/functions.yaml -r + +yamllint: + @$(INFO) running yamllint + @yamllint ./apis || $(FAIL) + @$(OK) running yamllint + +.PHONY: uptest e2e render yamllint \ No newline at end of file diff --git a/apis/composition.yaml b/apis/composition.yaml index 84b4b2e..ff525f8 100644 --- a/apis/composition.yaml +++ b/apis/composition.yaml @@ -9,244 +9,261 @@ spec: compositeTypeRef: apiVersion: gitops.platform.upbound.io/v1alpha1 kind: XArgo - 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: releaseArgo - base: - apiVersion: helm.crossplane.io/v1beta1 - kind: Release - spec: - forProvider: - namespace: argocd - chart: - name: argo-cd - repository: https://argoproj.github.io/argo-helm - values: - dex: - enabled: false - redis-ha: - enabled: true - controller: - replicas: 1 - metrics: - enabled: true - service: - annotations: - prometheus.io/scrape: true - env: - - name: ARGOCD_K8S_CLIENT_QPS - value: "300" - repoServer: - autoscaling: - enabled: true - minReplicas: 1 - resources: - requests: - cpu : "100m" - memory : "256Mi" - limits: - cpu: "200m" - memory: "512Mi" - metrics: - enabled: true - service: - annotations: - prometheus.io/scrape: true - applicationSet: - replicaCount: 1 - metrics: - enabled: true - service: - annotations: - prometheus.io/scrape: true - server: - autoscaling: - enabled: true - minReplicas: 1 - resources: - requests: - cpu : "100m" - memory : "256Mi" - limits: - cpu: "200m" - memory: "512Mi" - metrics: - enabled: true - service: - annotations: - prometheus.io/scrape: true - service: - type: "LoadBalancer" - configs: - params: - application.namespaces: "cluster-*" - cm: - application.resourceTrackingMethod: "annotation" - resource.exclusions: | - - kinds: - - ProviderConfigUsage - apiGroups: - - "*" - resource.customizations: | - "*.upbound.io/*": - health.lua: | - health_status = { - status = "Progressing", - message = "Provisioning ..." - } + 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: + - 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: releaseArgo + base: + apiVersion: helm.crossplane.io/v1beta1 + kind: Release + spec: + forProvider: + chart: + name: argo-cd + repository: https://argoproj.github.io/argo-helm + namespace: argocd + values: + applicationSet: + metrics: + enabled: true + service: + annotations: + prometheus.io/scrape: true + replicaCount: 1 + configs: + cm: + application.resourceTrackingMethod: annotation + resource.customizations: | + "*.upbound.io/*": + health.lua: | + health_status = { + status = "Progressing", + message = "Provisioning ..." + } - if obj.status == nil or obj.status.conditions == nil then - return health_status - end + if obj.status == nil or obj.status.conditions == nil then + return health_status + end - for i, condition in ipairs(obj.status.conditions) do - if condition.type == "LastAsyncOperation" then - if condition.status == "False" then - health_status.status = "Degraded" - health_status.message = condition.message - return health_status - end - end + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "LastAsyncOperation" then + if condition.status == "False" then + health_status.status = "Degraded" + health_status.message = condition.message + return health_status + end + end - if condition.type == "Synced" then - if condition.status == "False" then - health_status.status = "Degraded" - health_status.message = condition.message - return health_status - end - end + if condition.type == "Synced" then + if condition.status == "False" then + health_status.status = "Degraded" + health_status.message = condition.message + return health_status + end + end + + if condition.type == "Ready" then + if condition.status == "True" then + health_status.status = "Healthy" + health_status.message = "Resource is up-to-date." + return health_status + end + end + end - if condition.type == "Ready" then - if condition.status == "True" then - health_status.status = "Healthy" - health_status.message = "Resource is up-to-date." return health_status - end - end - end - return health_status + "*.crossplane.io/*": + health.lua: | + health_status = { + status = "Progressing", + message = "Provisioning ..." + } - "*.crossplane.io/*": - health.lua: | - health_status = { - status = "Progressing", - message = "Provisioning ..." - } + if obj.status == nil or obj.status.conditions == nil then + return health_status + end - if obj.status == nil or obj.status.conditions == nil then - return health_status - end + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "LastAsyncOperation" then + if condition.status == "False" then + health_status.status = "Degraded" + health_status.message = condition.message + return health_status + end + end - for i, condition in ipairs(obj.status.conditions) do - if condition.type == "LastAsyncOperation" then - if condition.status == "False" then - health_status.status = "Degraded" - health_status.message = condition.message - return health_status - end - end + if condition.type == "Synced" then + if condition.status == "False" then + health_status.status = "Degraded" + health_status.message = condition.message + return health_status + end + end - if condition.type == "Synced" then - if condition.status == "False" then - health_status.status = "Degraded" - health_status.message = condition.message - return health_status - end - end + if condition.type == "Ready" then + if condition.status == "True" then + health_status.status = "Healthy" + health_status.message = "Resource is up-to-date." + return health_status + end + end + end - if condition.type == "Ready" then - if condition.status == "True" then - health_status.status = "Healthy" - health_status.message = "Resource is up-to-date." return health_status - end - end - end - - return health_status - patches: - - type: PatchSet - patchSetName: Common - - fromFieldPath: spec.parameters.ingressUrl - toFieldPath: spec.forProvider.values.server.url - - fromFieldPath: spec.parameters.oidcConfig - toFieldPath: spec.forProvider.values.server.config.oidc.config - - fromFieldPath: spec.parameters.operators.argocd.version - toFieldPath: spec.forProvider.chart.version - - fromFieldPath: spec.parameters.providerConfigName - toFieldPath: metadata.annotations[crossplane.io/external-name] - transforms: - - type: match - match: - patterns: - - type: regexp - regexp: '.*' - result: argocd + resource.exclusions: | + - kinds: + - ProviderConfigUsage + apiGroups: + - "*" + params: + application.namespaces: cluster-* + controller: + env: + - name: ARGOCD_K8S_CLIENT_QPS + value: "300" + metrics: + enabled: true + service: + annotations: + prometheus.io/scrape: true + replicas: 1 + dex: + enabled: false + redis-ha: + enabled: true + repoServer: + autoscaling: + enabled: true + minReplicas: 1 + metrics: + enabled: true + service: + annotations: + prometheus.io/scrape: true + resources: + limits: + cpu: 200m + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi + server: + autoscaling: + enabled: true + minReplicas: 1 + metrics: + enabled: true + service: + annotations: + prometheus.io/scrape: true + resources: + limits: + cpu: 200m + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi + service: + type: LoadBalancer + patches: + - type: PatchSet + patchSetName: Common + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.ingressUrl + toFieldPath: spec.forProvider.values.server.url + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.oidcConfig + toFieldPath: spec.forProvider.values.server.config[oidc.config] + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.operators.argocd.version + toFieldPath: spec.forProvider.chart.version + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.providerConfigName + toFieldPath: metadata.annotations[crossplane.io/external-name] + transforms: + - match: + fallbackValue: null + patterns: + - regexp: .* + result: argocd + type: regexp + type: match - - name: argoApplicationSet - base: - apiVersion: kubernetes.crossplane.io/v1alpha1 - kind: Object - spec: - forProvider: - manifest: - apiVersion: argoproj.io/v1alpha1 - kind: ApplicationSet - metadata: - namespace: argocd + - name: argoApplicationSet + base: + apiVersion: kubernetes.crossplane.io/v1alpha1 + kind: Object spec: - goTemplate: true - goTemplateOptions: ["missingkey=error"] - generators: - - matrix: + forProvider: + manifest: + apiVersion: argoproj.io/v1alpha1 + kind: ApplicationSet + metadata: + namespace: argocd + spec: generators: - - git: {} - - list: - # https://github.com/argoproj/argo-cd/issues/15341 - elements: [] - elementsYaml: "{{ .key.components | toJson }}" - template: - metadata: - name: '{{.name}}' - spec: - project: default - syncPolicy: - automated: - selfHeal: true - syncOptions: - - CreateNamespace=true - sources: - - chart: '{{.chart}}' - repoURL: '{{.repoUrl}}' - targetRevision: '{{.version}}' - helm: - releaseName: '{{.releaseName}}' - destination: - server: https://kubernetes.default.svc - namespace: '{{.namespace}}' - patches: - - type: PatchSet - patchSetName: Common - - fromFieldPath: spec.parameters.providerConfigName - toFieldPath: spec.forProvider.manifest.metadata.name - - fromFieldPath: spec.parameters.source.git.url - toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.repoURL - - fromFieldPath: spec.parameters.source.git.path - toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.files[0].path - - fromFieldPath: spec.parameters.source.git.ref.name - toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.revision + - matrix: + generators: + - git: {} + - list: + elements: [] + elementsYaml: '{{ .key.components | toJson }}' + goTemplate: true + goTemplateOptions: + - missingkey=error + template: + metadata: + name: '{{.name}}' + spec: + destination: + namespace: '{{.namespace}}' + server: https://kubernetes.default.svc + project: default + sources: + - chart: '{{.chart}}' + helm: + releaseName: '{{.releaseName}}' + repoURL: '{{.repoUrl}}' + targetRevision: '{{.version}}' + syncPolicy: + automated: + selfHeal: true + syncOptions: + - CreateNamespace=true + patches: + - type: PatchSet + patchSetName: Common + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.providerConfigName + toFieldPath: spec.forProvider.manifest.metadata.name + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.source.git.url + toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.repoURL + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.source.git.path + toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.files[0].path + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.source.git.ref.name + toFieldPath: spec.forProvider.manifest.spec.generators[0].matrix.generators[0].git.revision diff --git a/apis/definition.yaml b/apis/definition.yaml index b6de3fe..dd19c86 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -80,7 +80,7 @@ spec: path: type: string ref: - description: Reference specifies the Git reference to resolve and + description: Reference specifies the Git reference to resolve and monitor for changes. type: object properties: diff --git a/crossplane.yaml b/crossplane.yaml index 28a84a3..002a396 100644 --- a/crossplane.yaml +++ b/crossplane.yaml @@ -14,9 +14,14 @@ 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" - provider: xpkg.upbound.io/crossplane-contrib/provider-kubernetes - version: ">=v0.9.0" + # renovate: datasource=github-releases depName=crossplane-contrib/provider-kubernetes + version: "v0.10.0" + - function: xpkg.upbound.io/upbound/function-patch-and-transform + # renovate: datasource=github-releases depName=upbound/function-patch-and-transform + version: "v0.2.1" diff --git a/examples/functions.yaml b/examples/functions.yaml new file mode 100644 index 0000000..98c28bd --- /dev/null +++ b/examples/functions.yaml @@ -0,0 +1,6 @@ +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: upbound-function-patch-and-transform +spec: + package: xpkg.upbound.io/upbound/function-patch-and-transform:v0.2.1