Skip to content

Instantly share code, notes, and snippets.

@lawrencejones
Created June 1, 2020 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawrencejones/a504f88e764e992bc3ffecc7f6f165a4 to your computer and use it in GitHub Desktop.
Save lawrencejones/a504f88e764e992bc3ffecc7f6f165a4 to your computer and use it in GitHub Desktop.
Theatre auto-generated CRDs
{
local hidden = (import '_hidden.libsonnet'),
rbac:: {
v1alpha1:: {
local apiVersion = { apiVersion: 'rbac/v1alpha1' },
// Computer generated, description unknown
directoryRoleBinding:: {
new():: {},
withMetadata(metadata):: self + { metadata: metadata },
withMetadataMixin(metadata):: self + { metadata+: metadata },
mixin:: {
// Computer generated, description unknown
spec:: {
local __specMixin(spec) = { spec+: spec },
mixinInstance(spec):: __specMixin(spec),
withRoleRef(roleRef):: self + __specMixin({ roleRef: roleRef }),
withRoleRefMixin(roleRef):: self + __specMixin({ roleRef+: roleRef }),
withSubjects(subjects):: self + if std.type(subjects) == 'array' then __specMixin({ subjects: subjects }) else __specMixin({ subjects: [subjects] }),
withSubjectsMixin(subjects):: self + if std.type(subjects) == 'array' then __specMixin({ subjects+: subjects }) else __specMixin({ subjects+: [subjects] }),
},
specType:: hidden.rbac.v1alpha1.directoryRoleBindingSpec,
},
},
// Computer generated, description unknown
directoryRoleBindingSpec:: {
new():: {},
withRoleRef(roleRef):: self + { roleRef: roleRef },
withRoleRefMixin(roleRef):: self + { roleRef+: roleRef },
withSubjects(subjects):: self + if std.type(subjects) == 'array' then { subjects: subjects } else { subjects: [subjects] },
withSubjectsMixin(subjects):: self + if std.type(subjects) == 'array' then { subjects+: subjects } else { subjects+: [subjects] },
mixin:: {},
},
},
},
workloads:: {
v1alpha1:: {
local apiVersion = { apiVersion: 'workloads/v1alpha1' },
// Computer generated, description unknown
console:: {
new():: {},
withMetadata(metadata):: self + { metadata: metadata },
withMetadataMixin(metadata):: self + { metadata+: metadata },
mixin:: {
// Computer generated, description unknown
spec:: {
local __specMixin(spec) = { spec+: spec },
mixinInstance(spec):: __specMixin(spec),
// The command and arguments to execute. If not specified the command from the template specification will be used.
withCommand(command):: self + if std.type(command) == 'array' then __specMixin({ command: command }) else __specMixin({ command: [command] }),
// The command and arguments to execute. If not specified the command from the template specification will be used.
withCommandMixin(command):: self + if std.type(command) == 'array' then __specMixin({ command+: command }) else __specMixin({ command+: [command] }),
withConsoleTemplateRef(consoleTemplateRef):: self + __specMixin({ consoleTemplateRef: consoleTemplateRef }),
withConsoleTemplateRefMixin(consoleTemplateRef):: self + __specMixin({ consoleTemplateRef+: consoleTemplateRef }),
withReason(reason):: self + __specMixin({ reason: reason }),
// Number of seconds that the console should run for. If the process running within the console has not exited before this timeout is reached, then the console will be terminated. If this value exceeds the Maximum Timeout Seconds specified in the ConsoleTemplate that this console refers to, then this timeout will be clamped to that value. Maximum value of 1 week (as per ConsoleTemplate.Spec.MaxTimeoutSeconds).
withTimeoutSeconds(timeoutSeconds):: self + __specMixin({ timeoutSeconds: timeoutSeconds }),
// Specifies the TTL for this Console. The Console will be eligible for garbage collection TTLSecondsAfterFinished seconds after it enters the Stopped or Destroyed phase. This field is modeled on the TTL mechanism in Kubernetes 1.12.
withTtlSecondsAfterFinished(ttlSecondsAfterFinished):: self + __specMixin({ ttlSecondsAfterFinished: ttlSecondsAfterFinished }),
// Specifies the TTL before running for this Console. The Console will be eligible for garbage collection TTLSecondsBeforeRunning seconds if it has not progressed to the Running phase. This field is modeled on the TTL mechanism in Kubernetes 1.12.
withTtlSecondsBeforeRunning(ttlSecondsBeforeRunning):: self + __specMixin({ ttlSecondsBeforeRunning: ttlSecondsBeforeRunning }),
withUser(user):: self + __specMixin({ user: user }),
},
specType:: hidden.workloads.v1alpha1.consoleSpec,
},
},
// Computer generated, description unknown
consoleAuthorisation:: {
new():: {},
withMetadata(metadata):: self + { metadata: metadata },
withMetadataMixin(metadata):: self + { metadata+: metadata },
mixin:: {
// Computer generated, description unknown
spec:: {
local __specMixin(spec) = { spec+: spec },
mixinInstance(spec):: __specMixin(spec),
// List of authorisations that have been given to the referenced console.
withAuthorisations(authorisations):: self + if std.type(authorisations) == 'array' then __specMixin({ authorisations: authorisations }) else __specMixin({ authorisations: [authorisations] }),
// List of authorisations that have been given to the referenced console.
withAuthorisationsMixin(authorisations):: self + if std.type(authorisations) == 'array' then __specMixin({ authorisations+: authorisations }) else __specMixin({ authorisations+: [authorisations] }),
// The reference to the console by name that this console authorisation belongs to.
withConsoleRef(consoleRef):: self + __specMixin({ consoleRef: consoleRef }),
// The reference to the console by name that this console authorisation belongs to.
withConsoleRefMixin(consoleRef):: self + __specMixin({ consoleRef+: consoleRef }),
},
specType:: hidden.workloads.v1alpha1.consoleAuthorisationSpec,
},
},
// Computer generated, description unknown
consoleAuthorisationSpec:: {
new():: {},
// List of authorisations that have been given to the referenced console.
withAuthorisations(authorisations):: self + if std.type(authorisations) == 'array' then { authorisations: authorisations } else { authorisations: [authorisations] },
// List of authorisations that have been given to the referenced console.
withAuthorisationsMixin(authorisations):: self + if std.type(authorisations) == 'array' then { authorisations+: authorisations } else { authorisations+: [authorisations] },
// The reference to the console by name that this console authorisation belongs to.
withConsoleRef(consoleRef):: self + { consoleRef: consoleRef },
// The reference to the console by name that this console authorisation belongs to.
withConsoleRefMixin(consoleRef):: self + { consoleRef+: consoleRef },
mixin:: {},
},
// Computer generated, description unknown
consoleSpec:: {
new():: {},
// The command and arguments to execute. If not specified the command from the template specification will be used.
withCommand(command):: self + if std.type(command) == 'array' then { command: command } else { command: [command] },
// The command and arguments to execute. If not specified the command from the template specification will be used.
withCommandMixin(command):: self + if std.type(command) == 'array' then { command+: command } else { command+: [command] },
withConsoleTemplateRef(consoleTemplateRef):: self + { consoleTemplateRef: consoleTemplateRef },
withConsoleTemplateRefMixin(consoleTemplateRef):: self + { consoleTemplateRef+: consoleTemplateRef },
withReason(reason):: self + { reason: reason },
// Number of seconds that the console should run for. If the process running within the console has not exited before this timeout is reached, then the console will be terminated. If this value exceeds the Maximum Timeout Seconds specified in the ConsoleTemplate that this console refers to, then this timeout will be clamped to that value. Maximum value of 1 week (as per ConsoleTemplate.Spec.MaxTimeoutSeconds).
withTimeoutSeconds(timeoutSeconds):: self + { timeoutSeconds: timeoutSeconds },
// Specifies the TTL for this Console. The Console will be eligible for garbage collection TTLSecondsAfterFinished seconds after it enters the Stopped or Destroyed phase. This field is modeled on the TTL mechanism in Kubernetes 1.12.
withTtlSecondsAfterFinished(ttlSecondsAfterFinished):: self + { ttlSecondsAfterFinished: ttlSecondsAfterFinished },
// Specifies the TTL before running for this Console. The Console will be eligible for garbage collection TTLSecondsBeforeRunning seconds if it has not progressed to the Running phase. This field is modeled on the TTL mechanism in Kubernetes 1.12.
withTtlSecondsBeforeRunning(ttlSecondsBeforeRunning):: self + { ttlSecondsBeforeRunning: ttlSecondsBeforeRunning },
withUser(user):: self + { user: user },
mixin:: {},
},
// Computer generated, description unknown
consoleStatus:: {
new():: {},
// Time at which the job completed successfully
withCompletionTime(completionTime):: self + { completionTime: completionTime },
withExpiryTime(expiryTime):: self + { expiryTime: expiryTime },
withPhase(phase):: self + { phase: phase },
withPodName(podName):: self + { podName: podName },
mixin:: {},
},
// Computer generated, description unknown
consoleTemplate:: {
new():: {},
withMetadata(metadata):: self + { metadata: metadata },
withMetadataMixin(metadata):: self + { metadata+: metadata },
mixin:: {
// Computer generated, description unknown
spec:: {
local __specMixin(spec) = { spec+: spec },
mixinInstance(spec):: __specMixin(spec),
withAdditionalAttachSubjects(additionalAttachSubjects):: self + if std.type(additionalAttachSubjects) == 'array' then __specMixin({ additionalAttachSubjects: additionalAttachSubjects }) else __specMixin({ additionalAttachSubjects: [additionalAttachSubjects] }),
withAdditionalAttachSubjectsMixin(additionalAttachSubjects):: self + if std.type(additionalAttachSubjects) == 'array' then __specMixin({ additionalAttachSubjects+: additionalAttachSubjects }) else __specMixin({ additionalAttachSubjects+: [additionalAttachSubjects] }),
// List of authorisation rules to match against in order from top to bottom.
withAuthorisationRules(authorisationRules):: self + if std.type(authorisationRules) == 'array' then __specMixin({ authorisationRules: authorisationRules }) else __specMixin({ authorisationRules: [authorisationRules] }),
// List of authorisation rules to match against in order from top to bottom.
withAuthorisationRulesMixin(authorisationRules):: self + if std.type(authorisationRules) == 'array' then __specMixin({ authorisationRules+: authorisationRules }) else __specMixin({ authorisationRules+: [authorisationRules] }),
// Computer generated, description unknown
defaultAuthorisationRule:: {
local __defaultAuthorisationRuleMixin(defaultAuthorisationRule) = __specMixin({ defaultAuthorisationRule+: defaultAuthorisationRule }),
mixinInstance(defaultAuthorisationRule):: __defaultAuthorisationRuleMixin(defaultAuthorisationRule),
// The number of authorisations required from members of the subjects before the console can run.
withAuthorisationsRequired(authorisationsRequired):: self + __defaultAuthorisationRuleMixin({ authorisationsRequired: authorisationsRequired }),
// List of subjects that can provide authorisation for the console command to run.
withSubjects(subjects):: self + if std.type(subjects) == 'array' then __defaultAuthorisationRuleMixin({ subjects: subjects }) else __defaultAuthorisationRuleMixin({ subjects: [subjects] }),
// List of subjects that can provide authorisation for the console command to run.
withSubjectsMixin(subjects):: self + if std.type(subjects) == 'array' then __defaultAuthorisationRuleMixin({ subjects+: subjects }) else __defaultAuthorisationRuleMixin({ subjects+: [subjects] }),
},
defaultAuthorisationRuleType:: hidden.workloads.v1alpha1.consoleTemplateSpecDefaultAuthorisationRule,
// Default time, in seconds, that a Console will be created for. Maximum value of 1 week (as per MaxTimeoutSeconds).
withDefaultTimeoutSeconds(defaultTimeoutSeconds):: self + __specMixin({ defaultTimeoutSeconds: defaultTimeoutSeconds }),
// Specifies the TTL for any Console created with this template. If set, the Console will be eligible for garbage collection DefaultTTLSecondsAfterFinished seconds after it enters the Stopped or Destroyed phase. If not set, this value defaults to 24 hours. This field is modeled closely on the TTL mechanism in Kubernetes 1.12.
withDefaultTtlSecondsAfterFinished(defaultTtlSecondsAfterFinished):: self + __specMixin({ defaultTtlSecondsAfterFinished: defaultTtlSecondsAfterFinished }),
// Specifies the TTL before running for any Console created with this template. If set, the Console will be eligible for garbage collection TTLSecondsBeforeRunning seconds if it has not progressed to the Running phase. If not set, this value defaults to 60 minutes. This field is modeled on the TTL mechanism in Kubernetes 1.12.
withDefaultTtlSecondsBeforeRunning(defaultTtlSecondsBeforeRunning):: self + __specMixin({ defaultTtlSecondsBeforeRunning: defaultTtlSecondsBeforeRunning }),
// Maximum time, in seconds, that a Console can be created for. Maximum value of 1 week.
withMaxTimeoutSeconds(maxTimeoutSeconds):: self + __specMixin({ maxTimeoutSeconds: maxTimeoutSeconds }),
withTemplate(template):: self + __specMixin({ template: template }),
withTemplateMixin(template):: self + __specMixin({ template+: template }),
},
specType:: hidden.workloads.v1alpha1.consoleTemplateSpec,
},
},
// Computer generated, description unknown
consoleTemplateSpec:: {
new():: {},
withAdditionalAttachSubjects(additionalAttachSubjects):: self + if std.type(additionalAttachSubjects) == 'array' then { additionalAttachSubjects: additionalAttachSubjects } else { additionalAttachSubjects: [additionalAttachSubjects] },
withAdditionalAttachSubjectsMixin(additionalAttachSubjects):: self + if std.type(additionalAttachSubjects) == 'array' then { additionalAttachSubjects+: additionalAttachSubjects } else { additionalAttachSubjects+: [additionalAttachSubjects] },
// List of authorisation rules to match against in order from top to bottom.
withAuthorisationRules(authorisationRules):: self + if std.type(authorisationRules) == 'array' then { authorisationRules: authorisationRules } else { authorisationRules: [authorisationRules] },
// List of authorisation rules to match against in order from top to bottom.
withAuthorisationRulesMixin(authorisationRules):: self + if std.type(authorisationRules) == 'array' then { authorisationRules+: authorisationRules } else { authorisationRules+: [authorisationRules] },
// Default time, in seconds, that a Console will be created for. Maximum value of 1 week (as per MaxTimeoutSeconds).
withDefaultTimeoutSeconds(defaultTimeoutSeconds):: self + { defaultTimeoutSeconds: defaultTimeoutSeconds },
// Specifies the TTL for any Console created with this template. If set, the Console will be eligible for garbage collection DefaultTTLSecondsAfterFinished seconds after it enters the Stopped or Destroyed phase. If not set, this value defaults to 24 hours. This field is modeled closely on the TTL mechanism in Kubernetes 1.12.
withDefaultTtlSecondsAfterFinished(defaultTtlSecondsAfterFinished):: self + { defaultTtlSecondsAfterFinished: defaultTtlSecondsAfterFinished },
// Specifies the TTL before running for any Console created with this template. If set, the Console will be eligible for garbage collection TTLSecondsBeforeRunning seconds if it has not progressed to the Running phase. If not set, this value defaults to 60 minutes. This field is modeled on the TTL mechanism in Kubernetes 1.12.
withDefaultTtlSecondsBeforeRunning(defaultTtlSecondsBeforeRunning):: self + { defaultTtlSecondsBeforeRunning: defaultTtlSecondsBeforeRunning },
// Maximum time, in seconds, that a Console can be created for. Maximum value of 1 week.
withMaxTimeoutSeconds(maxTimeoutSeconds):: self + { maxTimeoutSeconds: maxTimeoutSeconds },
withTemplate(template):: self + { template: template },
withTemplateMixin(template):: self + { template+: template },
mixin:: {
// Computer generated, description unknown
defaultAuthorisationRule:: {
local __defaultAuthorisationRuleMixin(defaultAuthorisationRule) = { defaultAuthorisationRule+: defaultAuthorisationRule },
mixinInstance(defaultAuthorisationRule):: __defaultAuthorisationRuleMixin(defaultAuthorisationRule),
// The number of authorisations required from members of the subjects before the console can run.
withAuthorisationsRequired(authorisationsRequired):: self + __defaultAuthorisationRuleMixin({ authorisationsRequired: authorisationsRequired }),
// List of subjects that can provide authorisation for the console command to run.
withSubjects(subjects):: self + if std.type(subjects) == 'array' then __defaultAuthorisationRuleMixin({ subjects: subjects }) else __defaultAuthorisationRuleMixin({ subjects: [subjects] }),
// List of subjects that can provide authorisation for the console command to run.
withSubjectsMixin(subjects):: self + if std.type(subjects) == 'array' then __defaultAuthorisationRuleMixin({ subjects+: subjects }) else __defaultAuthorisationRuleMixin({ subjects+: [subjects] }),
},
defaultAuthorisationRuleType:: hidden.workloads.v1alpha1.consoleTemplateSpecDefaultAuthorisationRule,
},
},
// Computer generated, description unknown
consoleTemplateSpecDefaultAuthorisationRule:: {
new():: {},
// The number of authorisations required from members of the subjects before the console can run.
withAuthorisationsRequired(authorisationsRequired):: self + { authorisationsRequired: authorisationsRequired },
// List of subjects that can provide authorisation for the console command to run.
withSubjects(subjects):: self + if std.type(subjects) == 'array' then { subjects: subjects } else { subjects: [subjects] },
// List of subjects that can provide authorisation for the console command to run.
withSubjectsMixin(subjects):: self + if std.type(subjects) == 'array' then { subjects+: subjects } else { subjects+: [subjects] },
mixin:: {},
},
},
},
}
local k8s = (import 'k8s.libsonnet');
local fn = {
mapContainers(f):: {
local podContainers = super.spec.template.spec.containers,
spec+: {
template+: {
spec+: {
containers: std.map(f, podContainers),
},
},
},
},
mapContainersWithName(names, f)::
local nameSet = if std.type(names) == 'array' then std.set(names) else std.set([names]);
local inNameSet(name) = std.length(std.setInter(nameSet, std.set([name]))) > 0;
self.mapContainers(function(c) if std.objectHas(c, 'name') && inNameSet(c.name) then f(c) else c),
};
k8s + {
core:: k8s.core + {
v1:: k8s.core.v1 + {
list:: {
new(items):: {
apiVersion: 'v1',
} + {
kind: 'List',
} + self.items(items),
items(items):: if std.type(items) == 'array' then { items+: items } else { items+: [items] },
},
},
},
}
{
__ksonnet: {
"k8s.io": {
checksum: 'a7ae228407e3ecbb29d27de07282b3ace4f9dc7c4126dcab739bee39fb208d29',
generator: {
vendor: 'github.com/kube-jsonnet/k',
version: 'dev',
},
maintainer: 'kube-jsonnet',
version: '1.0.0',
},
},
_hidden:: (import '_hidden.libsonnet'),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment