crossplane-function-pythonic 0.1.1__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/PKG-INFO +5 -5
  2. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/README.md +4 -4
  3. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/crossplane/pythonic/composite.py +24 -29
  4. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/crossplane/pythonic/function.py +6 -7
  5. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/crossplane/pythonic/main.py +8 -8
  6. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/.dev/functions.yaml +1 -1
  7. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/cluster-function-pythonic.yaml +1 -1
  8. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/functions.yaml +1 -1
  9. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/functions.yaml +1 -1
  10. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/function.yaml +1 -1
  11. {crossplane_function_pythonic-0.1.1/examples/function-go-templating/context → crossplane_function_pythonic-0.1.3/examples/function-go-templating/conditions}/functions.yaml +1 -1
  12. {crossplane_function_pythonic-0.1.1/examples/function-go-templating/conditions → crossplane_function_pythonic-0.1.3/examples/function-go-templating/context}/functions.yaml +1 -1
  13. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/extra-resources/functions.yaml +1 -1
  14. {crossplane_function_pythonic-0.1.1/examples/function-go-templating/functions/getComposedResource → crossplane_function_pythonic-0.1.3/examples/function-go-templating/functions/fromYaml}/functions.yaml +1 -1
  15. {crossplane_function_pythonic-0.1.1/examples/function-go-templating/functions/getCompositeResource → crossplane_function_pythonic-0.1.3/examples/function-go-templating/functions/getComposedResource}/functions.yaml +1 -1
  16. {crossplane_function_pythonic-0.1.1/examples/function-go-templating/functions/fromYaml → crossplane_function_pythonic-0.1.3/examples/function-go-templating/functions/getCompositeResource}/functions.yaml +1 -1
  17. crossplane_function_pythonic-0.1.3/examples/function-go-templating/functions/getResourceCondition/functions.yaml +9 -0
  18. crossplane_function_pythonic-0.1.3/examples/function-go-templating/functions/include/functions.yaml +9 -0
  19. crossplane_function_pythonic-0.1.3/examples/function-go-templating/functions/toYaml/functions.yaml +9 -0
  20. crossplane_function_pythonic-0.1.3/examples/function-go-templating/inline/functions.yaml +9 -0
  21. crossplane_function_pythonic-0.1.3/examples/function-go-templating/recursive/functions.yaml +9 -0
  22. {crossplane_function_pythonic-0.1.1/examples/single-purpose → crossplane_function_pythonic-0.1.3/examples/get-started-app}/functions.yaml +1 -1
  23. {crossplane_function_pythonic-0.1.1/examples/get-started-app → crossplane_function_pythonic-0.1.3/examples/helm-copy-secret}/functions.yaml +1 -1
  24. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/README.md +35 -0
  25. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/composition.yaml +68 -0
  26. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/definition.yaml +39 -0
  27. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/functions.yaml +8 -0
  28. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/observed.yaml +6 -0
  29. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/provider-ec2.yaml +20 -0
  30. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/render.sh +4 -0
  31. crossplane_function_pythonic-0.1.3/examples/import-existing-vpc/xr.yaml +10 -0
  32. {crossplane_function_pythonic-0.1.1/examples/helm-copy-secret → crossplane_function_pythonic-0.1.3/examples/single-purpose}/functions.yaml +1 -1
  33. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/single-purpose/xr.yaml +1 -0
  34. crossplane_function_pythonic-0.1.3/examples/usages-extra/functions.yaml +9 -0
  35. crossplane_function_pythonic-0.1.1/examples/function-go-templating/functions/getResourceCondition/functions.yaml +0 -9
  36. crossplane_function_pythonic-0.1.1/examples/function-go-templating/functions/include/functions.yaml +0 -9
  37. crossplane_function_pythonic-0.1.1/examples/function-go-templating/functions/toYaml/functions.yaml +0 -9
  38. crossplane_function_pythonic-0.1.1/examples/function-go-templating/inline/functions.yaml +0 -9
  39. crossplane_function_pythonic-0.1.1/examples/function-go-templating/recursive/functions.yaml +0 -9
  40. crossplane_function_pythonic-0.1.1/examples/usages-extra/functions.yaml +0 -9
  41. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/.gitignore +0 -0
  42. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/LICENSE +0 -0
  43. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/crossplane/pythonic/__init__.py +0 -0
  44. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/crossplane/pythonic/packages.py +0 -0
  45. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/crossplane/pythonic/protobuf.py +0 -0
  46. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/README.md +0 -0
  47. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/aks/kubernetescluster.py +0 -0
  48. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/aks/resourcegroup.py +0 -0
  49. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/composition.yaml +0 -0
  50. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/definition.yaml +0 -0
  51. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/install.sh +0 -0
  52. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/kustomization.yaml +0 -0
  53. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/providers.yaml +0 -0
  54. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/render.sh +0 -0
  55. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/aks-cluster/xr.yaml +0 -0
  56. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/composition-v2.yaml +0 -0
  57. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/composition.yaml +0 -0
  58. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/definition.yaml +0 -0
  59. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/render-v2.sh +0 -0
  60. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/render.sh +0 -0
  61. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/eks-cluster/xr.yaml +0 -0
  62. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/README.md +0 -0
  63. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/composition.yaml +0 -0
  64. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/definition.yaml +0 -0
  65. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/kustomization.yaml +0 -0
  66. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/runtime.yaml +0 -0
  67. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/vcluster.py +0 -0
  68. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/filing-system/vcluster.yaml +0 -0
  69. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/conditions/composition.yaml +0 -0
  70. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/conditions/render.sh +0 -0
  71. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/conditions/xr.yaml +0 -0
  72. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/conditions/xrd.yaml +0 -0
  73. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/context/composition.yaml +0 -0
  74. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/context/environmentConfigs.yaml +0 -0
  75. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/context/render.sh +0 -0
  76. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/context/xr.yaml +0 -0
  77. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/context/xrd.yaml +0 -0
  78. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/extra-resources/composition.yaml +0 -0
  79. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/extra-resources/extraResources.yaml +0 -0
  80. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/extra-resources/render.sh +0 -0
  81. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/extra-resources/xr.yaml +0 -0
  82. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/fromYaml/composition.yaml +0 -0
  83. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/fromYaml/render.sh +0 -0
  84. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/fromYaml/xr.yaml +0 -0
  85. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getComposedResource/composition.yaml +0 -0
  86. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getComposedResource/observed.yaml +0 -0
  87. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getComposedResource/render.sh +0 -0
  88. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getComposedResource/xr.yaml +0 -0
  89. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getCompositeResource/composition.yaml +0 -0
  90. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getCompositeResource/render.sh +0 -0
  91. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getCompositeResource/xr.yaml +0 -0
  92. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getResourceCondition/composition.yaml +0 -0
  93. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getResourceCondition/observed.yaml +0 -0
  94. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getResourceCondition/render.sh +0 -0
  95. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/getResourceCondition/xr.yaml +0 -0
  96. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/include/composition.yaml +0 -0
  97. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/include/render.sh +0 -0
  98. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/include/xr.yaml +0 -0
  99. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/toYaml/composition.yaml +0 -0
  100. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/toYaml/render.sh +0 -0
  101. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/functions/toYaml/xr.yaml +0 -0
  102. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/inline/composition.yaml +0 -0
  103. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/inline/render.sh +0 -0
  104. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/inline/xr.yaml +0 -0
  105. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/recursive/composition-real.yaml +0 -0
  106. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/recursive/composition-wrapper.yaml +0 -0
  107. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/recursive/render.sh +0 -0
  108. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/function-go-templating/recursive/xr.yaml +0 -0
  109. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/get-started-app/composition.yaml +0 -0
  110. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/get-started-app/definition.yaml +0 -0
  111. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/get-started-app/render.sh +0 -0
  112. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/get-started-app/xr.yaml +0 -0
  113. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/composition.yaml +0 -0
  114. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/kustomization.yaml +0 -0
  115. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/render.sh +0 -0
  116. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/run-function.sh +0 -0
  117. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/vcluster.py +0 -0
  118. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/xr.yaml +0 -0
  119. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/helm-copy-secret/xrd.yaml +0 -0
  120. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/single-purpose/render.sh +0 -0
  121. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/usages-extra/composition.yaml +0 -0
  122. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/usages-extra/extraResources.yaml +0 -0
  123. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/usages-extra/observedResources.yaml +0 -0
  124. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/usages-extra/render.sh +0 -0
  125. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/examples/usages-extra/xr.yaml +0 -0
  126. {crossplane_function_pythonic-0.1.1 → crossplane_function_pythonic-0.1.3}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crossplane-function-pythonic
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A Python centric Crossplane Function
5
5
  Project-URL: Documentation, https://github.com/fortra/function-pythonic#readme
6
6
  Project-URL: Issues, https://github.com/fortra/function-pythonic/issues
@@ -49,7 +49,7 @@ spec:
49
49
  functionRef:
50
50
  name: function-pythonic
51
51
  input:
52
- apiVersion: pythonic.fn.crossplane.io/v1beta1
52
+ apiVersion: pythonic.fn.fortra.com/v1alpha1
53
53
  kind: Composite
54
54
  composite: |
55
55
  class VpcComposite(BaseComposite):
@@ -81,7 +81,7 @@ kind: Function
81
81
  metadata:
82
82
  name: function-pythonic
83
83
  spec:
84
- package: ghcr.io/fortra/function-pythonic:v0.1.1
84
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
85
85
  ```
86
86
  ## Composed Resource Dependencies
87
87
 
@@ -408,7 +408,7 @@ metadata:
408
408
  annotations:
409
409
  render.crossplane.io/runtime: Development
410
410
  spec:
411
- package: ghcr.io/fortra/function-pythonic:v0.1.1
411
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
412
412
  ```
413
413
  In one terminal session, run function-pythonic:
414
414
  ```shell
@@ -510,7 +510,7 @@ kind: Function
510
510
  metadata:
511
511
  name: function-pythonic
512
512
  spec:
513
- package: ghcr.io/fortra/function-pythonic:v0.1.1
513
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
514
514
  runtimeConfigRef:
515
515
  name: function-pythonic
516
516
  ---
@@ -25,7 +25,7 @@ spec:
25
25
  functionRef:
26
26
  name: function-pythonic
27
27
  input:
28
- apiVersion: pythonic.fn.crossplane.io/v1beta1
28
+ apiVersion: pythonic.fn.fortra.com/v1alpha1
29
29
  kind: Composite
30
30
  composite: |
31
31
  class VpcComposite(BaseComposite):
@@ -57,7 +57,7 @@ kind: Function
57
57
  metadata:
58
58
  name: function-pythonic
59
59
  spec:
60
- package: ghcr.io/fortra/function-pythonic:v0.1.1
60
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
61
61
  ```
62
62
  ## Composed Resource Dependencies
63
63
 
@@ -384,7 +384,7 @@ metadata:
384
384
  annotations:
385
385
  render.crossplane.io/runtime: Development
386
386
  spec:
387
- package: ghcr.io/fortra/function-pythonic:v0.1.1
387
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
388
388
  ```
389
389
  In one terminal session, run function-pythonic:
390
390
  ```shell
@@ -486,7 +486,7 @@ kind: Function
486
486
  metadata:
487
487
  name: function-pythonic
488
488
  spec:
489
- package: ghcr.io/fortra/function-pythonic:v0.1.1
489
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
490
490
  runtimeConfigRef:
491
491
  name: function-pythonic
492
492
  ---
@@ -41,7 +41,7 @@ class BaseComposite:
41
41
  self.kind = self.observed.kind
42
42
  self.metadata = self.observed.metadata
43
43
  self.spec = self.observed.spec
44
- self.status = Status(self.observed.status, self.desired.status)
44
+ self.status = self.desired.status
45
45
  self.conditions = Conditions(observed, self.response)
46
46
  self.connection = Connection(observed, desired)
47
47
  self.events = Events(self.response)
@@ -140,12 +140,17 @@ class Credential:
140
140
  class Resources:
141
141
  def __init__(self, composite):
142
142
  self.__dict__['_composite'] = composite
143
+ self.__dict__['_cache'] = {}
143
144
 
144
145
  def __getattr__(self, key):
145
146
  return self[key]
146
147
 
147
148
  def __getitem__(self, key):
148
- return Resource(self._composite, key)
149
+ resource = self._cache.get(key)
150
+ if not resource:
151
+ resource = Resource(self._composite, key)
152
+ self._cache[key] = resource
153
+ return resource
149
154
 
150
155
  def __bool__(self):
151
156
  return bool(self._composite.response.desired.resources)
@@ -165,6 +170,7 @@ class Resources:
165
170
 
166
171
  def __setitem__(self, key, resource):
167
172
  self._composite.response.desired.resources[key].resource = resource
173
+ self._cache.pop(key, None)
168
174
 
169
175
  def __delattr__(self, key):
170
176
  del self[key]
@@ -172,6 +178,7 @@ class Resources:
172
178
  def __delitem__(self, key):
173
179
  if key in self._composite.response.desired.resources:
174
180
  del self._composite.response.desired.resources[key]
181
+ self._cache.pop(key, None)
175
182
 
176
183
 
177
184
  class Resource:
@@ -217,10 +224,9 @@ class Resource:
217
224
 
218
225
  @property
219
226
  def externalName(self):
220
- name = self.metadata.annotations['crossplane.io/external-name']
221
- if name is None:
222
- name = self.observed.metadata.annotations['crossplane.io/external-name']
223
- return name
227
+ if 'crossplane.io/external-name' in self.metadata.annotations:
228
+ return self.metadata.annotations['crossplane.io/external-name']
229
+ return self.observed.metadata.annotations['crossplane.io/external-name']
224
230
 
225
231
  @externalName.setter
226
232
  def externalName(self, name):
@@ -277,12 +283,17 @@ class Resource:
277
283
  class Requireds:
278
284
  def __init__(self, composite):
279
285
  self._composite = composite
286
+ self._cache = {}
280
287
 
281
288
  def __getattr__(self, key):
282
289
  return self[key]
283
290
 
284
291
  def __getitem__(self, key):
285
- return RequiredResources(self._composite, key)
292
+ required = self._cache.get(key)
293
+ if not required:
294
+ required = RequiredResources(self._composite, key)
295
+ self._cache[key] = required
296
+ return required
286
297
 
287
298
  def __bool__(self):
288
299
  return bool(len(self))
@@ -317,6 +328,7 @@ class RequiredResources:
317
328
  self.name = name
318
329
  self._selector = composite.response.requirements.extra_resources[name]
319
330
  self._resources = composite.request.extra_resources[name]
331
+ self._cache = {}
320
332
 
321
333
  def __call__(self, apiVersion=_notset, kind=_notset, namespace=_notset, name=_notset, labels=_notset):
322
334
  self._selector()
@@ -379,7 +391,11 @@ class RequiredResources:
379
391
  self._selector.match_labels.labels[entry[0]] = entry[1]
380
392
 
381
393
  def __getitem__(self, ix):
382
- return RequiredResource(self.name, ix, self._resources.items[ix])
394
+ resource = self._cache.get(ix)
395
+ if not resource:
396
+ resource = RequiredResource(self.name, ix, self._resources.items[ix])
397
+ self._cache[ix] = resource
398
+ return resource
383
399
 
384
400
  def __bool__(self):
385
401
  return bool(self._resources.items)
@@ -409,27 +425,6 @@ class RequiredResource:
409
425
  return bool(self.observed)
410
426
 
411
427
 
412
- class Status:
413
- def __init__(self, observed, desired):
414
- self.__dict__['_observed'] = observed
415
- self.__dict__['_desired'] = desired
416
-
417
- def __getattr__(self, key):
418
- return self[key]
419
-
420
- def __getitem__(self, key):
421
- value = self._desired[key]
422
- if value is None:
423
- value = self._observed[key]
424
- return value
425
-
426
- def __setattr__(self, key, value):
427
- self[key] = value
428
-
429
- def __setitem__(self, key, value):
430
- self._desired[key] = value
431
-
432
-
433
428
  class Conditions:
434
429
  def __init__(self, observed, response=None):
435
430
  self._observed = observed
@@ -123,7 +123,7 @@ class FunctionRunner(grpcv1.FunctionRunnerService):
123
123
 
124
124
  def fatal(self, request, logger, message, exception=None):
125
125
  if exception:
126
- message += ' exceptiion'
126
+ message += ' exception'
127
127
  logger.exception(message)
128
128
  m = str(exception)
129
129
  if not m:
@@ -169,13 +169,14 @@ class FunctionRunner(grpcv1.FunctionRunnerService):
169
169
  source = self.trimFullName(source)
170
170
  composite.logger.debug(f"Dependency: {destination} = {source}")
171
171
  if resource.usages or (resource.usages is None and composite.usages):
172
+ apiVersion = 'protection.crossplane.io/v1beta1' if composite.metadata.namespace else 'apiextensions.crossplane.io/v1beta1'
172
173
  resources = {}
173
174
  requireds = {}
174
175
  for destination, source in sorted(dependencies.items()):
175
176
  name = source.split('.')
176
177
  if (len(name) > 5 and
177
- name[0] == 'request' and
178
- name[1] == 'observed' and
178
+ name[0] in ('request', 'response') and
179
+ name[1] in ('observed', 'desired') and
179
180
  name[2] == 'resources' and
180
181
  name[4] == 'resource'
181
182
  ):
@@ -198,8 +199,7 @@ class FunctionRunner(grpcv1.FunctionRunnerService):
198
199
  if source.metadata.namespace:
199
200
  name.append(str(source.metadata.namespace))
200
201
  name.append(str(source.observed.metadata.name))
201
- usage = composite.resources['_'.join(name)]('apiextensions.crossplane.io/v1beta1', 'Usage')
202
- #usage = composite.resources['_'.join(name)]('protection.crossplane.io/v1beta1', 'Usage')
202
+ usage = composite.resources['_'.join(name)](apiVersion, 'Usage')
203
203
  if resource.metadata.namespace:
204
204
  usage.metadata.namespace = resource.metadata.namespace
205
205
  usage.spec.reason = '\n'.join(dependencies)
@@ -218,8 +218,7 @@ class FunctionRunner(grpcv1.FunctionRunnerService):
218
218
  if source.metadata.namespace:
219
219
  name.append(str(source.metadata.namespace))
220
220
  name.append(str(source.metadata.name))
221
- usage = composite.resources['_'.join(name)]('apiextensions.crossplane.io/v1beta1', 'Usage')
222
- #usage = composite.resources['_'.join(name)]('protection.crossplane.io/v1beta1', 'Usage')
221
+ usage = composite.resources['_'.join(name)](apiVersion, 'Usage')
223
222
  if resource.metadata.namespace:
224
223
  usage.metadata.namespace = resource.metadata.namespace
225
224
  usage.spec.reason = '\n'.join(dependencies)
@@ -102,13 +102,6 @@ class Main:
102
102
  print('Either --tls-certs-dir or --insecure must be specified', file=sys.stderr)
103
103
  sys.exit(1)
104
104
 
105
- self.configure_logging(args)
106
- # enables read only volumes or mismatched uid volumes
107
- sys.dont_write_bytecode = True
108
- await self.run(args)
109
-
110
- # Allow for independent running of function-pythonic
111
- async def run(self, args):
112
105
  if args.pip_install:
113
106
  import pip._internal.cli.main
114
107
  pip._internal.cli.main.main(['install', '--user', *shlex.split(args.pip_install)])
@@ -116,6 +109,13 @@ class Main:
116
109
  for path in reversed(args.python_path):
117
110
  sys.path.insert(0, str(pathlib.Path(path).expanduser().resolve()))
118
111
 
112
+ self.configure_logging(args)
113
+ # enables read only volumes or mismatched uid volumes
114
+ sys.dont_write_bytecode = True
115
+ await self.run(args)
116
+
117
+ # Allow for independent running of function-pythonic
118
+ async def run(self, args):
119
119
  if args.allow_oversize_protos:
120
120
  from google.protobuf.internal import api_implementation
121
121
  if api_implementation._c_module:
@@ -166,7 +166,7 @@ class Main:
166
166
  handler = logging.StreamHandler()
167
167
  handler.setFormatter(formatter)
168
168
  logger = logging.getLogger()
169
- logger.addHandler(handler)
169
+ logger.handlers = [handler]
170
170
  logger.setLevel(logging.DEBUG if args.debug else logging.INFO)
171
171
 
172
172
 
@@ -10,4 +10,4 @@ metadata:
10
10
  render.crossplane.io/runtime: Development
11
11
  render.crossplane.io/runtime-development-target: localhost:9443
12
12
  spec:
13
- package: ghcr.io/fortra/function-pythonic:v0.1.1
13
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -3,7 +3,7 @@ kind: Function
3
3
  metadata:
4
4
  name: function-pythonic
5
5
  spec:
6
- package: ghcr.io/fortra/function-pythonic:v0.1.1
6
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
7
7
  runtimeConfigRef:
8
8
  name: function-pythonic
9
9
  ---
@@ -5,6 +5,6 @@ metadata:
5
5
  annotations:
6
6
  render.crossplane.io/runtime: Development
7
7
  spec:
8
- package: ghcr.io/fortra/function-pythonic:v0.1.1
8
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
9
9
  runtimeConfigRef:
10
10
  name: function-pythonic
@@ -5,4 +5,4 @@ metadata:
5
5
  annotations:
6
6
  render.crossplane.io/runtime: Development
7
7
  spec:
8
- package: ghcr.io/fortra/function-pythonic:v0.1.1
8
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -3,7 +3,7 @@ kind: Function
3
3
  metadata:
4
4
  name: function-pythonic
5
5
  spec:
6
- package: ghcr.io/fortra/function-pythonic:v0.1.1
6
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
7
7
  runtimeConfigRef:
8
8
  apiVersion: pkg.crossplane.io/v1beta1
9
9
  kind: DeploymentRuntimeConfig
@@ -15,7 +15,7 @@ metadata:
15
15
  # This tells crossplane beta render to connect to the function locally.
16
16
  render.crossplane.io/runtime: Development
17
17
  spec:
18
- package: ghcr.io/fortra/function-pythonic:v0.1.1
18
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
19
19
  ---
20
20
  apiVersion: pkg.crossplane.io/v1beta1
21
21
  kind: Function
@@ -15,7 +15,7 @@ metadata:
15
15
  # This tells crossplane beta render to connect to the function locally.
16
16
  render.crossplane.io/runtime: Development
17
17
  spec:
18
- package: ghcr.io/fortra/function-pythonic:v0.1.1
18
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
19
19
  ---
20
20
  apiVersion: pkg.crossplane.io/v1beta1
21
21
  kind: Function
@@ -6,4 +6,4 @@ metadata:
6
6
  # This tells crossplane beta render to connect to the function locally.
7
7
  render.crossplane.io/runtime: Development
8
8
  spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -6,4 +6,4 @@ metadata:
6
6
  # This tells crossplane beta render to connect to the function locally.
7
7
  render.crossplane.io/runtime: Development
8
8
  spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -6,4 +6,4 @@ metadata:
6
6
  # This tells crossplane beta render to connect to the function locally.
7
7
  render.crossplane.io/runtime: Development
8
8
  spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -6,4 +6,4 @@ metadata:
6
6
  # This tells crossplane beta render to connect to the function locally.
7
7
  render.crossplane.io/runtime: Development
8
8
  spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,9 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ # This tells crossplane beta render to connect to the function locally.
7
+ render.crossplane.io/runtime: Development
8
+ spec:
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,9 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ # This tells crossplane beta render to connect to the function locally.
7
+ render.crossplane.io/runtime: Development
8
+ spec:
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,9 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ # This tells crossplane beta render to connect to the function locally.
7
+ render.crossplane.io/runtime: Development
8
+ spec:
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,9 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ # This tells crossplane beta render to connect to the function locally.
7
+ render.crossplane.io/runtime: Development
8
+ spec:
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,9 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ # This tells crossplane beta render to connect to the function locally.
7
+ render.crossplane.io/runtime: Development
8
+ spec:
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -5,4 +5,4 @@ metadata:
5
5
  annotations:
6
6
  render.crossplane.io/runtime: Development
7
7
  spec:
8
- package: ghcr.io/fortra/function-pythonic:v0.1.1
8
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -5,4 +5,4 @@ metadata:
5
5
  annotations:
6
6
  render.crossplane.io/runtime: Development
7
7
  spec:
8
- package: ghcr.io/fortra/function-pythonic:v0.1.1
8
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,35 @@
1
+ # Import Existing VPC
2
+
3
+ This example demonstrates how to dynamically detect and importing
4
+ existing external resources when the external name of that resource
5
+ is a name generated by the external backend.
6
+
7
+ function-pythonic is deployed using `--pip-install` command line
8
+ option to install the AWS python client and must be configured
9
+ with the needed AWS permissions.
10
+
11
+ Here is an example of a DeploymentRuntimeConfig that uses the
12
+ `function-pythonic` ServiceAccount name which is configured
13
+ with needed EKS Pod Identity AWS permissions:
14
+ ```yaml
15
+ apiVersion: pkg.crossplane.io/v1beta1
16
+ kind: DeploymentRuntimeConfig
17
+ metadata:
18
+ name: function-pythonic
19
+ spec:
20
+ deploymentTemplate:
21
+ spec:
22
+ template:
23
+ spec:
24
+ containers:
25
+ - name: package-runtime
26
+ args:
27
+ - --debug
28
+ - --pip-install
29
+ - --quiet aiobotocore==2.23.2
30
+ serviceAccountName: function-pythonic
31
+ ```
32
+ To run the `render.sh` script, ensure that aiobotocore is installed
33
+ in the python environment used. The default AWS profile will be used
34
+ unless the AWS_PROFILE environment variable is set, or other
35
+ appropriate AWS environment variables.
@@ -0,0 +1,68 @@
1
+ apiVersion: apiextensions.crossplane.io/v1
2
+ kind: Composition
3
+ metadata:
4
+ name: networks.caleb.pythonic.com
5
+ spec:
6
+ compositeTypeRef:
7
+ apiVersion: caleb.pythonic.com/v1alpha1
8
+ kind: Network
9
+ mode: Pipeline
10
+ pipeline:
11
+
12
+ - step: render-templates
13
+ functionRef:
14
+ name: function-pythonic
15
+ input:
16
+ apiVersion: pythonic.fn.fortra.com/v1alpha1
17
+ kind: Composite
18
+ composite: |
19
+ from crossplane.pythonic import BaseComposite
20
+ from aiobotocore.session import get_session
21
+
22
+ class NetworkComposite(BaseComposite):
23
+ async def compose(self):
24
+ # Only create the AWS Session if needed
25
+ self._aws_session = None
26
+ # Create/Get VPC
27
+ vpc = await self.compose_vpc()
28
+
29
+ async def compose_vpc(self):
30
+ vpc = self.resources.VPC('ec2.aws.m.upbound.io/v1beta1', 'VPC')
31
+ vpc.spec.forProvider(
32
+ region = self.spec.region,
33
+ cidrBlock = self.spec.cidr,
34
+ enableDnsHostnames = True,
35
+ enableDnsSupport = True,
36
+ tags = self.tags(Name=self.metadata.name),
37
+ )
38
+ if not vpc.externalName:
39
+ async with self.aws_client('ec2') as ec2:
40
+ vpcs = (await ec2.describe_vpcs(
41
+ Filters=[{
42
+ 'Name': 'tag:Name',
43
+ 'Values': [str(self.metadata.name)],
44
+ }],
45
+ ))['Vpcs']
46
+ if vpcs:
47
+ if len(vpcs) == 1:
48
+ vpc.externalName = vpcs[0]['VpcId']
49
+ else:
50
+ self.events.fatal('MultipleResources', f"More than one vpc found for: {self.metadata.name}")
51
+ self.status.vpcId = vpc.status.atProvider.id
52
+ return vpc
53
+
54
+ def aws_client(self, service):
55
+ if not self._aws_session:
56
+ self._aws_session = get_session()
57
+ return self._aws_session.create_client(service, str(self.spec.region))
58
+
59
+ def tags(self, *args, **kwargs):
60
+ tags = {}
61
+ for arg in args:
62
+ arg = arg.split('=', 1)
63
+ tags[arg[0].strip()] = arg[1].lstrip()
64
+ tags.update(kwargs)
65
+ if self.spec.tags:
66
+ for key, value in self.spec.tags:
67
+ tags[key] = value
68
+ return tags
@@ -0,0 +1,39 @@
1
+ apiVersion: apiextensions.crossplane.io/v2
2
+ kind: CompositeResourceDefinition
3
+ metadata:
4
+ name: networks.caleb.pythonic.com
5
+ spec:
6
+ group: caleb.pythonic.com
7
+ names:
8
+ kind: Network
9
+ plural: networks
10
+ defaultCompositionRef:
11
+ name: networks.caleb.pythonic.com
12
+ versions:
13
+ - name: v1alpha1
14
+ served: true
15
+ referenceable: true
16
+ schema:
17
+ openAPIV3Schema:
18
+ type: object
19
+ properties:
20
+ spec:
21
+ type: object
22
+ properties:
23
+ region:
24
+ type: string
25
+ cidr:
26
+ type: string
27
+ tags:
28
+ type: object
29
+ additionalProperties:
30
+ type: string
31
+ default: {}
32
+ required:
33
+ - region
34
+ - cidr
35
+ status:
36
+ type: object
37
+ properties:
38
+ vpcId:
39
+ type: string
@@ -0,0 +1,8 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ render.crossplane.io/runtime: Development
7
+ spec:
8
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -0,0 +1,6 @@
1
+ apiVersion: ec2.aws.m.upbound.io/v1beta1
2
+ kind: VPC
3
+ metadata:
4
+ annotations:
5
+ crossplane.io/composition-resource-name: VPC
6
+ crossplane.io/external-name: vpc-0123456789
@@ -0,0 +1,20 @@
1
+ apiVersion: pkg.crossplane.io/v1
2
+ kind: Provider
3
+ metadata:
4
+ name: aws-upbound-provider-ec2
5
+ spec:
6
+ package: xpkg.upbound.io/upbound/provider-aws-ec2:v2.1.0
7
+ runtimeConfigRef:
8
+ name: provider-aws-upbound
9
+ ---
10
+ apiVersion: aws.m.upbound.io/v1beta1
11
+ kind: ClusterProviderConfig
12
+ metadata:
13
+ name: default
14
+ spec:
15
+ credentials:
16
+ secretRef:
17
+ key: credentials
18
+ name: aws-credentials
19
+ namespace: crossplane-system
20
+ source: Secret
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ cd $(dirname $(realpath $0))
3
+ #exec crossplane render xr.yaml composition.yaml functions.yaml
4
+ exec crossplane render --observed-resources=observed.yaml xr.yaml composition.yaml functions.yaml
@@ -0,0 +1,10 @@
1
+ apiVersion: caleb.pythonic.com/v1alpha1
2
+ kind: Network
3
+ metadata:
4
+ namespace: crossplane-system
5
+ name: test-network
6
+ spec:
7
+ region: us-east-1
8
+ cidr: 10.0.0.0/16
9
+ tags:
10
+ 'fortra:cloudops': 'owned'
@@ -5,4 +5,4 @@ metadata:
5
5
  annotations:
6
6
  render.crossplane.io/runtime: Development
7
7
  spec:
8
- package: ghcr.io/fortra/function-pythonic:v0.1.1
8
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -6,4 +6,5 @@ spec:
6
6
  composite: |
7
7
  class Composite(BaseComposite):
8
8
  def compose(self):
9
+ self.logger.info('Debug World!')
9
10
  self.status.composite = 'Hello, World!'
@@ -0,0 +1,9 @@
1
+ apiVersion: pkg.crossplane.io/v1beta1
2
+ kind: Function
3
+ metadata:
4
+ name: function-pythonic
5
+ annotations:
6
+ # This tells crossplane beta render to connect to the function locally.
7
+ render.crossplane.io/runtime: Development
8
+ spec:
9
+ package: ghcr.io/fortra/function-pythonic:v0.1.3
@@ -1,9 +0,0 @@
1
- apiVersion: pkg.crossplane.io/v1beta1
2
- kind: Function
3
- metadata:
4
- name: function-pythonic
5
- annotations:
6
- # This tells crossplane beta render to connect to the function locally.
7
- render.crossplane.io/runtime: Development
8
- spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
@@ -1,9 +0,0 @@
1
- apiVersion: pkg.crossplane.io/v1beta1
2
- kind: Function
3
- metadata:
4
- name: function-pythonic
5
- annotations:
6
- # This tells crossplane beta render to connect to the function locally.
7
- render.crossplane.io/runtime: Development
8
- spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
@@ -1,9 +0,0 @@
1
- apiVersion: pkg.crossplane.io/v1beta1
2
- kind: Function
3
- metadata:
4
- name: function-pythonic
5
- annotations:
6
- # This tells crossplane beta render to connect to the function locally.
7
- render.crossplane.io/runtime: Development
8
- spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
@@ -1,9 +0,0 @@
1
- apiVersion: pkg.crossplane.io/v1beta1
2
- kind: Function
3
- metadata:
4
- name: function-pythonic
5
- annotations:
6
- # This tells crossplane beta render to connect to the function locally.
7
- render.crossplane.io/runtime: Development
8
- spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1
@@ -1,9 +0,0 @@
1
- apiVersion: pkg.crossplane.io/v1beta1
2
- kind: Function
3
- metadata:
4
- name: function-pythonic
5
- annotations:
6
- # This tells crossplane beta render to connect to the function locally.
7
- render.crossplane.io/runtime: Development
8
- spec:
9
- package: xpkg.upbound.io/crossplane-contrib/function-pythonicv0.1.0
@@ -1,9 +0,0 @@
1
- apiVersion: pkg.crossplane.io/v1beta1
2
- kind: Function
3
- metadata:
4
- name: function-pythonic
5
- annotations:
6
- # This tells crossplane beta render to connect to the function locally.
7
- render.crossplane.io/runtime: Development
8
- spec:
9
- package: ghcr.io/fortra/function-pythonic:v0.1.1