@provisioner/common
Version:
Common stuff for provisioners
59 lines • 2.42 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateImageTag = void 0;
const pointer = __importStar(require("jsonpointer"));
const debug_1 = __importDefault(require("debug"));
const debug = debug_1.default('provisioner:c6o-system:updateSystem:');
exports.updateImageTag = async (cluster, document, tag, path) => {
const result = await cluster.list(document);
if (result.error) {
debug(`Failed to retrieve system ${document.kind}`, result.error);
return;
}
try {
for (const docItem of result.object.items) {
debug(`Updating ${document.kind}`, docItem.metadata.name);
const currentImage = pointer.get(docItem, path);
const sansTag = currentImage.substring(0, currentImage.indexOf(':'));
const newImage = `${sansTag}:${tag}`;
debug(`Going from ${currentImage} to ${newImage}`);
const op = [{ op: 'replace', path, value: newImage }];
const patchResult = await cluster.patch({
apiVersion: document.apiVersion,
kind: document.kind,
...docItem
}, op);
if (patchResult.error)
throw patchResult.error;
else
debug('Success');
}
}
catch (ex) {
debug('ERROR during update', ex);
throw ex;
}
};
//# sourceMappingURL=update.js.map