Skip to content

Commit

Permalink
update: source github.com/jsonnet-libs/k8s@8bbdf311
Browse files Browse the repository at this point in the history
  • Loading branch information
artych authored and jsonnet-libs-bot committed Nov 6, 2024
1 parent 6c02867 commit f2941f8
Show file tree
Hide file tree
Showing 155 changed files with 75,884 additions and 0 deletions.
78 changes: 78 additions & 0 deletions crossplane/1.16/_custom/compositeResourceDefinition.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
local d = import 'doc-util/main.libsonnet';

{
apiextensions+: {
v1+: {
xrd: self.compositeResourceDefinition,
compositeResourceDefinition+: {

'#new':: d.fn(help=|||
new returns an instance of CompositeResourceDefinition=
For example: xpostgresqlinstances.example.org
- `kind`: XPostgreSQLInstance
- `plural`: xpostgresqlinstances
- `group`: example.org
A common convention is that the XR (composite resource) are prefixed with 'X'
while claim names are not. This lets app team members think of creating a claim
as (e.g.) 'creating a PostgreSQLInstance'. Use `withClaimNames` to set this.
|||, args=[
d.arg('kind', d.T.string),
d.arg('plural', d.T.string),
d.arg('group', d.T.string),
]),
new(kind, plural, group):
super.new(plural + '.' + group)
+ super.metadata.withAnnotations({
// Tell Tanka to not set metadata.namespace.
'tanka.dev/namespaced': 'false',
})
+ super.spec.withGroup(group)
+ super.spec.names.withKind(kind)
+ super.spec.names.withPlural(plural)
,

'#withClaimNames':: d.fn(help=|||
Sets the ClaimNames attribute.
Example:
- `kind`: PostgreSQLInstance
- `plural`: postgresqlinstances
A common convention is that the XR (composite resource) are prefixed with 'X'
while claim names are not. This lets app team members think of creating a claim
as (e.g.) 'creating a PostgreSQLInstance'.
|||, args=[
d.arg('kind', d.T.string),
d.arg('plural', d.T.string),
]),
withClaimNames(kind, plural):
super.spec.claimNames.withKind(kind)
+ super.spec.claimNames.withPlural(plural),

'#mapVersions':: d.fn(help=|||
Sets the ClaimNames attribute.
Example:
- `kind`: PostgreSQLInstance
- `plural`: postgresqlinstances
A common convention is that the XR (composite resource) are prefixed with 'X'
while claim names are not. This lets app team members think of creating a claim
as (e.g.) 'creating a PostgreSQLInstance'.
|||, args=[
d.arg('kind', d.T.string),
d.arg('plural', d.T.string),
]),
mapVersions(f): {
local versions = super.spec.versions,
spec+: {
versions: std.map(f, versions),
},
},
},
},
},
}
54 changes: 54 additions & 0 deletions crossplane/1.16/_custom/composition.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
local d = import 'doc-util/main.libsonnet';

{
apiextensions+: {
v1+: {
composition+: {
'#fromXRD':: d.fn(help=|||
Create a Composition based on an XRD.
Attributes:
- `name` of the composition
- `namespace` where connectionDetails are propagated too, commonly the the
management namespace (ie. crossplane)
- `provider` of the resources in this composition
- `xrdRef` XRD object with which this composition is compatible
- `xrdVersion` Version of XRD object with which this composition is compatible
|||, args=[
d.arg('name', d.T.string),
d.arg('namespace', d.T.string),
d.arg('provider', d.T.string),
d.arg('xrdRef', d.T.object),
d.arg('xrdVersion', d.T.string),
]),
fromXRD(name, namespace, provider, xrdRef, xrdVersion):
super.new(name)
+ super.metadata.withAnnotations({
// Tell Tanka to not set metadata.namespace.
'tanka.dev/namespaced': 'false',
})
+ super.metadata.withLabels({
// An optional convention is to include a label of the XRD. This allows easy
// discovery of compatible Compositions.
'crossplane.io/xrd': xrdRef.metadata.name,
// Another optional convention is to include a label of the (most common)
// provider for the resource(s) in this composition. This label can be used in
// 'compositionSelector' in an XR or Claim.
provider: provider,
})

// Each Composition must declare that it is compatible with a particular type of
// Composite Resource using its 'compositeTypeRef' field. The referenced
// version must be marked 'referenceable' in the XRD that defines the XR.
+ super.spec.compositeTypeRef.withApiVersion(xrdRef.spec.group + '/' + xrdVersion)
+ super.spec.compositeTypeRef.withKind(xrdRef.spec.names.kind)


// When an XR is created in response to a claim Crossplane needs to know where it
// should create the XR's connection secret. This is configured using the
// 'writeConnectionSecretsToNamespace' field.
+ super.spec.withWriteConnectionSecretsToNamespace(namespace),
},
},
},
}
Loading

0 comments on commit f2941f8

Please sign in to comment.