diff options
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/models/image-spec.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/image-spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/image-spec.ts new file mode 100644 index 000000000..8b56b291c --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/image-spec.ts @@ -0,0 +1,25 @@ +export class ImageSpec { + static fromString(imageSpec: string) { + const imageSpecSplited = imageSpec.split('/'); + + const poolName = imageSpecSplited[0]; + const namespace = imageSpecSplited.length >= 3 ? imageSpecSplited[1] : null; + const imageName = imageSpecSplited.length >= 3 ? imageSpecSplited[2] : imageSpecSplited[1]; + + return new this(poolName, namespace, imageName); + } + + constructor(public poolName: string, public namespace: string, public imageName: string) {} + + private getNameSpace() { + return this.namespace ? `${this.namespace}/` : ''; + } + + toString() { + return `${this.poolName}/${this.getNameSpace()}${this.imageName}`; + } + + toStringEncoded() { + return encodeURIComponent(`${this.poolName}/${this.getNameSpace()}${this.imageName}`); + } +} |