Skip to content

Commit f2941f8

Browse files
artychjsonnet-libs-bot
authored andcommitted
update: source github.com/jsonnet-libs/k8s@8bbdf311
1 parent 6c02867 commit f2941f8

155 files changed

Lines changed: 75884 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
local d = import 'doc-util/main.libsonnet';
2+
3+
{
4+
apiextensions+: {
5+
v1+: {
6+
xrd: self.compositeResourceDefinition,
7+
compositeResourceDefinition+: {
8+
9+
'#new':: d.fn(help=|||
10+
new returns an instance of CompositeResourceDefinition=
11+
12+
For example: xpostgresqlinstances.example.org
13+
14+
- `kind`: XPostgreSQLInstance
15+
- `plural`: xpostgresqlinstances
16+
- `group`: example.org
17+
18+
A common convention is that the XR (composite resource) are prefixed with 'X'
19+
while claim names are not. This lets app team members think of creating a claim
20+
as (e.g.) 'creating a PostgreSQLInstance'. Use `withClaimNames` to set this.
21+
|||, args=[
22+
d.arg('kind', d.T.string),
23+
d.arg('plural', d.T.string),
24+
d.arg('group', d.T.string),
25+
]),
26+
new(kind, plural, group):
27+
super.new(plural + '.' + group)
28+
+ super.metadata.withAnnotations({
29+
// Tell Tanka to not set metadata.namespace.
30+
'tanka.dev/namespaced': 'false',
31+
})
32+
+ super.spec.withGroup(group)
33+
+ super.spec.names.withKind(kind)
34+
+ super.spec.names.withPlural(plural)
35+
,
36+
37+
'#withClaimNames':: d.fn(help=|||
38+
Sets the ClaimNames attribute.
39+
40+
Example:
41+
- `kind`: PostgreSQLInstance
42+
- `plural`: postgresqlinstances
43+
44+
A common convention is that the XR (composite resource) are prefixed with 'X'
45+
while claim names are not. This lets app team members think of creating a claim
46+
as (e.g.) 'creating a PostgreSQLInstance'.
47+
|||, args=[
48+
d.arg('kind', d.T.string),
49+
d.arg('plural', d.T.string),
50+
]),
51+
withClaimNames(kind, plural):
52+
super.spec.claimNames.withKind(kind)
53+
+ super.spec.claimNames.withPlural(plural),
54+
55+
'#mapVersions':: d.fn(help=|||
56+
Sets the ClaimNames attribute.
57+
58+
Example:
59+
- `kind`: PostgreSQLInstance
60+
- `plural`: postgresqlinstances
61+
62+
A common convention is that the XR (composite resource) are prefixed with 'X'
63+
while claim names are not. This lets app team members think of creating a claim
64+
as (e.g.) 'creating a PostgreSQLInstance'.
65+
|||, args=[
66+
d.arg('kind', d.T.string),
67+
d.arg('plural', d.T.string),
68+
]),
69+
mapVersions(f): {
70+
local versions = super.spec.versions,
71+
spec+: {
72+
versions: std.map(f, versions),
73+
},
74+
},
75+
},
76+
},
77+
},
78+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
local d = import 'doc-util/main.libsonnet';
2+
3+
{
4+
apiextensions+: {
5+
v1+: {
6+
composition+: {
7+
'#fromXRD':: d.fn(help=|||
8+
Create a Composition based on an XRD.
9+
10+
Attributes:
11+
- `name` of the composition
12+
- `namespace` where connectionDetails are propagated too, commonly the the
13+
management namespace (ie. crossplane)
14+
- `provider` of the resources in this composition
15+
- `xrdRef` XRD object with which this composition is compatible
16+
- `xrdVersion` Version of XRD object with which this composition is compatible
17+
|||, args=[
18+
d.arg('name', d.T.string),
19+
d.arg('namespace', d.T.string),
20+
d.arg('provider', d.T.string),
21+
d.arg('xrdRef', d.T.object),
22+
d.arg('xrdVersion', d.T.string),
23+
]),
24+
fromXRD(name, namespace, provider, xrdRef, xrdVersion):
25+
super.new(name)
26+
+ super.metadata.withAnnotations({
27+
// Tell Tanka to not set metadata.namespace.
28+
'tanka.dev/namespaced': 'false',
29+
})
30+
+ super.metadata.withLabels({
31+
// An optional convention is to include a label of the XRD. This allows easy
32+
// discovery of compatible Compositions.
33+
'crossplane.io/xrd': xrdRef.metadata.name,
34+
// Another optional convention is to include a label of the (most common)
35+
// provider for the resource(s) in this composition. This label can be used in
36+
// 'compositionSelector' in an XR or Claim.
37+
provider: provider,
38+
})
39+
40+
// Each Composition must declare that it is compatible with a particular type of
41+
// Composite Resource using its 'compositeTypeRef' field. The referenced
42+
// version must be marked 'referenceable' in the XRD that defines the XR.
43+
+ super.spec.compositeTypeRef.withApiVersion(xrdRef.spec.group + '/' + xrdVersion)
44+
+ super.spec.compositeTypeRef.withKind(xrdRef.spec.names.kind)
45+
46+
47+
// When an XR is created in response to a claim Crossplane needs to know where it
48+
// should create the XR's connection secret. This is configured using the
49+
// 'writeConnectionSecretsToNamespace' field.
50+
+ super.spec.withWriteConnectionSecretsToNamespace(namespace),
51+
},
52+
},
53+
},
54+
}

0 commit comments

Comments
 (0)