@@ -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 |
@@ -280,17 +281,31 @@ The BaseComposite also provides access to the following Crossplane Function leve
280281| self.request | Message | Low level direct access to the RunFunctionRequest message |
281282| self.response | Message | Low level direct access to the RunFunctionResponse message |
282283| self.logger | Logger | Python logger to log messages to the running function stdout |
284+ | self.capabilities | Capabilities | This Crossplane version's Capabilities |
283285| self.parameters | Map | The configured step parameters |
284286| self.ttl | Integer | Get or set the response TTL, in seconds |
285287| self.credentials | Credentials | The request credentials |
286288| self.context | Map | The response context, initialized from the request context |
287289| self.environment | Map | The response environment, initialized from the request context environment |
288290| self.requireds | Requireds | Request and read additional local Kubernetes resources |
291+ | self.schemas | Schemas | Request and read CustomResourceDefinition schemas |
289292| self.resources | Resources | Define and process composed resources |
290293| self.usages| Boolean | Generate Crossplane Usages for resource dependencies, default False |
291294| self.autoReady | Boolean | Perform auto ready processing on all composed resources, default True |
292295| self.unknownsFatal | Boolean | Terminate the composition if already created resources are assigned unknown values, default False |
293296
297+ # ## Capabiities
298+
299+ The Capabilities of the Crossplane version calling function-pythonic.
300+
301+ | Field | Type | Description |
302+ | ----- | ---- | ----------- |
303+ | bool(Capabilities) | Boolean | Whether or not the Crossplane version supports Capabilities |
304+ | Capabiities.requireds | Boolean | Functions can return required resources and Crossplane will fetch the required resources |
305+ | Capabiities.credentials | Boolean | Functions can receive credentials from secrets specified in the Composition |
306+ | Capabiities.conditions | Boolean | Functions can return status conditions to be applied to the XR and optionally its claim |
307+ | Capabiities.schemas | Boolean | Functions can request OpenAPI schemas and Crossplane will return them |
308+
294309# ## Composed Resources
295310
296311Creating and accessing composed resources is performed using the `BaseComposite.resources` field.
@@ -324,7 +339,7 @@ Resource class:
324339
325340Creating and accessing required resources is performed using the `BaseComposite.requireds` field.
326341` BaseComposite.requireds` is a dictionary of the required resources whose key is the required
327- resource name. The value returned when getting a required resource from BaseComposite is the
342+ schema name. The value returned when getting a required resource from BaseComposite is the
328343following RequiredResources class :
329344
330345| Field | Type | Description |
@@ -337,9 +352,6 @@ following RequiredResources class:
337352| RequiredResources.matchName | String | The names to match when returning the required resources |
338353| RequiredResources.matchLabels | Map | The labels to match when returning the required resources |
339354
340- The current version of crossplane-sdk-python used by function-pythonic does not support namespace
341- selection. For now, use matchLabels and filter the results if required.
342-
343355RequiredResources acts like a Python list to provide access to the found required resources.
344356Each resource in the list is the following RequiredResource class :
345357
@@ -356,6 +368,22 @@ Each resource in the list is the following RequiredResource class:
356368| RequiredResource.conditions | Map | The required resource conditions |
357369| RequiredResource.connection | Map | The required resource connection details |
358370
371+ # ## Required Schemas
372+
373+ Creating and accessing required schemas is performed using the `BaseComposite.schemas` field.
374+ ` BaseComposite.schemas` is a dictionary of the required schema whose key is the required
375+ resource name. The value returned when getting a required resource from BaseComposite is the
376+ following Schema class :
377+
378+ | Field | Type | Description |
379+ | ----- | ---- | ----------- |
380+ | Schema(apiVersion,kind) | Schema | Reset the required schema and set the optional parameters |
381+ | Schema.name | String | The required schema name |
382+ | Schema.apiVersion | String | The required schema selector apiVersion |
383+ | Schema.kind | String | The required schema selector kind |
384+ | Schema.\_\_getitem\_\_ | Map | The required schema openAPIV3Schema |
385+ | Schema.\_\_getattr\_\_ | Map | The required schema openAPIV3Schema |
386+
359387# ## Conditions
360388
361389The `BaseComposite.conditions`, `Resource.conditions`, and `RequiredResource.conditions` fields
@@ -474,7 +502,7 @@ $ function-pythonic render --help
474502usage: Crossplane Function Pythonic render [-h] [--debug] [--log-name-width WIDTH] [--logger-level LOGGER=LEVEL] [--python-path DIRECTORY]
475503 [--render-unknowns] [--allow-oversize-protos] [--crossplane-v1] [--kube-context CONTEXT]
476504 [--context-files KEY=PATH] [--context-values KEY=VALUE] [--observed-resources PATH]
477- [--required-resources PATH] [--secret-store PATH] [--include-full-xr] [--include-connection-xr]
505+ [--required-resources PATH] [--required-schemas PATH] [--include-full-xr] [--include-connection-xr]
478506 [--include-function-results] [--include-context]
479507 COMPOSITE [COMPOSITION]
480508
@@ -506,8 +534,8 @@ options:
506534 A YAML file or directory of YAML files specifying the observed state of composed resources.
507535 --required-resources, -e PATH
508536 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 .
537+ --required-schemas , -s PATH
538+ A JSON file or directory of JSON files specifying required schemas to pass to the Function pipeline .
511539 --include-full-xr, -x
512540 Include a direct copy of the input XR's spedc and metadata fields in the rendered output.
513541 --include-connection-xr
@@ -576,9 +604,15 @@ status:
576604Most of the examples contain a `render.sh` command which uses `function-pythonic render` to
577605render the example.
578606
579- # # ConfigMap Packages
607+ # # Shared Python Packages
608+
609+ Python packages and modules can be added to the function-pythonic runtime
610+ by including the python code in any of the following resources : ConfigMap,
611+ Secret, EnvironmentConfig, or Composition
612+
613+ # ## ConfigMap Packages
580614
581- ConfigMap based python packages are enable using the `--packages` and
615+ ConfigMap based python packages are enable using the `--packages-configmaps ` and
582616` --packages-namespace` command line options. ConfigMaps with the label
583617` function-pythonic.package` will be incorporated in the python path at
584618the location configured in the label value. For example, the following
@@ -640,7 +674,7 @@ data:
640674 composite: example.pythonic.features.FeatureOneComposite
641675 ...
642676` ` `
643- This requires enabling the the packages support using the `--packages` command
677+ This requires enabling the the packages support using the `--packages-configmaps ` command
644678line option in the DeploymentRuntimeConfig and configuring the required
645679Kubernetes RBAC permissions. For example :
646680` ` ` yaml
@@ -649,7 +683,7 @@ kind: Function
649683metadata:
650684 name: function-pythonic
651685spec:
652- package: xpkg.upbound .io/crossplane-contrib/function-pythonic:v0.4.2
686+ package: xpkg.crossplane .io/crossplane-contrib/function-pythonic:v0.6.0
653687 runtimeConfigRef:
654688 name: function-pythonic
655689---
@@ -711,9 +745,71 @@ ClusterRole permissions. The `--packages-namespace` command line option will res
711745to only using the supplied namespace. This option can be invoked multiple times.
712746The above RBAC permission can then be per namespace RBAC Role permissions.
713747
748+ # ## Secret Packages
749+
714750Secrets can also be used in an identical manner as ConfigMaps by enabling the
715751` --packages-secrets` command line option. Secrets permissions need to be
716- added to the above RBAC configuration.
752+ added to the above RBAC configuration. Secret based python packages also enable
753+ provisioning files with binary data.
754+
755+ # ## EnvironmentConfig Packages
756+
757+ EnvironmentConfig based provisioning enable an entire package and module
758+ directory structure. Use the `--packages-environmentconfigs` command line option
759+ and configure the ClusterRole RBAC access.
760+ ` ` ` yaml
761+ apiVersion: apiextensions.crossplane.io/v1beta1
762+ kind: EnvironmentConfig
763+ metadata:
764+ name: test
765+ labels:
766+ function-pythonic.package: 'true'
767+ data:
768+ arootpackage:
769+ asubpackage:
770+ bmodule.py: |
771+ def hello(where):
772+ return f"Hello, {where}!"
773+ amodule.py: |
774+ def goodby(where):
775+ return f"Goodby, {where}!"
776+ ` ` `
777+ # ## Composition Packages
778+
779+ Composition based provisioning works just like EnvironmentConfig where a
780+ directory structure is created. Use the `--packages-compositions` command line option
781+ and configure the ClusterRole RBAC access. The main reason to use Composition
782+ based provision is because Compositions can be included in a Crossplane
783+ Configuration Package.
784+ ` ` ` yaml
785+ apiVersion: apiextensions.crossplane.io/v1
786+ kind: Composition
787+ metadata:
788+ labels:
789+ function-pythonic.package: 'true'
790+ name: test
791+ spec:
792+ compositeTypeRef:
793+ apiVersion: code.pythoni.com/v1alpha1
794+ kind: Code
795+ mode: Pipeline
796+ pipeline:
797+ - step: render
798+ functionRef:
799+ name: function-pythonic
800+ input:
801+ apiVersion: pythonic.fn.crossplane.io/v1alpha1
802+ kind: Composite
803+ packages:
804+ arootpackage:
805+ asubpackage:
806+ bmodule.py: |
807+ def hello(where):
808+ return f"Hello, {where}!"
809+ amodule.py: |
810+ def goodby(where):
811+ return f"Goodby, {where}!"
812+ ` ` `
717813
718814# # Step Parameters
719815
0 commit comments