crossplane-function-pythonic 0.0.6__py3-none-any.whl

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.
@@ -0,0 +1,540 @@
1
+ Metadata-Version: 2.4
2
+ Name: crossplane-function-pythonic
3
+ Version: 0.0.6
4
+ Summary: A Python centric Crossplane Function
5
+ Project-URL: Documentation, https://github.com/fortra/function-pythonic#readme
6
+ Project-URL: Issues, https://github.com/fortra/function-pythonic/issues
7
+ Project-URL: Source, https://github.com/fortra/function-pythonic
8
+ Author-email: Patrick J McNerthney <pat@mcnerthney.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: <3.14,>=3.11
17
+ Requires-Dist: crossplane-function-sdk-python==0.9.0
18
+ Requires-Dist: kopf==1.38.0
19
+ Requires-Dist: pyyaml==6.0.2
20
+ Description-Content-Type: text/markdown
21
+
22
+ # function-pythonic
23
+
24
+ ## Introduction
25
+
26
+ A Crossplane composition function that lets you compose Composites using a set
27
+ of python classes enabling an elegant and terse syntax. Here is what the following
28
+ example is doing:
29
+
30
+ * Create an MR named 'vpc' with apiVersion 'ec2.aws.crossplane.io/v1beta1' and kind 'VPC'
31
+ * Set the vpc region and cidr from the XR spec values
32
+ * Set the XR status.vpcId to the created vpc id
33
+
34
+ ```yaml
35
+ apiVersion: apiextensions.crossplane.io/v1
36
+ kind: Composition
37
+ metadata:
38
+ name: create-vpc
39
+ spec:
40
+ compositeTypeRef:
41
+ apiVersion: example.crossplane.io/v1
42
+ kind: XR
43
+ mode: Pipeline
44
+ pipeline:
45
+ - step:
46
+ functionRef:
47
+ name: function-pythonic
48
+ input:
49
+ apiVersion: pythonic.fn.crossplane.io/v1beta1
50
+ kind: Composite
51
+ composite: |
52
+ class Composite(BaseComposite):
53
+ def compose(self):
54
+ vpc = self.resources.vpc('ec2.aws.crossplane.io/v1beta1', 'VPC')
55
+ vpc.spec.forProvider.region = self.spec.region
56
+ vpc.spec.forProvider.cidrBlock = self.spec.cidr
57
+ self.status.vpcId = vpc.status.atProvider.vpcId
58
+ ```
59
+
60
+ In addtion to an inline script, the python implementation can be specified
61
+ as the complete path to a python class. Python packages can be deployed using
62
+ ConfigMaps, enabling using your IDE of choice for writting the code. See
63
+ [ConfigMap Packages](#configmap-packages) and
64
+ [Filing System Packages](#filing-system-packages).
65
+
66
+ ## Examples
67
+
68
+ In the [examples](./examples) directory are many exemples, including all of the
69
+ function-go-templating examples implemented using function-pythonic.
70
+ The [eks-cluster](./examples/eks-cluster/composition.yaml) example is a good
71
+ complex example creating the entire vpc structure needed for an EKS cluster.
72
+
73
+ ## Installing function-pythonic
74
+
75
+ ```yaml
76
+ apiVersion: pkg.crossplane.io/v1
77
+ kind: Function
78
+ metadata:
79
+ name: function-pythonic
80
+ spec:
81
+ package: ghcr.io/fortra/function-pythonic:v0.0.7
82
+ ```
83
+
84
+ ## Composed Resource Dependencies
85
+
86
+ function-pythonic automatically handles dependencies between composed resources.
87
+
88
+ Just compose everything as if it is immediately created and the framework will delay
89
+ the creation of any resources which depend on other resources which do not exist yet.
90
+ In other words, it accomplishes what [function-sequencer](https://github.com/crossplane-contrib/function-sequencer)
91
+ provides, but it automatically detects the dependencies.
92
+
93
+ If a resource has been created and a dependency no longer exists due to some unexpected
94
+ condition, the composition will be terminated or the observed value for that field will
95
+ be used, depending on the `unknownsFatal` settings.
96
+
97
+ Take the following example:
98
+ ```yaml
99
+ vpc = self.resources.VPC('ec2.aws.crossplane.io/v1beta1', 'VPC')
100
+ vpc.spec.forProvider.region = 'us-east-1
101
+ vpc.spec.forProvider.cidrBlock = '10.0.0.0/16'
102
+
103
+ subnet = self.resources.SubnetA('ec2.aws.crossplane.io/v1beta1', 'Subnet')
104
+ subnet.spec.forProvider.region = 'us-east-1'
105
+ subnet.spec.forProvider.vpcId = vpc.status.atProvider.vpcId
106
+ subnet.spec.forProvider.availabilityZone = 'us-east-1a'
107
+ subnet.spec.forProvider.cidrBlock = '10.0.0.0/20'
108
+ ```
109
+ If the Subnet does not yet exist, the framework will detect if the vpcId set
110
+ in the Subnet is unknown, and will delay the creation of the subnet.
111
+
112
+ Once the Subnet has been created, if for some unexpected reason the vpcId passed
113
+ to the Subnet is unknown, the framework will detect it and either terminate
114
+ the Composite composition or use the vpcId in the observed Subnet. The default
115
+ action taken is to fast fail by terminating the composition. This can be
116
+ overridden for all composed resource by setting the Composite `self.unknownsFatal` field
117
+ to False, or at the individual composed resource level by setting the
118
+ `Resource.unknownsFatal` field to False.
119
+
120
+ ## Pythonic access of Protobuf Messages
121
+
122
+ All Protobuf messages are wrapped by a set of python classes which enable using
123
+ both object attribute names and dictionary key names to traverse the Protobuf
124
+ message contents. For example, the following examples obtain the same value
125
+ from the RunFunctionRequest message:
126
+ ```python
127
+ region = request.observed.composite.resource.spec.region
128
+ region = request['observed']['composite']['resource']['spec']['region']
129
+ ```
130
+ Getting values from free form map and list values will not throw
131
+ errors for keys that do not exist, but will return an unknown placeholder
132
+ which evaluates as False. For example, the following will evaluate as False
133
+ with a just created RunFunctionResponse message:
134
+ ```python
135
+ vpcId = response.desired.resources.vpc.resource.status.atProvider.vpcId
136
+ if vpcId:
137
+ # The vpcId is available
138
+ ```
139
+ Note that maps or lists that do exist but do not have any members will evaluate
140
+ as True, contrary to Python dicts and lists. Use the `len` function to test
141
+ if the map or list exists and has members.
142
+
143
+ When setting fields, all intermediary unknown placeholders will automatically
144
+ be created. For example, this will create all items needed to set the
145
+ region on the desired resource:
146
+ ```python
147
+ response.desired.resources.vpc.resource.spec.forProvider.region = 'us-east-1'
148
+ ```
149
+ Calling a message or map will clear it and will set any provided key word
150
+ arguments. For example, this will either create or clear the resource
151
+ and then set its apiVersion and kind:
152
+ ```python
153
+ response.desired.resources.vpc.resource(apiVersion='ec2.aws.crossplane.io/v1beta1', kind='VPC')
154
+ ```
155
+ The following functions are provided to create Protobuf structures:
156
+ | Function | Description |
157
+ | ----- | ----------- |
158
+ | Map | Create a new Protobuf map |
159
+ | List | Create a new Protobuf list |
160
+ | Unknown | Create a new Protobuf unknown placeholder |
161
+ | Yaml | Create a new Protobuf structure from a yaml string |
162
+ | Json | Create a new Protobuf structure from a json string |
163
+ | B64Encode | Encode a string into base 64 |
164
+ | B64Decode | Decode a string from base 64 |
165
+
166
+ The following items are supported in all the Protobuf Message wrapper classes: `bool`,
167
+ `len`, `contains`, `iter`, `hash`, `==`, `str`, `format`
168
+
169
+ To convert a Protobuf message to a string value, use either `str` or `format`.
170
+ ```python
171
+ yaml = str(request) # get the request as yaml
172
+ yaml = format(request) # also get the request as yaml
173
+ yaml = format(request, 'yaml') # yet another get the request as yaml
174
+ json = format(request, 'json') # get the request as json
175
+ json = format(request, 'jsonc') # get the request as json compact
176
+ proto = format(request, 'protobuf') # get the request as a protobuf string
177
+ ```
178
+ ## Composite Composition
179
+
180
+ Composite composition is performed from a Composite orientation. A `BaseComposite` class
181
+ is subclassed and the `compose` method is implemented.
182
+ ```python
183
+ class Composite(BaseComposite):
184
+ def compose(self):
185
+ # Compose the Composite
186
+ ```
187
+ The compose method can also declare itself as performing async io:
188
+ ```python
189
+ class Composite(BaseComposite):
190
+ async def compose(self):
191
+ # Compose the Composite using async io when needed
192
+ ```
193
+
194
+ ### BaseComposite
195
+
196
+ The BaseComposite class provides the following fields for manipulating the Composite itself:
197
+
198
+ | Field | Type | Description |
199
+ | ----- | ---- | ----------- |
200
+ | self.observed | Map | Low level direct access to the observed composite |
201
+ | self.desired | Map | Low level direct access to the desired composite |
202
+ | self.apiVersion | String | The composite observed apiVersion |
203
+ | self.kind | String | The composite observed kind |
204
+ | self.metadata | Map | The composite observed metadata |
205
+ | self.spec | Map | The composite observed spec |
206
+ | self.status | Map | The composite desired and observed status, read from observed if not in desired |
207
+ | self.conditions | Conditions | The composite desired and observed conditions, read from observed if not in desired |
208
+ | self.connection | Connection | The composite desired and observed connection detials, read from observed if not in desired |
209
+ | self.events | Events | Returned events against the Composite and optionally on the Claim |
210
+ | self.ready | Boolean | The composite desired ready state |
211
+
212
+ The BaseComposite also provides access to the following Crossplane Function level features:
213
+
214
+ | Field | Type | Description |
215
+ | ----- | ---- | ----------- |
216
+ | self.request | Message | Low level direct access to the RunFunctionRequest message |
217
+ | self.response | Message | Low level direct access to the RunFunctionResponse message |
218
+ | self.logger | Logger | Python logger to log messages to the running function stdout |
219
+ | self.ttl | Integer | Get or set the response TTL, in seconds |
220
+ | self.credentials | Credentials | The request credentials |
221
+ | self.context | Map | The response context, initialized from the request context |
222
+ | self.environment | Map | The response environment, initialized from the request context environment |
223
+ | self.requireds | Requireds | Request and read additional local Kubernetes resources |
224
+ | self.resources | Resources | Define and process composed resources |
225
+ | self.unknownsFatal | Boolean | Terminate the composition if already created resources are assigned unknown values, default True |
226
+ | self.autoReady | Boolean | Perform auto ready processing on all composed resources, default True |
227
+
228
+ ### Composed Resources
229
+
230
+ Creating and accessing composed resources is performed using the `BaseComposite.resources` field.
231
+ `BaseComposite.resources` is a dictionary of the composed resources whose key is the composition
232
+ resource name. The value returned when getting a resource from BaseComposite is the following
233
+ Resource class:
234
+
235
+ | Field | Type | Description |
236
+ | ----- | ---- | ----------- |
237
+ | Resource(apiVersion,kind,namespace,name) | Resource | Reset the resource and set the optional parameters |
238
+ | Resource.name | String | The composition composed resource name |
239
+ | Resource.observed | Map | Low level direct access to the observed composed resource |
240
+ | Resource.desired | Map | Low level direct access to the desired composed resource |
241
+ | Resource.apiVersion | String | The composed resource apiVersion |
242
+ | Resource.kind | String | The composed resource kind |
243
+ | Resource.externalName | String | The composed resource external name |
244
+ | Resource.metadata | Map | The composed resource desired metadata |
245
+ | Resource.spec | Map | The resource spec |
246
+ | Resource.data | Map | The resource data |
247
+ | Resource.status | Map | The resource status |
248
+ | Resource.conditions | Conditions | The resource conditions |
249
+ | Resource.connection | Connection | The resource connection details |
250
+ | Resource.ready | Boolean | The resource ready state |
251
+ | Resource.unknownsFatal | Boolean | Terminate the composition if this resource has been created and is assigned unknown values, default is Composite.unknownsFatal |
252
+ | Resource.autoReady | Boolean | Perform auto ready processing on this resource, default is Composite.autoReady |
253
+
254
+ ### Required Resources (AKA Extra Resources)
255
+
256
+ Creating and accessing required resources is performed using the `BaseComposite.requireds` field.
257
+ `BaseComposite.requireds` is a dictionary of the required resources whose key is the required
258
+ resource name. The value returned when getting a required resource from BaseComposite is the
259
+ following RequiredResources class:
260
+
261
+ | Field | Type | Description |
262
+ | ----- | ---- | ----------- |
263
+ | RequiredResource(apiVersion,kind,namespace,name,labels) | RequiredResource | Reset the required resource and set the optional parameters |
264
+ | RequiredResources.name | String | The required resources name |
265
+ | RequiredResources.apiVersion | String | The required resources apiVersion |
266
+ | RequiredResources.kind | String | The required resources kind |
267
+ | RequiredResources.namespace | String | The namespace to match when returning the required resources, see note below |
268
+ | RequiredResources.matchName | String | The names to match when returning the required resources |
269
+ | RequiredResources.matchLabels | Map | The labels to match when returning the required resources |
270
+
271
+ The current version of crossplane-sdk-python used by function-pythonic does not support namespace
272
+ selection. For now, use matchLabels and filter the results if required.
273
+
274
+ RequiredResources acts like a Python list to provide access to the found required resources.
275
+ Each resource in the list is the following RequiredResource class:
276
+
277
+ | Field | Description |
278
+ | ----- | ----------- |
279
+ | RequiredResource.name | The required resource name |
280
+ | RequiredResource.observed | Low level direct access to the observed required resource |
281
+ | RequiredResource.apiVersion | The required resource apiVersion |
282
+ | RequiredResource.kind | The required resource kind |
283
+ | RequiredResource.metadata | The required resource metadata |
284
+ | RequiredResource.spec | The required resource spec |
285
+ | RequiredResource.data | The required resource data |
286
+ | RequiredResource.status | The required resource status |
287
+ | RequiredResource.conditions | The required resource conditions |
288
+
289
+ ### Conditions
290
+
291
+ The `conditions` field is a map of the resource's status conditions array, with
292
+ the map key being the condition type.
293
+
294
+ | Field | Description |
295
+ | ----- | ----------- |
296
+ | Condition.type | The condtion type |
297
+ | Condition.status | RequiredResource.observed | Low level direct access to the observed required resource |
298
+ | RequiredResource.apiVersion | The required resource apiVersion |
299
+ | RequiredResource.kind | The required resource kind |
300
+ | RequiredResource.metadata | The required resource metadata |
301
+ | RequiredResource.spec | The required resource spec |
302
+ | RequiredResource.data | The required resource data |
303
+ | RequiredResource.status | The required resource status |
304
+ | RequiredResource.conditions | The required resource conditions |
305
+
306
+ ## Single use Composites
307
+
308
+ Tired of creating a CompositeResourceDefinition, a Composition, and a Composite
309
+ just to run that Composition once in a single use or initialize task?
310
+
311
+ function-pythonic installs a `Composite` CompositeResourceDefinition that enables
312
+ creating such tasks using a single Composite resource:
313
+ ```yaml
314
+ apiVersion: pythonic.fortra.com/v1alpha1
315
+ kind: Composite
316
+ metadata:
317
+ name: composite-example
318
+ spec:
319
+ composite: |
320
+ class Composite(BaseComposite):
321
+ def compose(self):
322
+ self.status.composite = 'Hello, World!'
323
+ ```
324
+
325
+ ## ConfigMap Packages
326
+
327
+ ConfigMap based python packages are enable using the `--packages` and
328
+ `--packages-namespace` command line options. ConfigMaps with the label
329
+ `function-pythonic.package` will be incorporated in the python path at
330
+ the location configured in the label value. For example, the following
331
+ ConfigMap will enable python to use `import example.pythonic.features`
332
+ ```yaml
333
+ apiVersion: v1
334
+ kind: ConfigMap
335
+ metadata:
336
+ namespace: crossplane-system
337
+ name: example-pythonic
338
+ labels:
339
+ function-pythonic.package: example.pythonic
340
+ data:
341
+ features.py: |
342
+ def anything():
343
+ return 'something'
344
+ ```
345
+ Then, in your Composition:
346
+ ```yaml
347
+ ...
348
+ - step: pythonic
349
+ functionRef:
350
+ name: function-pythonic
351
+ input:
352
+ apiVersion: pythonic.fn.fortra.com/v1alpha1
353
+ kind: Composite
354
+ composite: |
355
+ from example.pythonic import features
356
+ class Composite(BaseComposite):
357
+ def compose(self):
358
+ anything = features.anything()
359
+ ...
360
+ ```
361
+ The entire function-pythonic Composite class can be coded in the ConfigMap and
362
+ only the complete Composite class path is needed in the step configuration.
363
+ ```yaml
364
+ apiVersion: v1
365
+ kind: ConfigMap
366
+ metadata:
367
+ namespace: crossplane-system
368
+ name: example-pythonic
369
+ labels:
370
+ function-pythonic.package: example.pythonic
371
+ data:
372
+ features.py: |
373
+ from crossplane.pythonic import BaseComposite
374
+ class FeatureOneComposite(BaseComposite):
375
+ def compose(self):
376
+ # go at it!
377
+ ```
378
+ ```yaml
379
+ ...
380
+ - step: pythonic
381
+ functionRef:
382
+ name: function-pythonic
383
+ input:
384
+ apiVersion: pythonic.fn.fortra.com/v1alpha1
385
+ kind: Composite
386
+ composite: example.pythonic.features.FeatureOneComposite
387
+ ...
388
+ ```
389
+ This requires enabling the the packages support using the `--packages` command
390
+ line option in the DeploymentRuntimeConfig and configuring the required
391
+ Kubernetes RBAC permissions. For example:
392
+ ```yaml
393
+ apiVersion: pkg.crossplane.io/v1
394
+ kind: Function
395
+ metadata:
396
+ name: function-pythonic
397
+ spec:
398
+ package: ghcr.io/fortra/function-pythonic:v0.0.7
399
+ runtimeConfigRef:
400
+ name: function-pythonic
401
+ ---
402
+ apiVersion: pkg.crossplane.io/v1beta1
403
+ kind: DeploymentRuntimeConfig
404
+ metadata:
405
+ name: function-pythonic
406
+ spec:
407
+ deploymentTemplate:
408
+ spec:
409
+ selector: {}
410
+ template:
411
+ spec:
412
+ containers:
413
+ - name: package-runtime
414
+ args:
415
+ - --debug
416
+ - --packages
417
+ serviceAccountName: function-pythonic
418
+ serviceAccountTemplate:
419
+ metadata:
420
+ name: function-pythonic
421
+ ---
422
+ apiVersion: rbac.authorization.k8s.io/v1
423
+ kind: ClusterRole
424
+ metadata:
425
+ name: function-pythonic
426
+ rules:
427
+ - apiGroups:
428
+ - ''
429
+ resources:
430
+ - events
431
+ verbs:
432
+ - create
433
+ - apiGroups:
434
+ - ''
435
+ resources:
436
+ - configmaps
437
+ verbs:
438
+ - list
439
+ - watch
440
+ - patch
441
+ ---
442
+ apiVersion: rbac.authorization.k8s.io/v1
443
+ kind: ClusterRoleBinding
444
+ metadata:
445
+ name: function-pythonic
446
+ roleRef:
447
+ apiGroup: rbac.authorization.k8s.io
448
+ kind: ClusterRole
449
+ name: function-pythonic
450
+ subjects:
451
+ - kind: ServiceAccount
452
+ namespace: crossplane-system
453
+ name: function-pythonic
454
+ ```
455
+ When enabled, labeled ConfigMaps are obtained cluster wide, requiring the above
456
+ ClusterRole permissions. The `--packages-namespace` command line option will restrict
457
+ to only using the supplied namespace. This option can be invoked multiple times.
458
+ The above RBAC permission can then be per namespace RBAC Role permissions.
459
+
460
+ Secrets can also be used in an identical manner as ConfigMaps by enabling the
461
+ `--packages-secrets` command line option. Secrets permissions need to be
462
+ added to the above RBAC configuration.
463
+
464
+ ## Filing System Packages
465
+
466
+ Composition Composite implementations can be coded in a stand alone python files
467
+ by configuring the function-pythonic deployment with the code mounted into
468
+ the package-runtime container, and then adding the mount point to the python
469
+ path using the --python-path command line option.
470
+ ```yaml
471
+ apiVersion: pkg.crossplane.io/v1beta1
472
+ kind: DeploymentRuntimeConfig
473
+ metadata:
474
+ name: function-pythonic
475
+ spec:
476
+ deploymentTemplate:
477
+ spec:
478
+ template:
479
+ spec:
480
+ containers:
481
+ - name: package-runtime
482
+ args:
483
+ - --debug
484
+ - --python-path
485
+ - /mnt/composites
486
+ volumeMounts:
487
+ - name: composites
488
+ mountPath: /mnt/composites
489
+ volumes:
490
+ - name: composites
491
+ configMap:
492
+ name: pythonic-composites
493
+ ```
494
+ See the [filing-system](examples/filing-system) example.
495
+
496
+ ## Install Additional Python Packages
497
+
498
+ function-pythonic supports a `--pip-install` command line option which will run pip install
499
+ with the configured pip install command. For example:
500
+ ```yaml
501
+ apiVersion: pkg.crossplane.io/v1beta1
502
+ kind: DeploymentRuntimeConfig
503
+ metadata:
504
+ name: function-pythonic
505
+ spec:
506
+ deploymentTemplate:
507
+ spec:
508
+ template:
509
+ spec:
510
+ containers:
511
+ - name: package-runtime
512
+ args:
513
+ - --debug
514
+ - --pip-install
515
+ - --quiet aiobotocore==2.23.2
516
+ ```
517
+
518
+ ## Enable Oversize Protos
519
+
520
+ The Protobuf python package used by function-pythonic limits the depth of yaml
521
+ elements and the total size of yaml parsed. This results in a limit of approximately
522
+ 30 levels of nested yaml fields. This check can be disabled using the `--allow-oversize-protos`
523
+ command line option. For example:
524
+
525
+ ```yaml
526
+ apiVersion: pkg.crossplane.io/v1beta1
527
+ kind: DeploymentRuntimeConfig
528
+ metadata:
529
+ name: function-pythonic
530
+ spec:
531
+ deploymentTemplate:
532
+ spec:
533
+ template:
534
+ spec:
535
+ containers:
536
+ - name: package-runtime
537
+ args:
538
+ - --debug
539
+ - --allow-oversize-protos
540
+ ```
@@ -0,0 +1,5 @@
1
+ crossplane_function_pythonic-0.0.6.dist-info/METADATA,sha256=JjVxNRwXVZNd1w_ejkK9zb4MiVjRlmcQmO6meaO_RzA,20687
2
+ crossplane_function_pythonic-0.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
+ crossplane_function_pythonic-0.0.6.dist-info/entry_points.txt,sha256=jJ4baywFDviB9WyAhyhNYF2VOCb6XtbRSjKf7bnBwhg,68
4
+ crossplane_function_pythonic-0.0.6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
+ crossplane_function_pythonic-0.0.6.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ function-pythonic = crossplane.pythonic.main:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.