Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Scorsolini <[email protected]>
  • Loading branch information
phisco committed Aug 5, 2024
1 parent f3b88f5 commit d4d0ef3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
26 changes: 20 additions & 6 deletions example/extra-resources/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,27 @@ spec:
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
matchName: my-awesome-{{ .observed.composite.resource.spec.environment }}-bucket
{{ with index (default (dig "some-foo-by-name" "items" .extraResources)) 0 }}
{{ $bucketName := index . "resource" "status" "atProvider" "id" }}
{{- with .extraResources }}
{{ $someExtraResources := index . "bucket" }}
{{- range $i, $extraResource := $someExtraResources.items }}
---
apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
kind: CompositeConnectionDetails
data:
BUCKET_NAME: {{ $bucketName | b64enc }}
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: bucket-configmap-{{ $i }}
spec:
forProvider:
manifest:
apiVersion: v1
kind: Configmap
metadata:
name: {{ $extraResource.resource.metadata.name }}-bucket
data:
bucket: {{ $extraResource.resource.status.atProvider.id }}
providerConfigRef:
name: "kubernetes"
{{- end }}
{{- end }}
---
apiVersion: example.crossplane.io/v1beta1
Expand Down
3 changes: 3 additions & 0 deletions example/extra-resources/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-go-templating
annotations:
render.crossplane.io/runtime: "Development"
render.crossplane.io/runtime-development-target: "localhost:9443"
spec:
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1
2 changes: 1 addition & 1 deletion fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequ
requirements.ExtraResources[k] = v.ToResourceSelector()
}
default:
response.Fatal(rsp, errors.Errorf("invalid kind %q for apiVersion %q - must be CompositeConnectionDetails", obj.GetKind(), metaApiVersion))
response.Fatal(rsp, errors.Errorf("invalid kind %q for apiVersion %q - must be CompositeConnectionDetails or ExtraResources", obj.GetKind(), metaApiVersion))
return rsp, nil
}

Expand Down
2 changes: 1 addition & 1 deletion fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func TestRunFunction(t *testing.T) {
Results: []*fnv1beta1.Result{
{
Severity: fnv1beta1.Severity_SEVERITY_FATAL,
Message: "invalid kind \"InvalidMeta\" for apiVersion \"" + metaApiVersion + "\" - must be CompositeConnectionDetails",
Message: "invalid kind \"InvalidMeta\" for apiVersion \"" + metaApiVersion + "\" - must be CompositeConnectionDetails or ExtraResources",
},
},
Desired: &fnv1beta1.State{
Expand Down

0 comments on commit d4d0ef3

Please sign in to comment.