-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error during access to the item of the list #78
Comments
That's how first works in sprig, https://masterminds.github.io/sprig/lists.html. You can use mustFirst which counter intuitively returns an error instead of panicking |
The question is how can I get a particular list item? I tried to use {{ (index .observed.resources.pod.resource.status.atProvider.manifest.status.hostIPs 0).ip }} |
Also, I have run locally the Crossplane CLI. crossplane beta render -o observed.yaml xr.yaml composition.yaml functions.yaml -r
---
apiVersion: example.crossplane.io/v1beta1
kind: XR
metadata:
name: example
status:
conditions:
- lastTransitionTime: "2024-01-01T00:00:00Z"
message: 'Unready resources: test-debug'
reason: Creating
status: "False"
type: Ready
---
apiVersion: example.acme.io/v1beta1
kind: Debug
metadata:
annotations:
crossplane.io/composition-resource-name: test-debug
generateName: example-
labels:
crossplane.io/composite: example
name: test-debug
ownerReferences:
- apiVersion: example.crossplane.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: XR
name: example
uid: ""
spec:
ip: 192.168.65.3 # <---- the ip value log data:
composition.yamlapiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example-function
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1beta1
kind: XR
mode: Pipeline
pipeline:
- step: render-templates
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
---
apiVersion: example.acme.io/v1beta1
kind: Debug
metadata:
name: test-debug
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: test-debug
spec:
ip: {{ (first .observed.resources.pod.resource.status.atProvider.manifest.status.hostIPs).ip }} functions.yamlapiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-go-templating
annotations:
render.crossplane.io/runtime: Development
spec:
package: function-go-templating observed.yamlSome fields were removed for brevity. apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
annotations:
crossplane.io/composition-resource-name: pod
spec:
forProvider:
manifest:
apiVersion: v1
kind: Pod
status:
atProvider:
manifest:
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: default
spec:
containers:
- image: nginx:1.14.2
status:
hostIPs:
- ip: 192.168.65.3
phase: Running xr.yamlapiVersion: example.crossplane.io/v1beta1
kind: XR
metadata:
name: example
spec:
count: 2 |
I solved the problem in this way
In any case how fast should the reconciliation loop fail after getting an error? |
I think I was coming across the same problem - When needing the status of another managed resource that was created in the same composition - any reference would fail ie |
If one resource in the template depends on |
What happened?
During the access to the list item by index or by the
first
function inside the template, I got the error:log data
How can we reproduce it?
composition.yaml
definition.yaml
xr.yaml
What environment did it happen in?
The text was updated successfully, but these errors were encountered: