generated from crossplane/function-template-go
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add examples for kubecon 2024 demo
Signed-off-by: Philippe Scorsolini <[email protected]>
- Loading branch information
Showing
8 changed files
with
201 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Example manifests | ||
|
||
Before, one had to define references to `spec.environment.environmentConfigs`, | ||
see [./old/composition.yaml][]. | ||
|
||
The same can now be achieved using `function-environment-config`, which allows | ||
to leverage the power of `crossplane beta render` to see both the `Context` | ||
containing the `environment` and the XR: | ||
```shell | ||
$ crossplane beta render \ | ||
--extra-resources example/environmentConfigs.yaml \ | ||
--include-full-xr \ | ||
--include-context \ | ||
example/xr.yaml example/composition.yaml example/functions.yaml | ||
--- | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XR | ||
metadata: | ||
name: example-xr | ||
spec: {} | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2024-01-01T00:00:00Z" | ||
reason: Available | ||
status: "True" | ||
type: Ready | ||
fromEnv: by-label | ||
--- | ||
apiVersion: render.crossplane.io/v1beta1 | ||
kind: Context | ||
fields: | ||
apiextensions.crossplane.io/environment: | ||
apiVersion: internal.crossplane.io/v1alpha1 | ||
kind: Environment | ||
complex: | ||
a: b | ||
c: | ||
d: by-label | ||
f: "1" | ||
g: by-label | ||
``` |
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,42 @@ | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: function-environment-configs | ||
spec: | ||
compositeTypeRef: | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XR | ||
mode: Pipeline | ||
pipeline: | ||
- step: environmentConfigs | ||
functionRef: | ||
name: function-environment-configs | ||
input: | ||
apiVersion: environmentconfigs.fn.crossplane.io/v1beta1 | ||
kind: Input | ||
spec: | ||
environmentConfigs: | ||
- type: Reference | ||
ref: | ||
name: example-config | ||
- type: Selector | ||
selector: | ||
mode: Single | ||
matchLabels: | ||
- type: Value | ||
key: org | ||
value: foo | ||
- step: go-templating | ||
functionRef: | ||
name: function-go-templating | ||
input: | ||
apiVersion: gotemplating.fn.crossplane.io/v1beta1 | ||
kind: GoTemplate | ||
source: Inline | ||
inline: | ||
template: | | ||
--- | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XR | ||
status: | ||
fromEnv: {{ index .context "apiextensions.crossplane.io/environment" "complex" "c" "d" }} |
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,23 @@ | ||
--- | ||
apiVersion: apiextensions.crossplane.io/v1alpha1 | ||
kind: EnvironmentConfig | ||
metadata: | ||
name: example-config | ||
data: | ||
complex: | ||
a: b | ||
c: | ||
d: e | ||
f: "1" | ||
--- | ||
apiVersion: apiextensions.crossplane.io/v1alpha1 | ||
kind: EnvironmentConfig | ||
metadata: | ||
name: example-config-by-label | ||
labels: | ||
org: foo | ||
data: | ||
complex: | ||
c: | ||
d: by-label | ||
g: by-label |
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,18 @@ | ||
--- | ||
apiVersion: pkg.crossplane.io/v1beta1 | ||
kind: Function | ||
metadata: | ||
name: function-environment-configs | ||
annotations: | ||
# 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-environment-configs:v0.0.4 | ||
--- | ||
apiVersion: pkg.crossplane.io/v1beta1 | ||
kind: Function | ||
metadata: | ||
name: function-go-templating | ||
spec: | ||
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 |
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,38 @@ | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: function-environment-configs | ||
spec: | ||
environment: | ||
environmentConfigs: | ||
- type: Reference | ||
ref: | ||
name: example-config | ||
- type: Selector | ||
selector: | ||
mode: Single | ||
matchLabels: | ||
- type: Value | ||
key: org | ||
value: foo | ||
policy: | ||
resolve: Always | ||
compositeTypeRef: | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XR | ||
mode: Pipeline | ||
pipeline: | ||
- step: go-templating | ||
functionRef: | ||
name: function-go-templating | ||
input: | ||
apiVersion: gotemplating.fn.crossplane.io/v1beta1 | ||
kind: GoTemplate | ||
source: Inline | ||
inline: | ||
template: | | ||
--- | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XR | ||
status: | ||
fromEnv: {{ index .context "apiextensions.crossplane.io/environment" "complex" "c" "d" }} |
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: pkg.crossplane.io/v1 | ||
kind: Provider | ||
metadata: | ||
name: provider-nop | ||
spec: | ||
package: xpkg.upbound.io/crossplane-contrib/provider-nop:v0.2.1 | ||
ignoreCrossplaneConstraints: true |
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,6 @@ | ||
# Replace this with your XR! | ||
apiVersion: example.crossplane.io/v1 | ||
kind: XR | ||
metadata: | ||
name: example-xr | ||
spec: {} |
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,25 @@ | ||
--- | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: CompositeResourceDefinition | ||
metadata: | ||
name: xrs.example.crossplane.io | ||
spec: | ||
group: example.crossplane.io | ||
names: | ||
kind: XR | ||
plural: xrs | ||
connectionSecretKeys: | ||
- test | ||
versions: | ||
- name: v1 | ||
served: true | ||
referenceable: true | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
status: | ||
type: object | ||
properties: | ||
fromEnv: | ||
type: string |