containerify 3.2.1 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/appLayerCreator.d.ts +2 -2
- package/lib/appLayerCreator.js +8 -1
- package/lib/cli.js +7 -3
- package/lib/httpRequest.js +0 -1
- package/lib/types.d.ts +2 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/appLayerCreator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Options } from "./types";
|
|
2
|
-
declare function addLayers(tmpdir: string, fromdir: string, todir: string, options: Options): Promise<
|
|
1
|
+
import { ManifestDescriptor, Options } from "./types";
|
|
2
|
+
declare function addLayers(tmpdir: string, fromdir: string, todir: string, options: Options): Promise<ManifestDescriptor>;
|
|
3
3
|
declare const _default: {
|
|
4
4
|
addLayers: typeof addLayers;
|
|
5
5
|
};
|
package/lib/appLayerCreator.js
CHANGED
|
@@ -253,7 +253,14 @@ function addLayers(tmpdir, fromdir, todir, options) {
|
|
|
253
253
|
yield fs_1.promises.writeFile(configFile, configContent);
|
|
254
254
|
manifest.config.digest = "sha256:" + configHash;
|
|
255
255
|
manifest.config.size = yield fileutil.sizeOf(configFile);
|
|
256
|
-
|
|
256
|
+
const manifestJson = JSON.stringify(manifest);
|
|
257
|
+
yield fs_1.promises.writeFile(path.join(todir, "manifest.json"), manifestJson);
|
|
258
|
+
const manifestBuffer = Buffer.from(manifestJson, "utf-8");
|
|
259
|
+
return {
|
|
260
|
+
mediaType: manifest.mediaType,
|
|
261
|
+
digest: calculateHashOfBuffer(manifestBuffer),
|
|
262
|
+
size: manifestBuffer.byteLength,
|
|
263
|
+
};
|
|
257
264
|
});
|
|
258
265
|
}
|
|
259
266
|
exports.default = {
|
package/lib/cli.js
CHANGED
|
@@ -61,6 +61,7 @@ program
|
|
|
61
61
|
.option("--layerOwner <gid:uid>", "Optional: Set specific gid and uid on files in the added layers")
|
|
62
62
|
.option("--buildFolder <path>", "Optional: Use a specific build folder when creating the image")
|
|
63
63
|
.option("--layerCacheFolder <path>", "Optional: Folder to cache base layers between builds")
|
|
64
|
+
.option("--writeDigestTo <path>", "Optional: Write the resulting image digest to the file path provided")
|
|
64
65
|
.version(version_1.VERSION, "--version", "Get containerify version");
|
|
65
66
|
program.parse(process.argv);
|
|
66
67
|
function setKeyValue(target, keyValue, separator = "=", defaultValue) {
|
|
@@ -96,7 +97,6 @@ const labels = Object.assign(Object.assign({}, configFromFile.labels), labelsOpt
|
|
|
96
97
|
const envOpt = {};
|
|
97
98
|
(_b = cliOptions.envs) === null || _b === void 0 ? void 0 : _b.forEach((envs) => envs.split(",").forEach((env) => setKeyValue(envOpt, env)));
|
|
98
99
|
const envs = Object.assign(Object.assign({}, configFromFile.envs), envOpt); //Let cli arguments override file
|
|
99
|
-
console.log(envs);
|
|
100
100
|
const customContent = {};
|
|
101
101
|
(_c = configFromFile.customContent) === null || _c === void 0 ? void 0 : _c.forEach((c) => setKeyValue(customContent, c, ":", c));
|
|
102
102
|
(_d = cliOptions.customContent) === null || _d === void 0 ? void 0 : _d.forEach((contents) => contents.split(",").forEach((content) => setKeyValue(customContent, content, ":", content)));
|
|
@@ -118,7 +118,7 @@ const options = Object.assign(Object.assign(Object.assign({}, defaultOptions), s
|
|
|
118
118
|
user: setOptions.user,
|
|
119
119
|
workdir: setOptions.workdir,
|
|
120
120
|
entrypoint: setOptions.entrypoint,
|
|
121
|
-
} });
|
|
121
|
+
}, writeDigestTo: cliOptions.writeDigestTo });
|
|
122
122
|
function exitWithErrorIf(check, error) {
|
|
123
123
|
if (check) {
|
|
124
124
|
logger_1.default.error("ERROR: " + error);
|
|
@@ -214,7 +214,7 @@ function run(options) {
|
|
|
214
214
|
const fromRegistryUrl = (_a = options.fromRegistry) !== null && _a !== void 0 ? _a : registry_1.DEFAULT_DOCKER_REGISTRY;
|
|
215
215
|
const fromRegistry = yield (0, registry_1.createRegistry)(fromRegistryUrl, options.fromImage, allowInsecure, options.fromToken);
|
|
216
216
|
const originalManifest = yield fromRegistry.download(options.fromImage, fromdir, (0, utils_1.getPreferredPlatform)(options.platform), options.layerCacheFolder);
|
|
217
|
-
yield appLayerCreator_1.default.addLayers(tmpdir, fromdir, todir, options);
|
|
217
|
+
const manifestDescriptor = yield appLayerCreator_1.default.addLayers(tmpdir, fromdir, todir, options);
|
|
218
218
|
if (options.toDocker) {
|
|
219
219
|
if (!(yield dockerExporter_1.default.isAvailable())) {
|
|
220
220
|
throw new Error("Docker executable not found on path. Unable to export to local docker registry.");
|
|
@@ -233,6 +233,10 @@ function run(options) {
|
|
|
233
233
|
logger_1.default.debug(`Deleting ${tmpdir} ...`);
|
|
234
234
|
yield fse.remove(tmpdir);
|
|
235
235
|
logger_1.default.debug("Done");
|
|
236
|
+
if (options.writeDigestTo) {
|
|
237
|
+
logger_1.default.debug(`Writing digest ${manifestDescriptor.digest} to ${options.writeDigestTo}`);
|
|
238
|
+
fs.writeFileSync(options.writeDigestTo, manifestDescriptor.digest);
|
|
239
|
+
}
|
|
236
240
|
});
|
|
237
241
|
}
|
|
238
242
|
logger_1.default.debug("Running with config:", options);
|
package/lib/httpRequest.js
CHANGED
|
@@ -101,7 +101,6 @@ function followRedirects(uri, headers, allowInsecure, cb, count = 0) {
|
|
|
101
101
|
if (count > 10)
|
|
102
102
|
return cb({ error: "Too many redirects for " + uri });
|
|
103
103
|
const location = res.headers.location;
|
|
104
|
-
console.log(res.headers);
|
|
105
104
|
if (!location)
|
|
106
105
|
return cb({ error: "Redirect, but missing location header" });
|
|
107
106
|
return followRedirects(location, headers, allowInsecure, cb, count + 1);
|
package/lib/types.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ export type Options = {
|
|
|
91
91
|
workdir?: string;
|
|
92
92
|
entrypoint?: string;
|
|
93
93
|
};
|
|
94
|
+
writeDigestTo?: string;
|
|
94
95
|
};
|
|
95
96
|
export declare enum InsecureRegistrySupport {
|
|
96
97
|
NO = 0,
|
|
@@ -101,4 +102,5 @@ export type Registry = {
|
|
|
101
102
|
upload: (imageStr: string, folder: string, doCrossMount: boolean, originalManifest: Manifest, originalRepository: string) => Promise<void>;
|
|
102
103
|
registryBaseUrl: string;
|
|
103
104
|
};
|
|
105
|
+
export type ManifestDescriptor = Descriptor;
|
|
104
106
|
export {};
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.3.1";
|
package/lib/version.js
CHANGED