@@ -57,7 +57,7 @@ kind: Function
5757metadata :
5858 name : function-pythonic
5959spec :
60- package : xpkg.upbound .io/crossplane-contrib/function-pythonic:v0.4.2
60+ package : xpkg.crossplane .io/crossplane-contrib/function-pythonic:v0.6.0
6161` ` `
6262
6363### Crossplane V1
@@ -69,7 +69,7 @@ kind: Function
6969metadata:
7070 name: function-pythonic
7171spec:
72- package: xpkg.upbound .io/crossplane-contrib/function-pythonic:v0.4.2
72+ package: xpkg.crossplane .io/crossplane-contrib/function-pythonic:v0.6.0
7373 runtimeConfigRef:
7474 name: function-pythonic
7575--
@@ -266,6 +266,7 @@ The BaseComposite class provides the following fields for manipulating the Compo
266266| self.metadata | Map | The composite observed metadata |
267267| self.spec | Map | The composite observed spec |
268268| self.status | Map | The composite desired and observed status, read from observed if not in desired |
269+ | self.output | Map | The step output, only used during Operations |
269270| self.conditions | Conditions | The composite desired and observed conditions, read from observed if not in desired |
270271| self.results | Results | Returned results applied to the Composite and optionally on the Claim |
271272| self.connectionSecret | Map | The name, namespace, and resourceName to use when generating the connection secret in Crossplane v2 |
@@ -286,6 +287,7 @@ The BaseComposite also provides access to the following Crossplane Function leve
286287| self.context | Map | The response context, initialized from the request context |
287288| self.environment | Map | The response environment, initialized from the request context environment |
288289| self.requireds | Requireds | Request and read additional local Kubernetes resources |
290+ | self.schemas | Schemas | Request and read CustomResourceDefinition schemas |
289291| self.resources | Resources | Define and process composed resources |
290292| self.usages| Boolean | Generate Crossplane Usages for resource dependencies, default False |
291293| self.autoReady | Boolean | Perform auto ready processing on all composed resources, default True |
@@ -356,6 +358,41 @@ Each resource in the list is the following RequiredResource class:
356358| RequiredResource.conditions | Map | The required resource conditions |
357359| RequiredResource.connection | Map | The required resource connection details |
358360
361+ # ## Required Schemas
362+
363+ Creating and accessing required schemas is performed using the `BaseComposite.schemas` field.
364+ ` BaseComposite.schemas` is a dictionary of the required schema whose key is the required
365+ resource name. The value returned when getting a required resource from BaseComposite is the
366+ following Schema class :
367+
368+ | Field | Type | Description |
369+ | ----- | ---- | ----------- |
370+ | Schema(apiVersion,kind) | Schema | Reset the required schema and set the optional parameters |
371+ | Schema.name | String | The required schema name |
372+ | Schema.apiVersion | String | The required schema selector apiVersion |
373+ | Schema.kind | String | The required schema selector kind |
374+ | Schema.__getitem__ | Map | The required schema openAPIV3Schema |
375+ | Schema.__getattr__ | Map | The required schema openAPIV3Schema |
376+
377+ The current version of crossplane-sdk-python used by function-pythonic does not support namespace
378+ selection. For now, use matchLabels and filter the results if required.
379+
380+ RequiredResources acts like a Python list to provide access to the found required resources.
381+ Each resource in the list is the following RequiredResource class :
382+
383+ | Field | Type | Description |
384+ | ----- | ---- | ----------- |
385+ | RequiredResource.name | String | The required resource name |
386+ | RequiredResource.observed | Map | Low level direct access to the observed required resource |
387+ | RequiredResource.apiVersion | String | The required resource apiVersion |
388+ | RequiredResource.kind | String | The required resource kind |
389+ | RequiredResource.metadata | Map | The required resource metadata |
390+ | RequiredResource.spec | Map | The required resource spec |
391+ | RequiredResource.data | Map | The required resource data |
392+ | RequiredResource.status | Map | The required resource status |
393+ | RequiredResource.conditions | Map | The required resource conditions |
394+ | RequiredResource.connection | Map | The required resource connection details |
395+
359396# ## Conditions
360397
361398The `BaseComposite.conditions`, `Resource.conditions`, and `RequiredResource.conditions` fields
@@ -474,7 +511,7 @@ $ function-pythonic render --help
474511usage: Crossplane Function Pythonic render [-h] [--debug] [--log-name-width WIDTH] [--logger-level LOGGER=LEVEL] [--python-path DIRECTORY]
475512 [--render-unknowns] [--allow-oversize-protos] [--crossplane-v1] [--kube-context CONTEXT]
476513 [--context-files KEY=PATH] [--context-values KEY=VALUE] [--observed-resources PATH]
477- [--required-resources PATH] [--secret-store PATH] [--include-full-xr] [--include-connection-xr]
514+ [--required-resources PATH] [--required-schemas PATH] [--include-full-xr] [--include-connection-xr]
478515 [--include-function-results] [--include-context]
479516 COMPOSITE [COMPOSITION]
480517
@@ -506,8 +543,8 @@ options:
506543 A YAML file or directory of YAML files specifying the observed state of composed resources.
507544 --required-resources, -e PATH
508545 A YAML file or directory of YAML files specifying required resources to pass to the Function pipeline.
509- --secret-store , -s PATH
510- A YAML file or directory of YAML files specifying Secrets to use to resolve connections and credentials .
546+ --required-schemas , -s PATH
547+ A JSON file or directory of JSON files specifying required schemas to pass to the Function pipeline .
511548 --include-full-xr, -x
512549 Include a direct copy of the input XR's spedc and metadata fields in the rendered output.
513550 --include-connection-xr
@@ -576,9 +613,15 @@ status:
576613Most of the examples contain a `render.sh` command which uses `function-pythonic render` to
577614render the example.
578615
579- # # ConfigMap Packages
616+ # # Shared Python Packages
617+
618+ Python packages and modules can be added to the function-pythonic runtime
619+ by including the python code in any of the following resources : ConfigMap,
620+ Secret, EnvironmentConfig, or Composition
580621
581- ConfigMap based python packages are enable using the `--packages` and
622+ # ## ConfigMap Packages
623+
624+ ConfigMap based python packages are enable using the `--packages-configmaps` and
582625` --packages-namespace` command line options. ConfigMaps with the label
583626` function-pythonic.package` will be incorporated in the python path at
584627the location configured in the label value. For example, the following
@@ -640,7 +683,7 @@ data:
640683 composite: example.pythonic.features.FeatureOneComposite
641684 ...
642685` ` `
643- This requires enabling the the packages support using the `--packages` command
686+ This requires enabling the the packages support using the `--packages-configmaps ` command
644687line option in the DeploymentRuntimeConfig and configuring the required
645688Kubernetes RBAC permissions. For example :
646689` ` ` yaml
@@ -649,7 +692,7 @@ kind: Function
649692metadata:
650693 name: function-pythonic
651694spec:
652- package: xpkg.upbound .io/crossplane-contrib/function-pythonic:v0.4.2
695+ package: xpkg.crossplane .io/crossplane-contrib/function-pythonic:v0.6.0
653696 runtimeConfigRef:
654697 name: function-pythonic
655698---
@@ -711,9 +754,71 @@ ClusterRole permissions. The `--packages-namespace` command line option will res
711754to only using the supplied namespace. This option can be invoked multiple times.
712755The above RBAC permission can then be per namespace RBAC Role permissions.
713756
757+ # ## Secret Packages
758+
714759Secrets can also be used in an identical manner as ConfigMaps by enabling the
715760` --packages-secrets` command line option. Secrets permissions need to be
716- added to the above RBAC configuration.
761+ added to the above RBAC configuration. Secret based python packages also enable
762+ provisioning files with binary data.
763+
764+ # ## EnvironmentConfig Packages
765+
766+ EnvironmentConfig based provisioning enable an entire package and module
767+ directory structure. Use the `--packages-environmentconfigs` command line option
768+ and configure the ClusterRole RBAC access.
769+ ` ` ` yaml
770+ apiVersion: apiextensions.crossplane.io/v1beta1
771+ kind: EnvironmentConfig
772+ metadata:
773+ name: test
774+ labels:
775+ function-pythonic.package: 'true'
776+ data:
777+ arootpackage:
778+ asubpackage:
779+ bmodule.py: |
780+ def hello(where):
781+ return f"Hello, {where}!"
782+ amodule.py: |
783+ def goodby(where):
784+ return f"Goodby, {where}!"
785+ ` ` `
786+ # ## EnvironmentConfig Packages
787+
788+ Composition based provisioning works just like EnvironmentConfig where a
789+ directory structure is created. Use the `--packages-compositions` command line option
790+ and configure the ClusterRole RBAC access. The main reason to use Composition
791+ based provision is because Compositions can be included in a Crossplane
792+ Configuration Package.
793+ ` ` ` yaml
794+ apiVersion: apiextensions.crossplane.io/v1
795+ kind: Composition
796+ metadata:
797+ labels:
798+ function-pythonic.package: 'true'
799+ name: test
800+ spec:
801+ compositeTypeRef:
802+ apiVersion: code.pythoni.com/v1alpha1
803+ kind: Code
804+ mode: Pipeline
805+ pipeline:
806+ - step: render
807+ functionRef:
808+ name: function-pythonic
809+ input:
810+ apiVersion: pythonic.fn.crossplane.io/v1alpha1
811+ kind: Composite
812+ packages:
813+ arootpackage:
814+ asubpackage:
815+ bmodule.py: |
816+ def hello(where):
817+ return f"Hello, {where}!"
818+ amodule.py: |
819+ def goodby(where):
820+ return f"Goodby, {where}!"
821+ ` ` `
717822
718823# # Step Parameters
719824
0 commit comments