@wocker/mariadb-plugin
Version:
Mariadb plugin for wocker
79 lines (78 loc) • 2.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Service = exports.STORAGE_VOLUME = exports.STORAGE_FILESYSTEM = void 0;
exports.STORAGE_FILESYSTEM = "filesystem";
exports.STORAGE_VOLUME = "volume";
class Service {
constructor(data) {
const { name, host, user, username, password, passwordHash, rootPassword, storage, volume, image, imageName = image || "mariadb", imageVersion = "latest", env, containerPort } = data;
this.name = name;
this.host = host;
this.username = username || user;
this.password = password;
this.passwordHash = passwordHash;
this.rootPassword = rootPassword || password;
this.storage = storage;
this._volume = volume;
this.imageName = imageName;
this.imageVersion = imageVersion;
this.env = env;
this.containerPort = containerPort;
if (!host && !storage) {
this.storage = exports.STORAGE_FILESYSTEM;
}
}
get auth() {
const cmd = [];
if (!this.host) {
cmd.push("-uroot");
if (this.rootPassword) {
cmd.push(`-p${this.rootPassword}`);
}
}
else {
if (this.username) {
cmd.push(`-u${this.username}`);
}
if (this.password) {
cmd.push(`-p${this.password}`);
}
}
return cmd;
}
get imageTag() {
return `${this.imageName}:${this.imageVersion}`;
}
get containerName() {
return `mariadb-${this.name}.ws`;
}
get volume() {
if (!this._volume) {
this._volume = this.defaultVolume;
}
return this._volume;
}
set volume(volume) {
this._volume = volume;
}
get defaultVolume() {
return `wocker-mariadb-${this.name}`;
}
toObject() {
return {
name: this.name,
host: this.host,
username: this.username,
password: this.password,
passwordHash: this.passwordHash,
rootPassword: this.rootPassword,
storage: this.storage,
volume: this._volume,
imageName: this.imageName,
imageVersion: this.imageVersion,
env: this.env,
containerPort: this.containerPort
};
}
}
exports.Service = Service;