Skip to content

Instantly share code, notes, and snippets.

@squeedee
Forked from jwntrs/00-gitops-sc.yml
Created February 22, 2022 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squeedee/8d5937911602006d6cba4b19fe759509 to your computer and use it in GitHub Desktop.
Save squeedee/8d5937911602006d6cba4b19fe759509 to your computer and use it in GitHub Desktop.
Typed supply chains (ClusterSourceSupplyChain, ClusterImageSupplyChain, ClusterConfigSupplyChain)
apiVersion: carto.run/v1alpha1
kind: ClusterSupplyChain
metadata:
name: gitops-supply-chain
spec:
selector:
matchLabels:
workload-type: web
matchFields:
- {key: ".spec.target", operation: In, value: ["gitops"]}
- name: configure
templateRef:
kind: ClusterConfigSupplyChain
name: configure-builder
- name: gitops
templateRef:
kind: ClusterTemplate
name: git-pusher
configs:
- resource: configure
name: config
apiVersion: carto.run/v1alpha1
kind: ClusterSupplyChain
metadata:
name: regops-supply-chain
spec:
selector:
matchLabels:
workload-type: web
matchFields:
- {key: ".spec.target", operation: In, value: ["regops"]}
- name: configure
templateRef:
kind: ClusterConfigSupplyChain
name: configure-builder
- name: regops
templateRef:
kind: ClusterTemplate
name: registry-pusher
configs:
- resource: configure
name: config
apiVersion: carto.run/v1alpha1
kind: ClusterConfigSupplyChain
metadata:
name: config-builder
spec:
selector:
matchLabels:
workload-type: web
configPath: configure.config
resources:
- name: image-provider
options:
- name: build-from-source
templateRef:
kind: ClusterImageSupplyChain
name: image-builder
selector:
matchFields:
- { key: "spec.source", operation: exists }
- name: prebuilt
templateRef:
kind: ClusterImageTemplate
name: image-source
selector:
matchFields:
- { key: "spec.image", operation: exists }
- name: configure
templateRef:
kind: ClusterConfigTemplate
name: configure
images:
- resource: image-provider
name: image
apiVersion: carto.run/v1alpha1
kind: ClusterImageSupplyChain
metadata:
name: image-builder
spec:
params:
- name: image_prefix
default: some-default-prefix-
imagePath: build-image.image
resources:
- name: git-source
options:
- name: from-source-and-test
templateRef:
kind: ClusterSourceSupplyChain
name: source-and-test
selector:
matchFields:
- {key: "metadata.labels.has-tests", operation: In, value: ["true"]}
- name: from-source
templateRef:
kind: ClusterSourceTemplate
name: source
selector:
matchFields:
- {key: "metadata.labels.has-tests", operation: In, value: ["true"]}
- name: build-image
templateRef:
kind: ClusterImageTemplate
name: image
apiVersion: carto.run/v1alpha1
kind: ClusterSourceSupplyChain
metadata:
name: source-and-test
spec:
urlPath: source-tester.status.artifact.url
revisionPath: source-tester.status.artifact.revision
resources:
- name: git-source
templateRef:
kind: ClusterSourceTemplate
name: source
- name: source-tester
templateRef:
kind: ClusterSourceTemplate
name: source-test
apiVersion: carto.run/v1alpha1
kind: ClusterSourceTemplate
metadata:
name: source
spec:
urlPath: .status.artifact.url
revisionPath: .status.artifact.revision
template:
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: $(workload.metadata.name)$
spec:
interval: 1m0s
url: $(workload.spec.source.git.url)$
ref: $(workload.spec.source.git.ref)$
gitImplementation: libgit2
ignore: ""
apiVersion: carto.run/v1alpha1
kind: ClusterSourceTemplate
metadata:
name: source-test
spec:
urlPath: .status.outputs.url
revisionPath: .status.outputs.revision
ytt:
#@ load("@ytt:data", "data")
apiVersion: carto.run/v1alpha1
kind: Runnable
metadata:
name: #@ data.values.workload.metadata.name
spec:
#@ if/end hasattr(data.values.workload.spec, "serviceAccountName"):
serviceAccountName: #@ data.values.workload.spec.serviceAccountName
runTemplateRef:
name: tekton-source-pipelinerun
kind: ClusterRunTemplate
selector:
resource:
apiVersion: tekton.dev/v1beta1
kind: Pipeline
matchingLabels:
apps.tanzu.vmware.com/pipeline: test
inputs:
source-url: #@ data.values.source.url
source-revision: #@ data.values.source.revision
apiVersion: carto.run/v1alpha1
kind: ClusterImageTemplate
metadata:
name: image
spec:
imagePath: .status.latestImage
template:
apiVersion: kpack.io/v1alpha2
kind: Image
metadata:
name: $(workload.metadata.name)$
spec:
tag: $(params.image_prefix)$$(workload.metadata.name)$
serviceAccountName: cartographer-example-registry-creds-sa
builder:
kind: ClusterBuilder
name: go-builder
source:
blob:
url: $(sources.source.url)$
build:
env: $(workload.spec.build.env)$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment