-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add possibiltiy to set fully qualified field references (e.g. desired…
….composite.resource., .desired.resources. or context.) (#33)
- Loading branch information
Showing
15 changed files
with
581 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,6 @@ go.work | |
.golangci.yml | ||
*.xpkg | ||
function-cidr | ||
.vscode | ||
.idea | ||
.vscode | ||
*__debug_bin* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: xcidrs.platform.upbound.io | ||
spec: | ||
compositeTypeRef: | ||
apiVersion: platform.upbound.io/v1alpha1 | ||
kind: XCIDR | ||
mode: Pipeline | ||
pipeline: | ||
- step: pull-extra-resources | ||
functionRef: | ||
name: function-extra-resources | ||
input: | ||
apiVersion: extra-resources.fn.crossplane.io/v1beta1 | ||
kind: Input | ||
spec: | ||
extraResources: | ||
- kind: XCluster | ||
into: XCluster | ||
apiVersion: example.crossplane.io/v1 | ||
type: Selector | ||
selector: | ||
maxMatch: 2 | ||
minMatch: 1 | ||
matchLabels: | ||
- key: type | ||
type: Value | ||
value: cluster | ||
- step: debug-context | ||
functionRef: | ||
name: function-go-templating | ||
input: | ||
apiVersion: gotemplate.fn.crossplane.io/v1beta1 | ||
kind: GoTemplate | ||
source: Inline | ||
inline: | ||
template: | | ||
apiVersion: test.my-domain.com/v1alpha1 | ||
kind: DebugContext | ||
metadata: | ||
annotations: | ||
gotemplating.fn.crossplane.io/composition-resource-name: debug-context | ||
debug: | ||
{{ . | toYaml | nindent 2 }} | ||
- step: cidr-subnets-partitions | ||
functionRef: | ||
name: upbound-function-cidr | ||
input: | ||
apiVersion: cidr.fn.crossplane.io/v1beta1 | ||
kind: Parameters | ||
cidrFunc: cidrsubnets | ||
prefixField: context.apiextensions\.crossplane\.io/extra-resources.XCluster.0.spec.cidrBlock | ||
newBits: | ||
- 1 | ||
- 1 | ||
outputField: status.atFunction.cidr.partitions | ||
- step: cidr-subnets-private | ||
functionRef: | ||
name: upbound-function-cidr | ||
input: | ||
apiVersion: cidr.fn.crossplane.io/v1beta1 | ||
kind: Parameters | ||
cidrFunc: cidrsubnets | ||
prefixField: desired.composite.resource.status.atFunction.cidr.partitions[0] | ||
newBits: | ||
- 1 | ||
- 1 | ||
outputField: status.atFunction.cidr.private.subnets | ||
- step: cidr-subnets-public | ||
functionRef: | ||
name: upbound-function-cidr | ||
input: | ||
apiVersion: cidr.fn.crossplane.io/v1beta1 | ||
kind: Parameters | ||
cidrFunc: cidrsubnets | ||
prefixField: desired.composite.resource.status.atFunction.cidr.partitions[1] | ||
newBits: | ||
- 1 | ||
- 1 | ||
outputField: status.atFunction.cidr.public.subnets | ||
# To debug the pipeline output you can generate a new resource which contains all attributes. Make sure to add function-go-templating to functions.yaml. | ||
- step: render-templates | ||
functionRef: | ||
name: function-go-templating | ||
input: | ||
apiVersion: gotemplate.fn.crossplane.io/v1beta1 | ||
kind: GoTemplate | ||
source: Inline | ||
inline: | ||
template: | | ||
apiVersion: test.my-domain.com/v1alpha1 | ||
kind: DebugResource | ||
metadata: | ||
annotations: | ||
gotemplating.fn.crossplane.io/composition-resource-name: debug | ||
debug: | ||
{{ . | toYaml | nindent 2 }} | ||
debugValue: | ||
{{ index .desired.composite.resource.status.atFunction.cidr.public.subnets 0 | nindent 2 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: xcidrs.platform.upbound.io | ||
spec: | ||
compositeTypeRef: | ||
apiVersion: platform.upbound.io/v1alpha1 | ||
kind: XCIDR | ||
mode: Pipeline | ||
pipeline: | ||
- step: cidr-subnets-partitions | ||
functionRef: | ||
name: upbound-function-cidr | ||
input: | ||
apiVersion: cidr.fn.crossplane.io/v1beta1 | ||
kind: Parameters | ||
cidrFunc: cidrsubnets | ||
prefixField: spec.parameters.cidrBlock | ||
newBits: | ||
- 1 | ||
- 1 | ||
outputField: status.atFunction.cidr.partitions | ||
- step: cidr-subnets-private | ||
functionRef: | ||
name: upbound-function-cidr | ||
input: | ||
apiVersion: cidr.fn.crossplane.io/v1beta1 | ||
kind: Parameters | ||
cidrFunc: cidrsubnets | ||
prefixField: desired.composite.resource.status.atFunction.cidr.partitions[0] | ||
newBits: | ||
- 1 | ||
- 1 | ||
outputField: status.atFunction.cidr.private.subnets | ||
- step: cidr-subnets-public | ||
functionRef: | ||
name: upbound-function-cidr | ||
input: | ||
apiVersion: cidr.fn.crossplane.io/v1beta1 | ||
kind: Parameters | ||
cidrFunc: cidrsubnets | ||
prefixField: desired.composite.resource.status.atFunction.cidr.partitions[1] | ||
newBits: | ||
- 1 | ||
- 1 | ||
outputField: status.atFunction.cidr.public.subnets | ||
## To debug the pipeline output you can generate a new resource which contains all attributes. Make sure to add function-go-templating to functions.yaml. | ||
# - step: render-templates | ||
# functionRef: | ||
# name: function-go-templating | ||
# input: | ||
# apiVersion: gotemplate.fn.crossplane.io/v1beta1 | ||
# kind: GoTemplate | ||
# source: Inline | ||
# inline: | ||
# template: | | ||
# apiVersion: test.my-domain.com/v1alpha1 | ||
# kind: DebugResource | ||
# metadata: | ||
# annotations: | ||
# gotemplating.fn.crossplane.io/composition-resource-name: debug | ||
# debug: | ||
# {{ . | toYaml | nindent 2 }} | ||
# debugValue: | ||
# {{ index .desired.composite.resource.status.atFunction.cidr.public.subnets 0 | nindent 2 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ spec: | |
type: integer | ||
offset: | ||
type: integer | ||
output: | ||
outputField: | ||
type: string | ||
required: | ||
- parameters | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XCluster | ||
metadata: | ||
name: net-staging-blue | ||
labels: | ||
type: cluster | ||
spec: | ||
cidrBlock: 10.0.0.0/20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: pkg.crossplane.io/v1beta1 | ||
kind: Function | ||
metadata: | ||
name: upbound-function-cidr | ||
annotations: | ||
render.crossplane.io/runtime: Development | ||
# spec: | ||
# package: xpkg.upbound.io/upbound/function-cidr:v0.3.0 | ||
--- | ||
apiVersion: pkg.crossplane.io/v1beta1 | ||
kind: Function | ||
metadata: | ||
name: function-go-templating | ||
annotations: | ||
render.crossplane.io/runtime-docker-cleanup: "Orphan" | ||
spec: | ||
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.5.0 | ||
--- | ||
apiVersion: pkg.crossplane.io/v1beta1 | ||
kind: Function | ||
metadata: | ||
name: function-extra-resources | ||
annotations: | ||
render.crossplane.io/runtime-docker-cleanup: "Orphan" | ||
# This tells crossplane beta render to connect to the function locally. | ||
#render.crossplane.io/runtime: Development | ||
spec: | ||
# This is ignored when using the Development runtime. | ||
package: xpkg.upbound.io/crossplane-contrib/function-extra-resources:v0.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.