crossplane-contrib / function-environment-configs Goto Github PK
View Code? Open in Web Editor NEWA function building the environment from EnvironmentConfigs
License: Apache License 2.0
A function building the environment from EnvironmentConfigs
License: Apache License 2.0
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
k8s.io/apiextensions-apiserver
, k8s.io/apimachinery
)example/functions.yaml
xpkg.upbound.io/crossplane-contrib/function-environment-configs v0.0.7
xpkg.upbound.io/crossplane-contrib/function-go-templating v0.4.1
example/kubecon-2024/functions.yaml
xpkg.upbound.io/crossplane-contrib/function-environment-configs v0.0.7
xpkg.upbound.io/crossplane-contrib/function-go-templating v0.4.1
example/kubecon-2024/provider.yaml
xpkg.upbound.io/crossplane-contrib/provider-nop v0.2.1
example/provider.yaml
xpkg.upbound.io/crossplane-contrib/provider-nop v0.2.1
Dockerfile
docker/dockerfile 1
golang 1
.github/workflows/ci.yml
actions/checkout v4
actions/setup-go v5
golangci/golangci-lint-action v5
actions/checkout v4
actions/setup-go v5
docker/setup-qemu-action v3
docker/setup-buildx-action v3
actions/checkout v4
docker/build-push-action v5
actions/upload-artifact v4
actions/checkout v4
actions/download-artifact v4
docker/login-action v3
ubuntu 22.04
ubuntu 22.04
ubuntu 22.04
ubuntu 22.04
go.mod
go 1.21
go 1.22.2
github.com/alecthomas/kong v0.8.1
github.com/crossplane/crossplane-runtime v1.15.1
github.com/crossplane/function-sdk-go v0.2.0
github.com/google/go-cmp v0.6.0
google.golang.org/protobuf v1.33.0
k8s.io/apiextensions-apiserver v0.29.3
k8s.io/apimachinery v0.29.3
sigs.k8s.io/controller-tools v0.14.0
Message: incompatible Crossplane version: package is not compatible with Crossplane version (v1.16.0-rc.0.38.gdd131a7a)
Warning
This function relies on functionalities only available in Crossplane 1.15 and later. It will not work with earlier versions.
Function version: xpkg.upbound.io/crossplane-contrib/function-environment-configs
v0.0.4
v0.0.5
We currently don't support Resolve Policy IfNotPresent
, but only Always
, we could think of implementing it if needed.
Resolve Policy IfNotPresent
was originally implemented by writing to the XR
's spec.environmentConfigRefs
, Functions can only write to the status
of the XR, so we can't do the same here, but at the end of the day, all we need is a way to "store" the EnvironmentConfigs returned the first time and only request those in subsequent calls, so we could think of some alternatives.
The status
would be the most natural option, but usually that's not restored in case of Backup/Restores, so we should try thinking of another option.
We could output as part of the desired state an EnvironmentConfig containing the references to these resources, so that on subsequent reconciliations we could get it back as input and only request those back.
If Crossplane was to implement caching in some way, we can assume this function will get every time the same EnvironmentConfigs
requested on the first run, so by trusting them we could effectively have Always
resolve policy implemented with little effort.Invalidating these references in case of changes in the composition was an issue also in the original implementation AFAIR, but deleting the references from the resource spec was enough to manually invalidate it, how could we handle it here? this would probably be something to be defined at the Crossplane level though.
Support Resolve Policy IfNotPresent
It seems that spec.policy.resolution
set to Optional only applies for EnvironmentConfigs who are selected directly by Reference but does not work for Selectors.
Create an input to a reference for an EnvironmentConfig that does not exist.
I had an input like this:
- step: loadEnvironmentConfigs
functionRef:
name: function-environment-configs
input:
apiVersion: environmentconfigs.fn.crossplane.io/v1beta1
kind: Input
spec:
policy:
resolution: Optional
environmentConfigs:
- type: Selector
selector:
matchLabels:
- key: foo
type: FromCompositeFieldPath
valueFromFieldPath: metadata.name
You see the following error in my XR.
message: 'cannot compose resources: pipeline step "loadEnvironmentConfigs" returned
a fatal result: cannot get selected environment configs: expected exactly
one extra resource "environment-config-0", got 0'
I believe this is because the guard is only being applied in the reference case. Happy to open a PR.
Function version: 0.0.4
I would really like to select envs and then be able to create an object for each env I find.
Currently each env I find gets merged which necessitates a unique starting node for each env I want to create.
So for k8s cluster I'd do something like:
envconfig for cluster1
cluster1:
data:
all the things
envconfig for cluster2
cluster2:
data:
all the things
Purely to make each node unique.
If this function could fill an array of all found envconfigs then I could range over them in a go template function or similar.
So maybe optionally we could enable an additional key indexable like index .context "apiextensions.crossplane.io/environments"
plural which is just an unmerged array of environments selected.
Again, we could also make this totally optional and off by default.
That way memory and performance concerns are on the end user.
I personally would use this with a relatively small maxMatch.
Thank you! These functions are completely rad.
I only just got this one up and running locally tonight, and it's real fun to play with.
I could even attempt a PR if you'd like.
Function crashes when referencing to non-existing environment config.
Test environment config:
apiVersion: apiextensions.crossplane.io/v1alpha1
metadata:
name: environment
data:
branch: feature/dev
environment: dev
kind: EnvironmentConfig
Setup step in composition that reads something similar to:
- step: environment-configs
functionRef:
name: function-environment-configs
input:
apiVersion: environmentconfigs.fn.crossplane.io/v1beta1
kind: Input
spec:
environmentConfigs:
- type: Reference
ref:
name: does_not_exist
Submit and you'll get:
2024-03-28T22:35:58.242Z INFO fn/fn.go:40 Running function {"tag": ""}
2024-03-28T22:35:58.242Z DEBUG fn/fn.go:72 No extra resources specified, exiting {"requirements": "extra_resources:{key:\"environment-config-0\" value:{api_version:\"apiextensions.crossplane.io/v1alpha1\" kind:\"EnvironmentConfig\" match_name:\"does_not_exist\"}}"}
2024-03-28T22:35:58.246Z INFO fn/fn.go:40 Running function {"tag": ""}
2024-03-28T22:35:58.246Z DEBUG fn/fn.go:83 Loaded Composition environment from Function context {"context-key": "apiextensions.crossplane.io/environment"}
panic: runtime error: index out of range [0] with length 0
goroutine 5363 [running]:
main.getSelectedEnvConfigs(0xc0004c2500, 0x175a8a3?)
/fn/fn.go:150 +0x7ab
main.(*Function).RunFunction(0xc00041e840, {0xc0002a0660?, 0x499ae6?}, 0xc0002a0660)
/fn/fn.go:92 +0x328
github.com/crossplane/function-sdk-go/proto/v1beta1._FunctionRunnerService_RunFunction_Handler({0x1558b20?, 0xc00041e840}, {0x196f8c0, 0xc00052c0c0}, 0xc0001e4c00, 0x0)
/go/pkg/mod/github.com/crossplane/[email protected]/proto/v1beta1/run_function_grpc.pb.go:104 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000fa000, {0x196f8c0, 0xc00052c030}, {0x1975140, 0xc0005029c0}, 0xc000417b00, 0xc00058a630, 0x248b7d0, 0x0)
/go/pkg/mod/google.golang.org/[email protected]/server.go:1385 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc0000fa000, {0x1975140, 0xc0005029c0}, 0xc000417b00)
/go/pkg/mod/google.golang.org/[email protected]/server.go:1796 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
/go/pkg/mod/google.golang.org/[email protected]/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 8
/go/pkg/mod/google.golang.org/[email protected]/server.go:1040 +0x135
Function version: 0.0.4 - 0.0.6
Crossplane: 1.15.0
(testing locally via crank/crossplane validation and in k8s cluster)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.