@jcoreio/aws-ecr-utils 1.1.1 → 1.2.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/checkECRRepositoryPolicy.d.ts +20 -0
- package/checkECRRepositoryPolicy.js +132 -0
- package/checkECRRepositoryPolicy.mjs +100 -0
- package/copyECRImage.js +79 -104
- package/copyECRImage.mjs +67 -0
- package/ecrImageExists.js +51 -74
- package/ecrImageExists.mjs +31 -0
- package/index.d.ts +2 -0
- package/index.js +20 -13
- package/index.mjs +8 -0
- package/loginToECR.js +44 -65
- package/loginToECR.mjs +38 -0
- package/package.json +25 -104
- package/parseECRImageUri.d.ts +3 -2
- package/parseECRImageUri.js +6 -10
- package/parseECRImageUri.mjs +11 -0
- package/parseECRRepositoryHostname.d.ts +6 -0
- package/parseECRRepositoryHostname.js +22 -0
- package/parseECRRepositoryHostname.mjs +10 -0
- package/tagECRImage.js +81 -115
- package/tagECRImage.mjs +50 -0
- package/upsertECRRepository.js +45 -64
- package/upsertECRRepository.mjs +33 -0
- package/es/copyECRImage.d.ts +0 -13
- package/es/copyECRImage.js +0 -76
- package/es/ecrImageExists.d.ts +0 -9
- package/es/ecrImageExists.js +0 -45
- package/es/index.d.ts +0 -6
- package/es/index.js +0 -56
- package/es/loginToECR.d.ts +0 -8
- package/es/loginToECR.js +0 -56
- package/es/parseECRImageUri.d.ts +0 -6
- package/es/parseECRImageUri.js +0 -19
- package/es/tagECRImage.d.ts +0 -10
- package/es/tagECRImage.js +0 -65
- package/es/upsertECRRepository.d.ts +0 -6
- package/es/upsertECRRepository.js +0 -45
- /package/{es/copyECRImage.js.flow → copyECRImage.mjs.flow} +0 -0
- /package/{es/ecrImageExists.js.flow → ecrImageExists.mjs.flow} +0 -0
- /package/{es/index.js.flow → index.mjs.flow} +0 -0
- /package/{es/loginToECR.js.flow → loginToECR.mjs.flow} +0 -0
- /package/{es/parseECRImageUri.js.flow → parseECRImageUri.mjs.flow} +0 -0
- /package/{es/tagECRImage.js.flow → tagECRImage.mjs.flow} +0 -0
- /package/{es/upsertECRRepository.js.flow → upsertECRRepository.mjs.flow} +0 -0
package/ecrImageExists.js
CHANGED
|
@@ -1,97 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = ecrImageExists;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
12
|
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
15
|
function ecrImageExists(_x) {
|
|
25
16
|
return _ecrImageExists.apply(this, arguments);
|
|
26
17
|
}
|
|
27
|
-
|
|
28
18
|
function _ecrImageExists() {
|
|
29
19
|
_ecrImageExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
|
|
30
20
|
var ecr, awsConfig, imageUri, registryId, repositoryName, imageTag, region, match, _match;
|
|
31
|
-
|
|
32
21
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
33
|
-
while (1) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
region
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}).promise().then(function () {
|
|
81
|
-
return true;
|
|
82
|
-
}, function () {
|
|
83
|
-
return false;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
case 16:
|
|
87
|
-
return _context.abrupt("return", _context.sent);
|
|
88
|
-
|
|
89
|
-
case 17:
|
|
90
|
-
case "end":
|
|
91
|
-
return _context.stop();
|
|
92
|
-
}
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
ecr = _ref.ecr, awsConfig = _ref.awsConfig, imageUri = _ref.imageUri, registryId = _ref.registryId, repositoryName = _ref.repositoryName, imageTag = _ref.imageTag;
|
|
25
|
+
if (!imageUri) {
|
|
26
|
+
_context.next = 10;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
match = /(\d+)\.dkr\.ecr\.(.+?)\.amazonaws\.com\/(.+?):(.+)/.exec(imageUri);
|
|
30
|
+
if (match) {
|
|
31
|
+
_context.next = 5;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
throw new Error("failed to parse imageUri: ".concat(imageUri));
|
|
35
|
+
case 5:
|
|
36
|
+
_match = (0, _slicedToArray2["default"])(match, 5);
|
|
37
|
+
registryId = _match[1];
|
|
38
|
+
region = _match[2];
|
|
39
|
+
repositoryName = _match[3];
|
|
40
|
+
imageTag = _match[4];
|
|
41
|
+
case 10:
|
|
42
|
+
if (!region) region = awsConfig === null || awsConfig === void 0 ? void 0 : awsConfig.region;
|
|
43
|
+
if (!ecr) ecr = new _awsSdk["default"].ECR(_objectSpread(_objectSpread({}, awsConfig), {}, {
|
|
44
|
+
region: region
|
|
45
|
+
}));
|
|
46
|
+
if (!(!repositoryName || !imageTag)) {
|
|
47
|
+
_context.next = 14;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
throw new Error("missing repositoryName/imageTag or imageUri");
|
|
51
|
+
case 14:
|
|
52
|
+
_context.next = 16;
|
|
53
|
+
return ecr.describeImages({
|
|
54
|
+
registryId: registryId,
|
|
55
|
+
repositoryName: repositoryName,
|
|
56
|
+
imageIds: [{
|
|
57
|
+
imageTag: imageTag
|
|
58
|
+
}]
|
|
59
|
+
}).promise().then(function () {
|
|
60
|
+
return true;
|
|
61
|
+
}, function () {
|
|
62
|
+
return false;
|
|
63
|
+
});
|
|
64
|
+
case 16:
|
|
65
|
+
return _context.abrupt("return", _context.sent);
|
|
66
|
+
case 17:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
93
69
|
}
|
|
94
70
|
}, _callee);
|
|
95
71
|
}));
|
|
96
72
|
return _ecrImageExists.apply(this, arguments);
|
|
97
|
-
}
|
|
73
|
+
}
|
|
74
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import AWS from 'aws-sdk';
|
|
2
|
+
export default async function ecrImageExists({
|
|
3
|
+
ecr,
|
|
4
|
+
awsConfig,
|
|
5
|
+
imageUri,
|
|
6
|
+
registryId,
|
|
7
|
+
repositoryName,
|
|
8
|
+
imageTag
|
|
9
|
+
}) {
|
|
10
|
+
let region;
|
|
11
|
+
if (imageUri) {
|
|
12
|
+
const match = /(\d+)\.dkr\.ecr\.(.+?)\.amazonaws\.com\/(.+?):(.+)/.exec(imageUri);
|
|
13
|
+
if (!match) throw new Error(`failed to parse imageUri: ${imageUri}`);
|
|
14
|
+
[, registryId, region, repositoryName, imageTag] = match;
|
|
15
|
+
}
|
|
16
|
+
if (!region) region = awsConfig === null || awsConfig === void 0 ? void 0 : awsConfig.region;
|
|
17
|
+
if (!ecr) ecr = new AWS.ECR({
|
|
18
|
+
...awsConfig,
|
|
19
|
+
region
|
|
20
|
+
});
|
|
21
|
+
if (!repositoryName || !imageTag) {
|
|
22
|
+
throw new Error(`missing repositoryName/imageTag or imageUri`);
|
|
23
|
+
}
|
|
24
|
+
return await ecr.describeImages({
|
|
25
|
+
registryId,
|
|
26
|
+
repositoryName,
|
|
27
|
+
imageIds: [{
|
|
28
|
+
imageTag
|
|
29
|
+
}]
|
|
30
|
+
}).promise().then(() => true, () => false);
|
|
31
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { default as ecrImageExists } from './ecrImageExists';
|
|
|
3
3
|
export { default as loginToECR } from './loginToECR';
|
|
4
4
|
export { default as tagECRImage } from './tagECRImage';
|
|
5
5
|
export { default as parseECRImageUri } from './parseECRImageUri';
|
|
6
|
+
export { default as parseECRRepositoryHostname } from './parseECRRepositoryHostname';
|
|
6
7
|
export { default as upsertECRRepository } from './upsertECRRepository';
|
|
8
|
+
export { default as checkECRRepositoryPolicy } from './checkECRRepositoryPolicy';
|
package/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "checkECRRepositoryPolicy", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _checkECRRepositoryPolicy["default"];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
8
13
|
Object.defineProperty(exports, "copyECRImage", {
|
|
9
14
|
enumerable: true,
|
|
10
15
|
get: function get() {
|
|
@@ -29,6 +34,12 @@ Object.defineProperty(exports, "parseECRImageUri", {
|
|
|
29
34
|
return _parseECRImageUri["default"];
|
|
30
35
|
}
|
|
31
36
|
});
|
|
37
|
+
Object.defineProperty(exports, "parseECRRepositoryHostname", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _parseECRRepositoryHostname["default"];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
32
43
|
Object.defineProperty(exports, "tagECRImage", {
|
|
33
44
|
enumerable: true,
|
|
34
45
|
get: function get() {
|
|
@@ -41,15 +52,11 @@ Object.defineProperty(exports, "upsertECRRepository", {
|
|
|
41
52
|
return _upsertECRRepository["default"];
|
|
42
53
|
}
|
|
43
54
|
});
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
var _parseECRImageUri = _interopRequireDefault(require("./parseECRImageUri"));
|
|
54
|
-
|
|
55
|
-
var _upsertECRRepository = _interopRequireDefault(require("./upsertECRRepository"));
|
|
55
|
+
var _copyECRImage = _interopRequireDefault(require("./copyECRImage.js"));
|
|
56
|
+
var _ecrImageExists = _interopRequireDefault(require("./ecrImageExists.js"));
|
|
57
|
+
var _loginToECR = _interopRequireDefault(require("./loginToECR.js"));
|
|
58
|
+
var _tagECRImage = _interopRequireDefault(require("./tagECRImage.js"));
|
|
59
|
+
var _parseECRImageUri = _interopRequireDefault(require("./parseECRImageUri.js"));
|
|
60
|
+
var _parseECRRepositoryHostname = _interopRequireDefault(require("./parseECRRepositoryHostname.js"));
|
|
61
|
+
var _upsertECRRepository = _interopRequireDefault(require("./upsertECRRepository.js"));
|
|
62
|
+
var _checkECRRepositoryPolicy = _interopRequireDefault(require("./checkECRRepositoryPolicy.js"));
|
package/index.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as copyECRImage } from "./copyECRImage.mjs";
|
|
2
|
+
export { default as ecrImageExists } from "./ecrImageExists.mjs";
|
|
3
|
+
export { default as loginToECR } from "./loginToECR.mjs";
|
|
4
|
+
export { default as tagECRImage } from "./tagECRImage.mjs";
|
|
5
|
+
export { default as parseECRImageUri } from "./parseECRImageUri.mjs";
|
|
6
|
+
export { default as parseECRRepositoryHostname } from "./parseECRRepositoryHostname.mjs";
|
|
7
|
+
export { default as upsertECRRepository } from "./upsertECRRepository.mjs";
|
|
8
|
+
export { default as checkECRRepositoryPolicy } from "./checkECRRepositoryPolicy.mjs";
|
package/loginToECR.js
CHANGED
|
@@ -1,92 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = loginToECR;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
|
|
16
11
|
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
17
|
-
|
|
18
12
|
var _promisifyChildProcess = require("promisify-child-process");
|
|
19
|
-
|
|
20
13
|
var _base64Js = _interopRequireDefault(require("base64-js"));
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* @prettier
|
|
24
16
|
*/
|
|
25
17
|
function loginToECR(_x) {
|
|
26
18
|
return _loginToECR.apply(this, arguments);
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
function _loginToECR() {
|
|
30
21
|
_loginToECR = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
|
|
31
22
|
var ecr, awsConfig, _yield$ecr$getAuthori, authorizationData, _ref2, authorizationToken, proxyEndpoint, decoded, _decoded$split, _decoded$split2, user, password, child;
|
|
32
|
-
|
|
33
23
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
34
|
-
while (1) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw new Error('expected child.stdin to be defined');
|
|
77
|
-
|
|
78
|
-
case 16:
|
|
79
|
-
child.stdin.write(password);
|
|
80
|
-
child.stdin.end();
|
|
81
|
-
_context.next = 20;
|
|
82
|
-
return child;
|
|
83
|
-
|
|
84
|
-
case 20:
|
|
85
|
-
case "end":
|
|
86
|
-
return _context.stop();
|
|
87
|
-
}
|
|
24
|
+
while (1) switch (_context.prev = _context.next) {
|
|
25
|
+
case 0:
|
|
26
|
+
ecr = _ref.ecr, awsConfig = _ref.awsConfig;
|
|
27
|
+
if (!ecr) ecr = new _awsSdk["default"].ECR(awsConfig);
|
|
28
|
+
_context.next = 4;
|
|
29
|
+
return ecr.getAuthorizationToken().promise();
|
|
30
|
+
case 4:
|
|
31
|
+
_yield$ecr$getAuthori = _context.sent;
|
|
32
|
+
authorizationData = _yield$ecr$getAuthori.authorizationData;
|
|
33
|
+
_ref2 = (authorizationData === null || authorizationData === void 0 ? void 0 : authorizationData[0]) || {}, authorizationToken = _ref2.authorizationToken, proxyEndpoint = _ref2.proxyEndpoint;
|
|
34
|
+
if (authorizationToken) {
|
|
35
|
+
_context.next = 9;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
throw new Error('failed to get authorizationToken from ECR');
|
|
39
|
+
case 9:
|
|
40
|
+
if (proxyEndpoint) {
|
|
41
|
+
_context.next = 11;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
throw new Error('failed to get proxyEndpoint from ECR');
|
|
45
|
+
case 11:
|
|
46
|
+
// this is silly...
|
|
47
|
+
decoded = new Buffer(_base64Js["default"].toByteArray(authorizationToken)).toString('utf8');
|
|
48
|
+
_decoded$split = decoded.split(/:/), _decoded$split2 = (0, _slicedToArray2["default"])(_decoded$split, 2), user = _decoded$split2[0], password = _decoded$split2[1];
|
|
49
|
+
child = (0, _promisifyChildProcess.spawn)('docker', ['login', '-u', user, '--password-stdin', proxyEndpoint], {
|
|
50
|
+
stdio: 'pipe',
|
|
51
|
+
encoding: 'utf8'
|
|
52
|
+
});
|
|
53
|
+
if (child.stdin) {
|
|
54
|
+
_context.next = 16;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
throw new Error('expected child.stdin to be defined');
|
|
58
|
+
case 16:
|
|
59
|
+
child.stdin.write(password);
|
|
60
|
+
child.stdin.end();
|
|
61
|
+
_context.next = 20;
|
|
62
|
+
return child;
|
|
63
|
+
case 20:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context.stop();
|
|
88
66
|
}
|
|
89
67
|
}, _callee);
|
|
90
68
|
}));
|
|
91
69
|
return _loginToECR.apply(this, arguments);
|
|
92
|
-
}
|
|
70
|
+
}
|
|
71
|
+
module.exports = exports.default;
|
package/loginToECR.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @prettier
|
|
3
|
+
*/
|
|
4
|
+
import AWS from 'aws-sdk';
|
|
5
|
+
import { spawn } from 'promisify-child-process';
|
|
6
|
+
import base64 from 'base64-js';
|
|
7
|
+
export default async function loginToECR({
|
|
8
|
+
ecr,
|
|
9
|
+
awsConfig
|
|
10
|
+
}) {
|
|
11
|
+
if (!ecr) ecr = new AWS.ECR(awsConfig);
|
|
12
|
+
const {
|
|
13
|
+
authorizationData
|
|
14
|
+
} = await ecr.getAuthorizationToken().promise();
|
|
15
|
+
const {
|
|
16
|
+
authorizationToken,
|
|
17
|
+
proxyEndpoint
|
|
18
|
+
} = (authorizationData === null || authorizationData === void 0 ? void 0 : authorizationData[0]) || {};
|
|
19
|
+
if (!authorizationToken) {
|
|
20
|
+
throw new Error('failed to get authorizationToken from ECR');
|
|
21
|
+
}
|
|
22
|
+
if (!proxyEndpoint) {
|
|
23
|
+
throw new Error('failed to get proxyEndpoint from ECR');
|
|
24
|
+
}
|
|
25
|
+
// this is silly...
|
|
26
|
+
const decoded = new Buffer(base64.toByteArray(authorizationToken)).toString('utf8');
|
|
27
|
+
const [user, password] = decoded.split(/:/);
|
|
28
|
+
const child = spawn('docker', ['login', '-u', user, '--password-stdin', proxyEndpoint], {
|
|
29
|
+
stdio: 'pipe',
|
|
30
|
+
encoding: 'utf8'
|
|
31
|
+
});
|
|
32
|
+
if (!child.stdin) {
|
|
33
|
+
throw new Error('expected child.stdin to be defined');
|
|
34
|
+
}
|
|
35
|
+
child.stdin.write(password);
|
|
36
|
+
child.stdin.end();
|
|
37
|
+
await child;
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,71 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcoreio/aws-ecr-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "utilities for working with AWS Elastic Container Registry",
|
|
5
|
-
"main": "index.js",
|
|
6
5
|
"sideEffects": false,
|
|
7
|
-
"scripts": {
|
|
8
|
-
"lint": "eslint $npm_package_config_lint",
|
|
9
|
-
"lint:fix": "eslint $npm_package_config_lint",
|
|
10
|
-
"prettier": "prettier --write $npm_package_config_prettier",
|
|
11
|
-
"prettier:check": "prettier --list-different $npm_package_config_prettier",
|
|
12
|
-
"tsc": "tsc",
|
|
13
|
-
"tsc:watch": "npm run tsc -- --watch",
|
|
14
|
-
"clean": "rimraf es lib $(cd src; ls) *.js *.d.ts *.js.flow",
|
|
15
|
-
"build": "npm run clean && npm run build:types && npm run build:js",
|
|
16
|
-
"build:types": "tsc -p tsconfig.build.json && tsc -p tsconfig.build.json --outDir es && copy 'src/**/*.js.flow' . && copy 'src/**/*.js.flow' es",
|
|
17
|
-
"build:js": "babel src --out-dir es --extensions \".ts\" --source-maps inline && cross-env BABEL_ENV=es5 babel src --out-dir . --extensions \".ts\"",
|
|
18
|
-
"test": "cross-env NODE_ENV=test BABEL_ENV=es5 mocha $npm_package_config_mocha && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --reporter=text mocha $npm_package_config_mocha",
|
|
19
|
-
"test:watch": "cross-env NODE_ENV=test BABEL_ENV=test mocha $npm_package_config_mocha --watch",
|
|
20
|
-
"test:debug": "cross-env NODE_ENV=test BABEL_ENV=test mocha --inspect-brk $npm_package_config_mocha",
|
|
21
|
-
"codecov": "nyc report --reporter=text-lcov > coverage.lcov; codecov",
|
|
22
|
-
"prepublishOnly": "npm run clean && npm run prettier:check && npm run lint && flow && npm test && npm run build",
|
|
23
|
-
"open:coverage": "open coverage/lcov-report/index.html",
|
|
24
|
-
"semantic-release": "semantic-release"
|
|
25
|
-
},
|
|
26
|
-
"config": {
|
|
27
|
-
"lint": "--cache --ext .js,.ts src test",
|
|
28
|
-
"mocha": "--extension js --extension ts test/configure.js 'src/**/*.spec.ts' 'test/**/*.ts'",
|
|
29
|
-
"prettier": ".babelrc.js *.{json,md} {src,test}/**/*.{js,ts,flow}",
|
|
30
|
-
"commitizen": {
|
|
31
|
-
"path": "cz-conventional-changelog"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"husky": {
|
|
35
|
-
"hooks": {
|
|
36
|
-
"pre-commit": "lint-staged && npm run lint && npm run tsc && flow",
|
|
37
|
-
"commit-msg": "commitlint -e $GIT_PARAMS",
|
|
38
|
-
"pre-push": "npm test"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"lint-staged": {
|
|
42
|
-
"*.{js,ts,json,css,md,flow}": [
|
|
43
|
-
"prettier --write"
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
"commitlint": {
|
|
47
|
-
"extends": [
|
|
48
|
-
"@jedwards1211/commitlint-config"
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
"prettier": {
|
|
52
|
-
"semi": false,
|
|
53
|
-
"singleQuote": true,
|
|
54
|
-
"trailingComma": "es5"
|
|
55
|
-
},
|
|
56
|
-
"nyc": {
|
|
57
|
-
"include": [
|
|
58
|
-
"src/**/*.ts"
|
|
59
|
-
],
|
|
60
|
-
"exclude": [
|
|
61
|
-
"src/**/*.spec.ts"
|
|
62
|
-
],
|
|
63
|
-
"require": [
|
|
64
|
-
"@babel/register"
|
|
65
|
-
],
|
|
66
|
-
"sourceMap": false,
|
|
67
|
-
"instrument": false
|
|
68
|
-
},
|
|
69
6
|
"repository": {
|
|
70
7
|
"type": "git",
|
|
71
8
|
"url": "https://github.com/jcoreio/aws-ecr-utils.git"
|
|
@@ -81,48 +18,32 @@
|
|
|
81
18
|
"url": "https://github.com/jcoreio/aws-ecr-utils/issues"
|
|
82
19
|
},
|
|
83
20
|
"homepage": "https://github.com/jcoreio/aws-ecr-utils#readme",
|
|
84
|
-
"devDependencies": {
|
|
85
|
-
"@babel/cli": "^7.15.7",
|
|
86
|
-
"@babel/core": "^7.15.5",
|
|
87
|
-
"@babel/plugin-proposal-export-default-from": "^7.14.5",
|
|
88
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.14.5",
|
|
89
|
-
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
90
|
-
"@babel/preset-env": "^7.15.6",
|
|
91
|
-
"@babel/preset-typescript": "^7.15.0",
|
|
92
|
-
"@babel/register": "^7.15.3",
|
|
93
|
-
"@commitlint/cli": "^13.2.0",
|
|
94
|
-
"@commitlint/config-conventional": "^13.2.0",
|
|
95
|
-
"@jedwards1211/commitlint-config": "^1.0.2",
|
|
96
|
-
"@jedwards1211/eslint-config": "^2.0.2",
|
|
97
|
-
"@jedwards1211/eslint-config-typescript": "^2.0.2",
|
|
98
|
-
"@types/chai": "^4.2.22",
|
|
99
|
-
"@types/mocha": "^9.0.0",
|
|
100
|
-
"@types/node": "^16.10.2",
|
|
101
|
-
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
102
|
-
"@typescript-eslint/parser": "^4.32.0",
|
|
103
|
-
"@typescript-eslint/typescript-estree": "^4.32.0",
|
|
104
|
-
"babel-plugin-istanbul": "^6.0.0",
|
|
105
|
-
"chai": "^4.3.4",
|
|
106
|
-
"codecov": "^3.8.3",
|
|
107
|
-
"copy": "^0.3.2",
|
|
108
|
-
"cross-env": "^7.0.3",
|
|
109
|
-
"eslint": "^7.32.0",
|
|
110
|
-
"eslint-config-prettier": "^8.3.0",
|
|
111
|
-
"flow-bin": "^0.161.0",
|
|
112
|
-
"husky": "^7.0.2",
|
|
113
|
-
"lint-staged": "^11.1.2",
|
|
114
|
-
"mocha": "^9.1.2",
|
|
115
|
-
"nyc": "^15.1.0",
|
|
116
|
-
"prettier": "^2.4.1",
|
|
117
|
-
"prettier-eslint": "^13.0.0",
|
|
118
|
-
"rimraf": "^3.0.2",
|
|
119
|
-
"semantic-release": "^18.0.0",
|
|
120
|
-
"typescript": "^4.4.3"
|
|
121
|
-
},
|
|
122
21
|
"dependencies": {
|
|
123
|
-
"@babel/runtime": "^7.
|
|
22
|
+
"@babel/runtime": "^7.18.6",
|
|
124
23
|
"aws-sdk": "^2.1070.0",
|
|
125
24
|
"base64-js": "^1.5.1",
|
|
25
|
+
"inquirer": "^8.2.6",
|
|
26
|
+
"is-interactive": "^1.0.0",
|
|
126
27
|
"promisify-child-process": "^4.1.1"
|
|
127
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"main": "index.js",
|
|
30
|
+
"module": "index.mjs",
|
|
31
|
+
"types": "index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./index.d.ts",
|
|
35
|
+
"require": "./index.js",
|
|
36
|
+
"default": "./index.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json",
|
|
39
|
+
"./*": {
|
|
40
|
+
"types": "./*.d.ts",
|
|
41
|
+
"require": "./*.js",
|
|
42
|
+
"default": "./*.mjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=16"
|
|
47
|
+
},
|
|
48
|
+
"packageManager": "pnpm@8.3.1"
|
|
128
49
|
}
|
package/parseECRImageUri.d.ts
CHANGED
package/parseECRImageUri.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = parseECRImageUri;
|
|
9
|
-
|
|
10
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
9
|
function parseECRImageUri(imageUri) {
|
|
13
10
|
var match = /(\d+)\.dkr\.ecr\.([^.]+)\.amazonaws\.com\/([^:]+):(.+)/.exec(imageUri);
|
|
14
11
|
if (!match) throw new Error("invalid imageUri: ".concat(imageUri));
|
|
15
|
-
|
|
16
12
|
var _match = (0, _slicedToArray2["default"])(match, 5),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
registryId = _match[1],
|
|
14
|
+
region = _match[2],
|
|
15
|
+
repositoryName = _match[3],
|
|
16
|
+
imageTag = _match[4];
|
|
22
17
|
return {
|
|
23
18
|
registryId: registryId,
|
|
24
19
|
region: region,
|
|
25
20
|
repositoryName: repositoryName,
|
|
26
21
|
imageTag: imageTag
|
|
27
22
|
};
|
|
28
|
-
}
|
|
23
|
+
}
|
|
24
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function parseECRImageUri(imageUri) {
|
|
2
|
+
const match = /(\d+)\.dkr\.ecr\.([^.]+)\.amazonaws\.com\/([^:]+):(.+)/.exec(imageUri);
|
|
3
|
+
if (!match) throw new Error(`invalid imageUri: ${imageUri}`);
|
|
4
|
+
const [, registryId, region, repositoryName, imageTag] = match;
|
|
5
|
+
return {
|
|
6
|
+
registryId,
|
|
7
|
+
region,
|
|
8
|
+
repositoryName,
|
|
9
|
+
imageTag
|
|
10
|
+
};
|
|
11
|
+
}
|