Class: Document
Defined in: document.d.ts:10
Document corresponds to a single YAML document. Note that even though a YAML file can contain multiple documents, each one of these documents is represented by a separate Document object.
Although the root of the document can be any kind of node, only Mapping is supported.
Constructors
Constructor
new Document(path): Document;
Defined in: document.d.ts:12
Creates a new empty document with the given path.
Parameters
Parameter | Type |
---|---|
path | string |
Returns
Document
Constructor
new Document(path, yamlContent): Document;
Defined in: document.d.ts:15
Creates a new document with the given path and YAML content. The YAML content must be a valid YAML mapping.
Parameters
Parameter | Type |
---|---|
path | string |
yamlContent | string |
Returns
Document
Constructor
new Document(path, root): Document;
Defined in: document.d.ts:18
Creates a new document with the given path and root. The root must be a Mapping or an Object.
Parameters
Parameter | Type |
---|---|
path | string |
root | Object | Mapping |
Returns
Document
Properties
Property | Type | Description | Defined in |
---|---|---|---|
group? | DocumentGroup | The document group this document belongs to. | document.d.ts:24 |
path | string | The file path to the document. May contain multiple segments separated by slashes. | document.d.ts:21 |
Methods
clone()
clone(): Document;
Defined in: document.d.ts:33
Returns a deep clone of the document.
Returns
Document
ensureAnnotations()
ensureAnnotations(): Mapping;
Defined in: documentExtensions.d.ts:11
Ensures a Mapping for ".metadata.annotations".
Returns
ensureContainers()
ensureContainers(): Sequence;
Defined in: documentExtensions.d.ts:23
Ensures a Sequence for ".spec.containers" if the document specifies a Pod or ".spec.template.spec.containers" if the document specifies another type of workload.
Returns
ensureInitContainers()
ensureInitContainers(): Sequence;
Defined in: documentExtensions.d.ts:29
Ensures a Sequence for ".spec.initContainers" if the document specifies a Pod or ".spec.template.spec.initContainers" if the document specifies another type of workload.
Returns
ensureLabels()
ensureLabels(): Mapping;
Defined in: documentExtensions.d.ts:8
Ensures a Mapping for ".metadata.labels".
Returns
ensureMetadata()
ensureMetadata(): Mapping;
Defined in: document.d.ts:36
Ensures a Mapping for ".metadata".
Returns
ensureVolumes()
ensureVolumes(): Sequence;
Defined in: documentExtensions.d.ts:35
Ensures a Sequence for ".spec.volumes" if the document specifies a Pod or ".spec.template.spec.volumes" if the document specifies another type of workload.
Returns
ensureWorkloadAnnotations()
ensureWorkloadAnnotations(): Mapping;
Defined in: documentExtensions.d.ts:53
Ensures a Mapping for ".metadata.annotations" if the document specifies a Pod or ".spec.template.metadata.annotations" if the document specifies another type of workload.
Returns
ensureWorkloadLabels()
ensureWorkloadLabels(): Mapping;
Defined in: documentExtensions.d.ts:47
Ensures a Mapping for ".metadata.labels" if the document specifies a Pod or ".spec.template.metadata.labels" if the document specifies another type of workload.
Returns
ensureWorkloadMetadata()
ensureWorkloadMetadata(): Mapping;
Defined in: documentExtensions.d.ts:41
Ensures a Mapping for ".metadata" if the document specifies a Pod or ".spec.template.metadata" if the document specifies another type of workload.
Returns
ensureWorkloadSpec()
ensureWorkloadSpec(): Mapping;
Defined in: documentExtensions.d.ts:17
Ensures a Mapping for ".spec" if the document specifies a Pod or ".spec.template.spec" if the document specifies another type of workload.
Returns
fullPath()
fullPath(): string;
Defined in: document.d.ts:27
Returns the file path to write the document into. Adds group name as base directory if it is not null.
Returns
string
getAnnotation()
getAnnotation(annotation): string;
Defined in: documentExtensions.d.ts:77
Returns the value of ".metadata.annotations.$annotation". Returns null if the value is not found.
Parameters
Parameter | Type |
---|---|
annotation | string |
Returns
string
getAnnotations()
getAnnotations(): Mapping;
Defined in: documentExtensions.d.ts:80
Returns the Mapping for ".metadata.annotations". Returns null if the Mapping is not found.
Returns
getApiVersion()
getApiVersion(): string;
Defined in: documentExtensions.d.ts:56
Returns the value of ".apiVersion". Returns null if the value is not found.
Returns
string
getContainer()
Call Signature
getContainer(index): Mapping;
Defined in: documentExtensions.d.ts:95
Returns the ContainerMapping for ".spec.containers[i]" if the document specifies a Pod or ".spec.template.spec.containers[i]" if the document specifies another type of workload. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
index | number |
Returns
Call Signature
getContainer(name): Mapping;
Defined in: documentExtensions.d.ts:101
Returns the first Mapping under ".spec.containers" if the document specifies a Pod or ".spec.template.spec.containers" if the document specifies another type of workload that the name equals to the given parameter. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
name | string |
Returns
Call Signature
getContainer(filter): Mapping;
Defined in: documentExtensions.d.ts:107
Returns the first Mapping under ".spec.containers" if the document specifies a Pod or ".spec.template.spec.containers" if the document specifies another type of workload that the filter function returns true for. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
filter | (container ) => boolean |
Returns
getContainers()
getContainers(): Sequence;
Defined in: documentExtensions.d.ts:113
Returns the Sequence for ".spec.containers" if the document specifies a Pod or ".spec.template.spec.containers" if the document specifies another type of workload. Returns null if the Sequence is not found.
Returns
getInitContainer()
Call Signature
getInitContainer(index): Mapping;
Defined in: documentExtensions.d.ts:119
Returns the ContainerMapping for ".spec.initContainers[i]" if the document specifies a Pod or ".spec.template.spec.initContainers[i]" if the document specifies another type of workload. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
index | number |
Returns
Call Signature
getInitContainer(name): Mapping;
Defined in: documentExtensions.d.ts:125
Returns the first Mapping under ".spec.initContainers" if the document specifies a Pod or ".spec.template.spec.initContainers" if the document specifies another type of workload that the name equals to the given parameter. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
name | string |
Returns
Call Signature
getInitContainer(filter): Mapping;
Defined in: documentExtensions.d.ts:131
Returns the first Mapping under ".spec.initContainers" if the document specifies a Pod or ".spec.template.spec.initContainers" if the document specifies another type of workload that the filter function returns true for. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
filter | (container ) => boolean |
Returns
getInitContainers()
getInitContainers(): Sequence;
Defined in: documentExtensions.d.ts:137
Returns the Sequence for ".spec.initContainers" if the document specifies a Pod or ".spec.template.spec.initContainers" if the document specifies another type of workload. Returns null if the Sequence is not found.
Returns
getKind()
getKind(): string;
Defined in: documentExtensions.d.ts:59
Returns value of ".kind". Returns null if the value is not found.
Returns
string
getLabel()
getLabel(label): string;
Defined in: documentExtensions.d.ts:71
Returns the value of ".metadata.labels.$label". Returns null if the value is not found.
Parameters
Parameter | Type |
---|---|
label | string |
Returns
string
getLabels()
getLabels(): Mapping;
Defined in: documentExtensions.d.ts:74
Returns the Mapping for ".metadata.labels". Returns null if the Mapping is not found.
Returns
getMetadata()
getMetadata(): Mapping;
Defined in: documentExtensions.d.ts:62
Returns the Mapping for ".metadata". Returns null if the Mapping is not found.
Returns
getName()
getName(): string;
Defined in: documentExtensions.d.ts:65
Returns value of ".metadata.name". Returns null if the value is not found.
Returns
string
getNamespace()
getNamespace(): string;
Defined in: documentExtensions.d.ts:68
Returns value of ".metadata.namespace". Returns null if the value is not found.
Returns
string
getRoot()
getRoot(): Mapping;
Defined in: document.d.ts:30
Return the root of the document as a Mapping.
Returns
getSpec()
getSpec(): Mapping;
Defined in: documentExtensions.d.ts:83
Returns the Mapping for ".spec". Returns null if the value is not found.
Returns
getVolume()
Call Signature
getVolume(index): Mapping;
Defined in: documentExtensions.d.ts:143
Returns the Mapping for ".spec.volumes[i]" if the document specifies a Pod or ".spec.template.spec.volumes[i]" if the document specifies another type of workload. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
index | number |
Returns
Call Signature
getVolume(filter): Mapping;
Defined in: documentExtensions.d.ts:150
Returns the first Mapping under ".spec.volumes" if the document specifies a Pod or ".spec.template.spec.volumes" if the document specifies another type of workload that the filter function returns true for. Returns null if the Mapping is not found.
Parameters
Parameter | Type |
---|---|
filter | (volume ) => boolean |
Returns
getVolumes()
getVolumes(): Sequence;
Defined in: documentExtensions.d.ts:156
Returns the Sequence for ".spec.volumes" if the document specifies a Pod or ".spec.template.spec.volumes" if the document specifies another type of workload. Returns null if the Sequence is not found.
Returns
getWorkloadAnnotations()
getWorkloadAnnotations(): Mapping;
Defined in: documentExtensions.d.ts:174
Returns the Mapping for ".metadata.annotations" if the document specifies a Pod or ".spec.template.metadata.annotations" if the document specifies another type of workload. Returns null if the Mapping is not found.
Returns
getWorkloadLabels()
getWorkloadLabels(): Mapping;
Defined in: documentExtensions.d.ts:168
Returns the Mapping for ".metadata.labels" if the document specifies a Pod or ".spec.template.metadata.labels" if the document specifies another type of workload. Returns null if the Mapping is not found.
Returns
getWorkloadMetadata()
getWorkloadMetadata(): Mapping;
Defined in: documentExtensions.d.ts:162
Returns the Mapping for ".metadata" if the document specifies a Pod or ".spec.template.metadata" if the document specifies another type of workload. Returns null if the Mapping is not found.
Returns
getWorkloadSpec()
getWorkloadSpec(): Mapping;
Defined in: documentExtensions.d.ts:89
Returns the Mapping for ".spec" if the document specifies a Pod or ".spec.template.spec" if the document specifies another type of workload. Returns null if the Mapping is not found.
Returns
isClusterRole()
isClusterRole(): boolean;
Defined in: documentExtensions.d.ts:180
Returns true if the document is a ClusterRole.
Returns
boolean
isClusterRoleBinding()
isClusterRoleBinding(): boolean;
Defined in: documentExtensions.d.ts:183
Returns true if the document is a ClusterRoleBinding.
Returns
boolean
isConfigMap()
isConfigMap(): boolean;
Defined in: documentExtensions.d.ts:186
Returns true if the document is a ConfigMap.
Returns
boolean
isCronJob()
isCronJob(): boolean;
Defined in: documentExtensions.d.ts:189
Returns true if the document is a CronJob.
Returns
boolean
isCustomResourceDefinition()
isCustomResourceDefinition(): boolean;
Defined in: documentExtensions.d.ts:192
Returns true if the document is a CustomResourceDefinition.
Returns
boolean
isDaemonSet()
isDaemonSet(): boolean;
Defined in: documentExtensions.d.ts:195
Returns true if the document is a DaemonSet.
Returns
boolean
isDeployment()
isDeployment(): boolean;
Defined in: documentExtensions.d.ts:198
Returns true if the document is a Deployment.
Returns
boolean
isHorizontalPodAutoscaler()
isHorizontalPodAutoscaler(): boolean;
Defined in: documentExtensions.d.ts:201
Returns true if the document is a HorizontalPodAutoscaler.
Returns
boolean
isIngress()
isIngress(): boolean;
Defined in: documentExtensions.d.ts:204
Returns true if the document is an Ingress.
Returns
boolean
isJob()
isJob(): boolean;
Defined in: documentExtensions.d.ts:207
Returns true if the document is a Job.
Returns
boolean
isNamespace()
isNamespace(): boolean;
Defined in: documentExtensions.d.ts:210
Returns true if the document is a Namespace.
Returns
boolean
isOfKind()
isOfKind(apiVersion, kind): boolean;
Defined in: documentExtensions.d.ts:177
Returns true if the document has the given apiVersion and kind.
Parameters
Parameter | Type |
---|---|
apiVersion | string |
kind | string |
Returns
boolean
isPersistentVolume()
isPersistentVolume(): boolean;
Defined in: documentExtensions.d.ts:213
Returns true if the document is a PersistentVolume.
Returns
boolean
isPersistentVolumeClaim()
isPersistentVolumeClaim(): boolean;
Defined in: documentExtensions.d.ts:216
Returns true if the document is a PersistentVolumeClaim.
Returns
boolean
isPod()
isPod(): boolean;
Defined in: documentExtensions.d.ts:219
Returns true if the document is a Pod.
Returns
boolean
isReplicaSet()
isReplicaSet(): boolean;
Defined in: documentExtensions.d.ts:222
Returns true if the document is a ReplicaSet.
Returns
boolean
isRole()
isRole(): boolean;
Defined in: documentExtensions.d.ts:225
Returns true if the document is a Role.
Returns
boolean
isRoleBinding()
isRoleBinding(): boolean;
Defined in: documentExtensions.d.ts:228
Returns true if the document is a RoleBinding.
Returns
boolean
isSecret()
isSecret(): boolean;
Defined in: documentExtensions.d.ts:231
Returns true if the document is a Secret.
Returns
boolean
isService()
isService(): boolean;
Defined in: documentExtensions.d.ts:234
Returns true if the document is a Service.
Returns
boolean
isServiceAccount()
isServiceAccount(): boolean;
Defined in: documentExtensions.d.ts:237
Returns true if the document is a ServiceAccount.
Returns
boolean
isStatefulSet()
isStatefulSet(): boolean;
Defined in: documentExtensions.d.ts:240
Returns true if the document is a StatefulSet.
Returns
boolean
isWorkload()
isWorkload(): boolean;
Defined in: documentExtensions.d.ts:243
Returns true if the document is one of these: CronJob, DaemonSet, Deployment, Job, Pod, ReplicaSet, StatefulSet.
Returns
boolean
setAnnotation()
setAnnotation(key, value): void;
Defined in: documentExtensions.d.ts:261
Sets the given key value pair to ".metadata.annotations".
Parameters
Parameter | Type |
---|---|
key | string |
value | string |
Returns
void
setAnnotations()
setAnnotations(annotations): void;
Defined in: documentExtensions.d.ts:264
Sets the given key value pairs to ".metadata.annotations". Keys are sorted alphabetically.
Parameters
Parameter | Type |
---|---|
annotations | Record <string , string > |
Returns
void
setLabel()
setLabel(key, value): void;
Defined in: documentExtensions.d.ts:252
Sets the given key value pair to ".metadata.labels".
Parameters
Parameter | Type |
---|---|
key | string |
value | string |
Returns
void
setLabels()
Call Signature
setLabels(labels): void;
Defined in: documentExtensions.d.ts:255
Sets the given key value pairs to ".metadata.labels". Keys are sorted alphabetically.
Parameters
Parameter | Type |
---|---|
labels | Record <string , string > |
Returns
void
Call Signature
setLabels(labels, labelNodes): void;
Defined in: documentExtensions.d.ts:258
Sets the given key value pairs to the specified nodes on the document. Keys are sorted alphabetically.
Parameters
Parameter | Type |
---|---|
labels | Record <string , string > |
labelNodes | LabelNode [] |
Returns
void
setName()
setName(value): void;
Defined in: documentExtensions.d.ts:246
Sets the given value to ".metadata.name".
Parameters
Parameter | Type |
---|---|
value | string |
Returns
void
setNamespace()
setNamespace(value): void;
Defined in: documentExtensions.d.ts:249
Sets the given value to ".metadata.namespace".
Parameters
Parameter | Type |
---|---|
value | string |
Returns
void