containerify 3.0.1 → 3.1.0

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/README.md CHANGED
@@ -80,6 +80,7 @@ Options:
80
80
  --setTimeStamp <timestamp> Optional: Set a specific ISO 8601 timestamp on all entries (e.g. git commit hash). Default: 1970 in tar files, and current time on manifest/config
81
81
  --verbose Verbose logging
82
82
  --allowInsecureRegistries Allow insecure registries (with self-signed/untrusted cert)
83
+ --allowNoPushAuth Allow pushing images without authentication/token if the registry allows it
83
84
  --customContent <dirs/files> Optional: Skip normal node_modules and applayer and include specified root folder files/directories instead. You can specify as
84
85
  local-path:absolute-container-path if you want to place it in a specific location
85
86
  --extraContent <dirs/files> Optional: Add specific content. Specify as local-path:absolute-container-path,local-path2:absolute-container-path2 etc
package/lib/cli.js CHANGED
@@ -53,6 +53,7 @@ const possibleArgs = {
53
53
  "--setTimeStamp <timestamp>": "Optional: Set a specific ISO 8601 timestamp on all entries (e.g. git commit hash). Default: 1970 in tar files, and current time on manifest/config",
54
54
  "--verbose": "Verbose logging",
55
55
  "--allowInsecureRegistries": "Allow insecure registries (with self-signed/untrusted cert)",
56
+ "--allowNoPushAuth": "Allow pushing images without a authentication/token to registries that allow it",
56
57
  "--customContent <dirs/files>": "Optional: Skip normal node_modules and applayer and include specified root folder files/directories instead. You can specify as local-path:absolute-container-path if you want to place it in a specific location",
57
58
  "--extraContent <dirs/files>": "Optional: Add specific content. Specify as local-path:absolute-container-path,local-path2:absolute-container-path2 etc",
58
59
  "--layerOwner <gid:uid>": "Optional: Set specific gid and uid on files in the added layers",
@@ -196,7 +197,7 @@ exitWithErrorIf(!options.folder, "--folder must be specified");
196
197
  exitWithErrorIf(!options.fromImage, "--fromImage must be specified");
197
198
  exitWithErrorIf(!options.toImage, "--toImage must be specified");
198
199
  exitWithErrorIf(!options.toRegistry && !options.toTar && !options.toDocker, "Must specify either --toTar, --toRegistry or --toDocker");
199
- exitWithErrorIf(!!options.toRegistry && !options.toToken, "A token must be given when uploading to docker hub");
200
+ exitWithErrorIf(!!options.toRegistry && !options.toToken && !options.allowNoPushAuth, "A token must be provided when uploading images");
200
201
  if (options.toRegistry && !options.toRegistry.endsWith("/"))
201
202
  options.toRegistry += "/";
202
203
  if (options.fromRegistry && !options.fromRegistry.endsWith("/"))
@@ -250,9 +251,6 @@ function run(options) {
250
251
  yield tarExporter_1.default.saveToTar(todir, tmpdir, options.toTar, [options.toImage], options);
251
252
  }
252
253
  if (options.toRegistry) {
253
- if (!options.token && allowInsecure == types_1.InsecureRegistrySupport.NO) {
254
- throw new Error("Need auth token to upload to " + options.toRegistry);
255
- }
256
254
  const toRegistry = yield (0, registry_1.createRegistry)(options.toRegistry, options.toImage, allowInsecure, options.toToken, options.optimisticToRegistryCheck);
257
255
  yield toRegistry.upload(options.toImage, todir, options.doCrossMount, originalManifest, options.fromImage);
258
256
  }
package/lib/registry.js CHANGED
@@ -98,11 +98,13 @@ function uploadContent(uploadUrl, file, fileConfig, allowInsecure, auth, content
98
98
  let url = uploadUrl;
99
99
  if (fileConfig.digest)
100
100
  url += (url.indexOf("?") == -1 ? "?" : "&") + "digest=" + fileConfig.digest;
101
- const options = (0, httpRequest_1.createHttpOptions)("PUT", url, {
102
- authorization: auth,
101
+ const headers = {
103
102
  "content-length": fileConfig.size,
104
103
  "content-type": contentType,
105
- });
104
+ };
105
+ if (auth)
106
+ headers.authorization = auth;
107
+ const options = (0, httpRequest_1.createHttpOptions)("PUT", url, headers);
106
108
  logger_1.default.debug(options.method, url);
107
109
  const req = (0, httpRequest_1.request)(options, allowInsecure, (res) => {
108
110
  var _a;
@@ -171,7 +173,8 @@ function createRegistry(registryBaseUrl, imagePath, allowInsecure, auth, optimis
171
173
  const url = `${registryBaseUrl}${image.path}/blobs/uploads/${parameters.size > 0 ? "?" + parameters : ""}`;
172
174
  const options = URL.parse(url);
173
175
  options.method = "POST";
174
- options.headers = { authorization: auth };
176
+ if (auth)
177
+ options.headers = { authorization: auth };
175
178
  (0, httpRequest_1.request)(options, allowInsecure, (res) => {
176
179
  logger_1.default.debug("POST", `${url}`, res.statusCode);
177
180
  if (res.statusCode == 202) {
package/lib/types.d.ts CHANGED
@@ -79,6 +79,7 @@ export type Options = {
79
79
  setTimeStamp?: string;
80
80
  verbose?: boolean;
81
81
  allowInsecureRegistries?: boolean;
82
+ allowNoPushAuth?: boolean;
82
83
  customContent: Record<string, string>;
83
84
  extraContent: Record<string, string>;
84
85
  layerOwner?: string;
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.1";
1
+ export declare const VERSION = "3.1.0";
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "3.0.1";
4
+ exports.VERSION = "3.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "containerify",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "Build node.js docker images without docker",
5
5
  "main": "./lib/cli.js",
6
6
  "scripts": {
@@ -12,12 +12,16 @@
12
12
  "check": "npm run lint && npm run typecheck",
13
13
  "dev": "tsc --watch",
14
14
  "integrationTest": "cd tests/integration/ && ./test.sh",
15
- "registryTest": "cd tests/localtest/ && ./test.sh"
15
+ "registryTest": "cd tests/localtest/ && ./test.sh && ./test-insecure.sh",
16
+ "allTests": "npm run integrationTest && npm run registryTest"
16
17
  },
17
18
  "bin": {
18
19
  "containerify": "./lib/cli.js"
19
20
  },
20
21
  "author": "Erlend Oftedal <erlend@oftedal.no>",
22
+ "contributors": [
23
+ "Vegard S. Hagen <vegard@stonegarden.dev>"
24
+ ],
21
25
  "license": "Apache-2.0",
22
26
  "repository": {
23
27
  "type": "git",