Skip to main content

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

ParameterType
pathstring

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

ParameterType
pathstring
yamlContentstring

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

ParameterType
pathstring
rootObject | Mapping

Returns

Document

Properties

PropertyTypeDescriptionDefined in
group?DocumentGroupThe document group this document belongs to.document.d.ts:24
pathstringThe 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

Mapping


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

Sequence


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

Sequence


ensureLabels()

ensureLabels(): Mapping;

Defined in: documentExtensions.d.ts:8

Ensures a Mapping for ".metadata.labels".

Returns

Mapping


ensureMetadata()

ensureMetadata(): Mapping;

Defined in: document.d.ts:36

Ensures a Mapping for ".metadata".

Returns

Mapping


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

Sequence


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

Mapping


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

Mapping


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

Mapping


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

Mapping


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

ParameterType
annotationstring

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

Mapping


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
ParameterType
indexnumber
Returns

Mapping

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
ParameterType
namestring
Returns

Mapping

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
ParameterType
filter(container) => boolean
Returns

Mapping


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

Sequence


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
ParameterType
indexnumber
Returns

Mapping

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
ParameterType
namestring
Returns

Mapping

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
ParameterType
filter(container) => boolean
Returns

Mapping


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

Sequence


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

ParameterType
labelstring

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

Mapping


getMetadata()

getMetadata(): Mapping;

Defined in: documentExtensions.d.ts:62

Returns the Mapping for ".metadata". Returns null if the Mapping is not found.

Returns

Mapping


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

Mapping


getSpec()

getSpec(): Mapping;

Defined in: documentExtensions.d.ts:83

Returns the Mapping for ".spec". Returns null if the value is not found.

Returns

Mapping


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
ParameterType
indexnumber
Returns

Mapping

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
ParameterType
filter(volume) => boolean
Returns

Mapping


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

Sequence


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

Mapping


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

Mapping


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

Mapping


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

Mapping


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

ParameterType
apiVersionstring
kindstring

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

ParameterType
keystring
valuestring

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

ParameterType
annotationsRecord<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

ParameterType
keystring
valuestring

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
ParameterType
labelsRecord<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
ParameterType
labelsRecord<string, string>
labelNodesLabelNode[]
Returns

void


setName()

setName(value): void;

Defined in: documentExtensions.d.ts:246

Sets the given value to ".metadata.name".

Parameters

ParameterType
valuestring

Returns

void


setNamespace()

setNamespace(value): void;

Defined in: documentExtensions.d.ts:249

Sets the given value to ".metadata.namespace".

Parameters

ParameterType
valuestring

Returns

void