From 81b00ffb085ed4672be0925ce6072bc58c7f799d Mon Sep 17 00:00:00 2001 From: gilesrapkin Date: Tue, 19 Mar 2024 20:53:10 +0000 Subject: [PATCH] feat: Add knative-eventing, knative-serving and triggermesh CRDs (#387) * feat: Add knative-eventing and knative-serving CRDs * fix: config errors * feat: add mapContainers patch for service resource * chore: add patch dir * feat: add triggermesh CRDs * feat: update workflow --------- Co-authored-by: Giles Rapkin --- .github/workflows/main.yml | 123 ++++++++++++++++++ libs/knative-eventing/config.jsonnet | 16 +++ libs/knative-serving/config.jsonnet | 17 +++ .../custom/serving/mapContainers.libsonnet | 42 ++++++ libs/triggermesh/config.jsonnet | 16 +++ 5 files changed, 214 insertions(+) create mode 100644 libs/knative-eventing/config.jsonnet create mode 100644 libs/knative-serving/config.jsonnet create mode 100644 libs/knative-serving/custom/serving/mapContainers.libsonnet create mode 100644 libs/triggermesh/config.jsonnet diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07a9b68..1637db6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1499,6 +1499,86 @@ "SSH_KEY": "${{ secrets.DEPLOY_KEY }}" "if": "steps.filter.outputs.workflows == 'true'" "run": "make libs/keda" + "knative-eventing": + "name": "Generate knative-eventing Jsonnet library and docs" + "needs": + - "build" + - "repos" + "runs-on": "ubuntu-latest" + "steps": + - "uses": "actions/checkout@v3" + - "id": "filter" + "uses": "dorny/paths-filter@v2" + "with": + "filters": | + workflows: + - '.github/**' + - 'bin/**' + - 'Dockerfile' + - 'go.mod' + - 'go.sum' + - 'jsonnet/**' + - 'main.go' + - 'Makefile' + - 'pkg/**' + - 'scripts/**' + - 'tf/**' + - 'libs/knative-eventing/**' + - "if": "steps.filter.outputs.workflows == 'true'" + "uses": "actions/download-artifact@v2" + "with": + "name": "docker-artifact" + "path": "artifacts" + - "if": "steps.filter.outputs.workflows == 'true'" + "run": "make load" + - "env": + "DIFF": "true" + "GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}" + "GIT_COMMITTER_EMAIL": "86770550+jsonnet-libs-bot@users.noreply.github.com" + "GIT_COMMITTER_NAME": "jsonnet-libs-bot" + "SSH_KEY": "${{ secrets.DEPLOY_KEY }}" + "if": "steps.filter.outputs.workflows == 'true'" + "run": "make libs/knative-eventing" + "knative-serving": + "name": "Generate knative-serving Jsonnet library and docs" + "needs": + - "build" + - "repos" + "runs-on": "ubuntu-latest" + "steps": + - "uses": "actions/checkout@v3" + - "id": "filter" + "uses": "dorny/paths-filter@v2" + "with": + "filters": | + workflows: + - '.github/**' + - 'bin/**' + - 'Dockerfile' + - 'go.mod' + - 'go.sum' + - 'jsonnet/**' + - 'main.go' + - 'Makefile' + - 'pkg/**' + - 'scripts/**' + - 'tf/**' + - 'libs/knative-serving/**' + - "if": "steps.filter.outputs.workflows == 'true'" + "uses": "actions/download-artifact@v2" + "with": + "name": "docker-artifact" + "path": "artifacts" + - "if": "steps.filter.outputs.workflows == 'true'" + "run": "make load" + - "env": + "DIFF": "true" + "GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}" + "GIT_COMMITTER_EMAIL": "86770550+jsonnet-libs-bot@users.noreply.github.com" + "GIT_COMMITTER_NAME": "jsonnet-libs-bot" + "SSH_KEY": "${{ secrets.DEPLOY_KEY }}" + "if": "steps.filter.outputs.workflows == 'true'" + "run": "make libs/knative-serving" "kube-prometheus": "name": "Generate kube-prometheus Jsonnet library and docs" "needs": @@ -2015,6 +2095,8 @@ - "k8s" - "karpenter" - "keda" + - "knative-eventing" + - "knative-serving" - "kube-prometheus" - "kubernetes-nmstate" - "kubernetes-secret-generator" @@ -2031,6 +2113,7 @@ - "strimzi" - "teleport-operator" - "traefik" + - "triggermesh" - "vault-secrets-operator" - "vertical-pod-autoscaler" - "zalando-postgres-operator" @@ -2268,6 +2351,46 @@ "SSH_KEY": "${{ secrets.DEPLOY_KEY }}" "if": "steps.filter.outputs.workflows == 'true'" "run": "make libs/traefik" + "triggermesh": + "name": "Generate triggermesh Jsonnet library and docs" + "needs": + - "build" + - "repos" + "runs-on": "ubuntu-latest" + "steps": + - "uses": "actions/checkout@v3" + - "id": "filter" + "uses": "dorny/paths-filter@v2" + "with": + "filters": | + workflows: + - '.github/**' + - 'bin/**' + - 'Dockerfile' + - 'go.mod' + - 'go.sum' + - 'jsonnet/**' + - 'main.go' + - 'Makefile' + - 'pkg/**' + - 'scripts/**' + - 'tf/**' + - 'libs/triggermesh/**' + - "if": "steps.filter.outputs.workflows == 'true'" + "uses": "actions/download-artifact@v2" + "with": + "name": "docker-artifact" + "path": "artifacts" + - "if": "steps.filter.outputs.workflows == 'true'" + "run": "make load" + - "env": + "DIFF": "true" + "GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}" + "GIT_COMMITTER_EMAIL": "86770550+jsonnet-libs-bot@users.noreply.github.com" + "GIT_COMMITTER_NAME": "jsonnet-libs-bot" + "SSH_KEY": "${{ secrets.DEPLOY_KEY }}" + "if": "steps.filter.outputs.workflows == 'true'" + "run": "make libs/triggermesh" "vault-secrets-operator": "name": "Generate vault-secrets-operator Jsonnet library and docs" "needs": diff --git a/libs/knative-eventing/config.jsonnet b/libs/knative-eventing/config.jsonnet new file mode 100644 index 0000000..d8da4c4 --- /dev/null +++ b/libs/knative-eventing/config.jsonnet @@ -0,0 +1,16 @@ +local config = import 'jsonnet/config.jsonnet'; + +local versions = ['1.13.1', '1.12.4', '1.11.10']; + +config.new( + name='knative-eventing', + specs=[ + { + output: v, + crds: ['https://github.com/knative/eventing/releases/download/knative-v%s/eventing-crds.yaml' % v], + prefix: '^dev\\.knative\\..*', + localName: 'knative-eventing', + }, + for v in versions + ] +) \ No newline at end of file diff --git a/libs/knative-serving/config.jsonnet b/libs/knative-serving/config.jsonnet new file mode 100644 index 0000000..133098a --- /dev/null +++ b/libs/knative-serving/config.jsonnet @@ -0,0 +1,17 @@ +local config = import 'jsonnet/config.jsonnet'; + +local versions = ['1.13.1', '1.12.3', '1.11.6']; + +config.new( + name='knative-serving', + specs=[ + { + output: v, + crds: ['https://github.com/knative/serving/releases/download/knative-v%s/serving-crds.yaml' % v], + prefix: '^dev\\.knative\\..*', + patchDir: 'custom/serving', + localName: 'knative-serving', + }, + for v in versions + ] +) \ No newline at end of file diff --git a/libs/knative-serving/custom/serving/mapContainers.libsonnet b/libs/knative-serving/custom/serving/mapContainers.libsonnet new file mode 100644 index 0000000..4575abb --- /dev/null +++ b/libs/knative-serving/custom/serving/mapContainers.libsonnet @@ -0,0 +1,42 @@ +local d = import 'doc-util/main.libsonnet'; + +local patch = { + '#mapContainers': d.fn( + ||| + `mapContainers` applies the function f to each container. + It works exactly as `std.map`, but on the containers of this object. + + **Signature of `f`**: + ```ts + f(container: Object) Object + ``` + |||, + [d.arg('f', d.T.func)] + ), + mapContainers(f, includeInitContainers=false):: { + local podContainers = super.spec.template.spec.containers, + local podInitContainers = super.spec.template.spec.initContainers, + spec+: { + template+: { + spec+: { + containers: std.map(f, podContainers), + [if includeInitContainers then 'initContainers']: std.map(f, podInitContainers), + }, + }, + }, + }, + + '#mapContainersWithName': d.fn('`mapContainersWithName` is like `mapContainers`, but only applies to those containers in the `names` array', + [d.arg('names', d.T.array), d.arg('f', d.T.func)]), + mapContainersWithName(names, f, includeInitContainers=false):: + local nameSet = if std.type(names) == 'array' then std.set(names) else std.set([names]); + local inNameSet(name) = std.length(std.setInter(nameSet, std.set([name]))) > 0; + + self.mapContainers(function(c) if std.objectHas(c, 'name') && inNameSet(c.name) then f(c) else c, includeInitContainers), +}; + +{ + serving+: { v1+: { + service+: patch, + } }, +} diff --git a/libs/triggermesh/config.jsonnet b/libs/triggermesh/config.jsonnet new file mode 100644 index 0000000..fe92018 --- /dev/null +++ b/libs/triggermesh/config.jsonnet @@ -0,0 +1,16 @@ +local config = import 'jsonnet/config.jsonnet'; + +local versions = ['1.27.0']; + +config.new( + name='triggermesh', + specs=[ + { + output: v, + crds: ['https://github.com/triggermesh/triggermesh/releases/download/v%s/triggermesh-crds.yaml' % v], + prefix: '^io\\.triggermesh\\..*', + localName: 'triggermesh', + }, + for v in versions + ] +) \ No newline at end of file