UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

54 lines 1.54 kB
/** * SPDX-License-Identifier: Apache-2.0 */ import { isDns1123Label } from '../kube_validation.js'; import { InvalidResourceNameError } from '../errors/invalid_resource_name_error.js'; export class ResourceName { name; constructor(type, name) { this.name = name; if (!this.isValid()) { throw new InvalidResourceNameError(name, type); } } /** * Returns true if the pod name is valid. A Kubernetes pod name must be a valid RFC-1123 DNS label. * * @include DNS_1123_LABEL * * @returns true if the pod name is valid. * @throws InvalidResourceNameError if the pod name is invalid. */ isValid() { return isDns1123Label(this.name); } /** * Compares this instance with another PodName. * @param other The other PodName instance. * @returns true if both instances have the same name. */ equals(other) { return other instanceof ResourceName && this.name === other.name; } /** * Allows implicit conversion to a string. * @returns The pod name as a string. */ toString() { return this.name; } /** * Allows `PodName` to be used as a primitive string in operations. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars [Symbol.toPrimitive](hint) { return this.name; } /** * Returns the primitive value of the object. */ valueOf() { return this.name; } } //# sourceMappingURL=resource_name.js.map