You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
composition.apiextensions.crossplane.io/apps.platform.upbound.io created
414
+
compositeresourcedefinition.apiextensions.crossplane.io/apps.platform.upbound.io created
415
+
```
416
+
390
417
### Configuration Package
391
418
392
-
With the Function package created, the Configuration
393
-
Package can be generated. This package will install the Function
394
-
Package as a dependency.
419
+
Crossplane configuration packages install CompositeResourceDefinition and Composition manifests. The Configuration will install Function and Provider packages as dependencies.
420
+
421
+
With the Function package created, the Configuration Package can be generated. We'll
422
+
update the Configuration package metadata to include our function as a dependency.
@@ -484,13 +512,26 @@ export class Function implements FunctionHandler {
484
512
485
513
The SDK provides helper functions for working with Crossplane resources:
486
514
515
+
**Resource Access:**
516
+
487
517
- `getObservedCompositeResource(req)`- Get the observed composite resource (XR)
488
518
- `getDesiredCompositeResource(req)`- Get the desired composite resource
489
519
- `getObservedComposedResources(req)`- Get observed composed resources
490
520
- `getDesiredComposedResources(req)`- Get desired composed resources
491
521
- `setDesiredComposedResources(rsp, resources)`- Set desired composed resources
522
+
523
+
**Resource Conversion:**
524
+
492
525
- `fromModel(model)`- Convert a Kubernetes model to a Crossplane Resource (added in SDK v0.4.0)
493
526
- `Resource.fromJSON()`- Create resources from JSON (legacy method, use `fromModel` for kubernetes-models)
527
+
528
+
**Status and Conditions (added in SDK v0.5.0):**
529
+
530
+
- `getCondition(resource, type)`- Extract a status condition by type from a resource. Returns a condition object with `status` set to `"Unknown"` if the condition is not found. Useful for checking resource readiness and health.
531
+
- `hasCapability(req, capability)`- Check if a specific Crossplane capability is available. Use the `Capability` enum to check for features like `CAPABILITY_REQUIRED_RESOURCES` or `CAPABILITY_REQUIRED_SCHEMAS`. This helps ensure compatibility with different Crossplane versions.
532
+
533
+
**Response Management:**
534
+
494
535
- `normal(rsp, message)`- Add a normal condition to the response
495
536
- `fatal(rsp, message)`- Add a fatal condition to the response
496
537
- `to(req)`- Create a minimal response from a request
**Note**: As of SDK v0.4.0, the `fromModel` helper function provides a cleaner way to convert kubernetes-models objects to Crossplane Resources. The legacy approach using `Resource.fromJSON({ resource: pod.toJSON() })` is still supported but `fromModel` is now the recommended method.
554
595
596
+
### Checking Resource Conditions (SDK v0.5.0+)
597
+
598
+
The SDK provides the `getCondition` function to extract status conditions from resources:
available: availableCondition.status, // "True", "False", or "Unknown"
619
+
progressing: progressingCondition.status,
620
+
},
621
+
'Deployment conditions'
622
+
);
623
+
}
624
+
```
625
+
626
+
The `getCondition` function returns a condition object with `status` set to `"Unknown"` if the condition type is not found, making it safe to use even when resources are newly created.
0 commit comments