@jcoreio/aws-ecr-utils 1.1.1 → 1.3.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.
Files changed (56) hide show
  1. package/ImageManifestSchema.d.ts +58 -0
  2. package/ImageManifestSchema.js +22 -0
  3. package/ImageManifestSchema.mjs +15 -0
  4. package/checkECRImageAccess.d.ts +18 -0
  5. package/checkECRImageAccess.js +180 -0
  6. package/checkECRImageAccess.mjs +133 -0
  7. package/checkECRRepositoryPolicy.d.ts +20 -0
  8. package/checkECRRepositoryPolicy.js +132 -0
  9. package/checkECRRepositoryPolicy.mjs +100 -0
  10. package/copyECRImage.js +79 -104
  11. package/copyECRImage.mjs +67 -0
  12. package/ecrImageExists.js +51 -74
  13. package/ecrImageExists.mjs +31 -0
  14. package/formatECRImageUri.d.ts +6 -0
  15. package/formatECRImageUri.js +20 -0
  16. package/formatECRImageUri.mjs +13 -0
  17. package/formatECRRepositoryHostname.d.ts +5 -0
  18. package/formatECRRepositoryHostname.js +13 -0
  19. package/formatECRRepositoryHostname.mjs +7 -0
  20. package/index.d.ts +5 -0
  21. package/index.js +41 -13
  22. package/index.mjs +11 -0
  23. package/loginToECR.js +44 -65
  24. package/loginToECR.mjs +38 -0
  25. package/package.json +27 -105
  26. package/parseECRImageUri.d.ts +3 -2
  27. package/parseECRImageUri.js +6 -10
  28. package/parseECRImageUri.mjs +11 -0
  29. package/parseECRRepositoryHostname.d.ts +6 -0
  30. package/parseECRRepositoryHostname.js +22 -0
  31. package/parseECRRepositoryHostname.mjs +10 -0
  32. package/tagECRImage.js +81 -115
  33. package/tagECRImage.mjs +50 -0
  34. package/upsertECRRepository.js +45 -64
  35. package/upsertECRRepository.mjs +33 -0
  36. package/es/copyECRImage.d.ts +0 -13
  37. package/es/copyECRImage.js +0 -76
  38. package/es/ecrImageExists.d.ts +0 -9
  39. package/es/ecrImageExists.js +0 -45
  40. package/es/index.d.ts +0 -6
  41. package/es/index.js +0 -56
  42. package/es/loginToECR.d.ts +0 -8
  43. package/es/loginToECR.js +0 -56
  44. package/es/parseECRImageUri.d.ts +0 -6
  45. package/es/parseECRImageUri.js +0 -19
  46. package/es/tagECRImage.d.ts +0 -10
  47. package/es/tagECRImage.js +0 -65
  48. package/es/upsertECRRepository.d.ts +0 -6
  49. package/es/upsertECRRepository.js +0 -45
  50. /package/{es/copyECRImage.js.flow → copyECRImage.mjs.flow} +0 -0
  51. /package/{es/ecrImageExists.js.flow → ecrImageExists.mjs.flow} +0 -0
  52. /package/{es/index.js.flow → index.mjs.flow} +0 -0
  53. /package/{es/loginToECR.js.flow → loginToECR.mjs.flow} +0 -0
  54. /package/{es/parseECRImageUri.js.flow → parseECRImageUri.mjs.flow} +0 -0
  55. /package/{es/tagECRImage.js.flow → tagECRImage.mjs.flow} +0 -0
  56. /package/{es/upsertECRRepository.js.flow → upsertECRRepository.mjs.flow} +0 -0
package/copyECRImage.js CHANGED
@@ -1,127 +1,102 @@
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"] = copyECRImage;
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 _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
11
  var _promisifyChildProcess = require("promisify-child-process");
17
-
18
- var _loginToECR = _interopRequireDefault(require("./loginToECR"));
19
-
20
- var _ecrImageExists = _interopRequireDefault(require("./ecrImageExists"));
21
-
22
- var _parseECRImageUri3 = _interopRequireDefault(require("./parseECRImageUri"));
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
25
-
26
- 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; }
27
-
12
+ var _loginToECR = _interopRequireDefault(require("./loginToECR.js"));
13
+ var _ecrImageExists = _interopRequireDefault(require("./ecrImageExists.js"));
14
+ var _parseECRImageUri3 = _interopRequireDefault(require("./parseECRImageUri.js"));
15
+ 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; }
16
+ 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; }
28
17
  function copyECRImage(_x) {
29
18
  return _copyECRImage.apply(this, arguments);
30
19
  }
31
-
32
20
  function _copyECRImage() {
33
21
  _copyECRImage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
34
22
  var from, to, srcRepositoryUri, repositoryUri, _parseECRImageUri, fromRegion, _parseECRImageUri2, toRegion, repositoryName, imageTag;
35
-
36
23
  return _regenerator["default"].wrap(function _callee$(_context) {
37
- while (1) {
38
- switch (_context.prev = _context.next) {
39
- case 0:
40
- from = _ref.from, to = _ref.to;
41
-
42
- if (!(from.imageUri === to.imageUri)) {
43
- _context.next = 3;
44
- break;
45
- }
46
-
47
- return _context.abrupt("return");
48
-
49
- case 3:
50
- srcRepositoryUri = from.imageUri.replace(/:.+/, '');
51
- repositoryUri = to.imageUri.replace(/:.+/, '');
52
- _parseECRImageUri = (0, _parseECRImageUri3["default"])(from.imageUri), fromRegion = _parseECRImageUri.region;
53
- _parseECRImageUri2 = (0, _parseECRImageUri3["default"])(to.imageUri), toRegion = _parseECRImageUri2.region, repositoryName = _parseECRImageUri2.repositoryName, imageTag = _parseECRImageUri2.imageTag;
54
- _context.next = 9;
55
- return (0, _ecrImageExists["default"])({
56
- awsConfig: _objectSpread(_objectSpread({}, to.awsConfig), {}, {
57
- region: toRegion
58
- }),
59
- ecr: to.ecr,
60
- repositoryName: repositoryName,
61
- imageTag: imageTag
62
- });
63
-
64
- case 9:
65
- if (!_context.sent) {
66
- _context.next = 13;
67
- break;
68
- }
69
-
70
- // eslint-disable-next-line no-console
71
- console.error("Clarity image already exists in your ECR: ".concat(repositoryName, ":").concat(imageTag));
72
- _context.next = 27;
24
+ while (1) switch (_context.prev = _context.next) {
25
+ case 0:
26
+ from = _ref.from, to = _ref.to;
27
+ if (!(from.imageUri === to.imageUri)) {
28
+ _context.next = 3;
73
29
  break;
74
-
75
- case 13:
76
- // eslint-disable-next-line no-console
77
- console.error("Logging into source ECR: ".concat(srcRepositoryUri.replace(/\/.*/, ''), "..."));
78
- _context.next = 16;
79
- return (0, _loginToECR["default"])({
80
- ecr: from.ecr,
81
- awsConfig: _objectSpread(_objectSpread({}, from.awsConfig), {}, {
82
- region: fromRegion
83
- })
84
- });
85
-
86
- case 16:
87
- // eslint-disable-next-line no-console
88
- console.error("Pulling ".concat(from.imageUri, "..."));
89
- _context.next = 19;
90
- return (0, _promisifyChildProcess.spawn)('docker', ['pull', from.imageUri], {
91
- stdio: 'inherit'
92
- });
93
-
94
- case 19:
95
- // eslint-disable-next-line no-console
96
- console.error("Logging into dest ECR: ".concat(repositoryUri.replace(/\/.*/, ''), "..."));
97
- _context.next = 22;
98
- return (0, _loginToECR["default"])({
99
- ecr: to.ecr,
100
- awsConfig: _objectSpread(_objectSpread({}, to.awsConfig), {}, {
101
- region: toRegion
102
- })
103
- });
104
-
105
- case 22:
106
- // eslint-disable-next-line no-console
107
- console.error("Pushing ".concat(to.imageUri, "..."));
108
- _context.next = 25;
109
- return (0, _promisifyChildProcess.spawn)('docker', ['tag', from.imageUri, to.imageUri], {
110
- stdio: 'inherit'
111
- });
112
-
113
- case 25:
114
- _context.next = 27;
115
- return (0, _promisifyChildProcess.spawn)('docker', ['push', to.imageUri], {
116
- stdio: 'inherit'
117
- });
118
-
119
- case 27:
120
- case "end":
121
- return _context.stop();
122
- }
30
+ }
31
+ return _context.abrupt("return");
32
+ case 3:
33
+ srcRepositoryUri = from.imageUri.replace(/:.+/, '');
34
+ repositoryUri = to.imageUri.replace(/:.+/, '');
35
+ _parseECRImageUri = (0, _parseECRImageUri3["default"])(from.imageUri), fromRegion = _parseECRImageUri.region;
36
+ _parseECRImageUri2 = (0, _parseECRImageUri3["default"])(to.imageUri), toRegion = _parseECRImageUri2.region, repositoryName = _parseECRImageUri2.repositoryName, imageTag = _parseECRImageUri2.imageTag;
37
+ _context.next = 9;
38
+ return (0, _ecrImageExists["default"])({
39
+ awsConfig: _objectSpread(_objectSpread({}, to.awsConfig), {}, {
40
+ region: toRegion
41
+ }),
42
+ ecr: to.ecr,
43
+ repositoryName: repositoryName,
44
+ imageTag: imageTag
45
+ });
46
+ case 9:
47
+ if (!_context.sent) {
48
+ _context.next = 13;
49
+ break;
50
+ }
51
+ // eslint-disable-next-line no-console
52
+ console.error("Clarity image already exists in your ECR: ".concat(repositoryName, ":").concat(imageTag));
53
+ _context.next = 27;
54
+ break;
55
+ case 13:
56
+ // eslint-disable-next-line no-console
57
+ console.error("Logging into source ECR: ".concat(srcRepositoryUri.replace(/\/.*/, ''), "..."));
58
+ _context.next = 16;
59
+ return (0, _loginToECR["default"])({
60
+ ecr: from.ecr,
61
+ awsConfig: _objectSpread(_objectSpread({}, from.awsConfig), {}, {
62
+ region: fromRegion
63
+ })
64
+ });
65
+ case 16:
66
+ // eslint-disable-next-line no-console
67
+ console.error("Pulling ".concat(from.imageUri, "..."));
68
+ _context.next = 19;
69
+ return (0, _promisifyChildProcess.spawn)('docker', ['pull', from.imageUri], {
70
+ stdio: 'inherit'
71
+ });
72
+ case 19:
73
+ // eslint-disable-next-line no-console
74
+ console.error("Logging into dest ECR: ".concat(repositoryUri.replace(/\/.*/, ''), "..."));
75
+ _context.next = 22;
76
+ return (0, _loginToECR["default"])({
77
+ ecr: to.ecr,
78
+ awsConfig: _objectSpread(_objectSpread({}, to.awsConfig), {}, {
79
+ region: toRegion
80
+ })
81
+ });
82
+ case 22:
83
+ // eslint-disable-next-line no-console
84
+ console.error("Pushing ".concat(to.imageUri, "..."));
85
+ _context.next = 25;
86
+ return (0, _promisifyChildProcess.spawn)('docker', ['tag', from.imageUri, to.imageUri], {
87
+ stdio: 'inherit'
88
+ });
89
+ case 25:
90
+ _context.next = 27;
91
+ return (0, _promisifyChildProcess.spawn)('docker', ['push', to.imageUri], {
92
+ stdio: 'inherit'
93
+ });
94
+ case 27:
95
+ case "end":
96
+ return _context.stop();
123
97
  }
124
98
  }, _callee);
125
99
  }));
126
100
  return _copyECRImage.apply(this, arguments);
127
- }
101
+ }
102
+ module.exports = exports.default;
@@ -0,0 +1,67 @@
1
+ import { spawn } from 'promisify-child-process';
2
+ import loginToECR from "./loginToECR.mjs";
3
+ import ecrImageExists from "./ecrImageExists.mjs";
4
+ import parseECRImageUri from "./parseECRImageUri.mjs";
5
+ export default async function copyECRImage({
6
+ from,
7
+ to
8
+ }) {
9
+ if (from.imageUri === to.imageUri) return;
10
+ const srcRepositoryUri = from.imageUri.replace(/:.+/, '');
11
+ const repositoryUri = to.imageUri.replace(/:.+/, '');
12
+ const {
13
+ region: fromRegion
14
+ } = parseECRImageUri(from.imageUri);
15
+ const {
16
+ region: toRegion,
17
+ repositoryName,
18
+ imageTag
19
+ } = parseECRImageUri(to.imageUri);
20
+ if (await ecrImageExists({
21
+ awsConfig: {
22
+ ...to.awsConfig,
23
+ region: toRegion
24
+ },
25
+ ecr: to.ecr,
26
+ repositoryName,
27
+ imageTag
28
+ })) {
29
+ // eslint-disable-next-line no-console
30
+ console.error(`Clarity image already exists in your ECR: ${repositoryName}:${imageTag}`);
31
+ } else {
32
+ // eslint-disable-next-line no-console
33
+ console.error(`Logging into source ECR: ${srcRepositoryUri.replace(/\/.*/, '')}...`);
34
+ await loginToECR({
35
+ ecr: from.ecr,
36
+ awsConfig: {
37
+ ...from.awsConfig,
38
+ region: fromRegion
39
+ }
40
+ });
41
+
42
+ // eslint-disable-next-line no-console
43
+ console.error(`Pulling ${from.imageUri}...`);
44
+ await spawn('docker', ['pull', from.imageUri], {
45
+ stdio: 'inherit'
46
+ });
47
+
48
+ // eslint-disable-next-line no-console
49
+ console.error(`Logging into dest ECR: ${repositoryUri.replace(/\/.*/, '')}...`);
50
+ await loginToECR({
51
+ ecr: to.ecr,
52
+ awsConfig: {
53
+ ...to.awsConfig,
54
+ region: toRegion
55
+ }
56
+ });
57
+
58
+ // eslint-disable-next-line no-console
59
+ console.error(`Pushing ${to.imageUri}...`);
60
+ await spawn('docker', ['tag', from.imageUri, to.imageUri], {
61
+ stdio: 'inherit'
62
+ });
63
+ await spawn('docker', ['push', to.imageUri], {
64
+ stdio: 'inherit'
65
+ });
66
+ }
67
+ }
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
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
- switch (_context.prev = _context.next) {
35
- case 0:
36
- ecr = _ref.ecr, awsConfig = _ref.awsConfig, imageUri = _ref.imageUri, registryId = _ref.registryId, repositoryName = _ref.repositoryName, imageTag = _ref.imageTag;
37
-
38
- if (!imageUri) {
39
- _context.next = 10;
40
- break;
41
- }
42
-
43
- match = /(\d+)\.dkr\.ecr\.(.+?)\.amazonaws\.com\/(.+?):(.+)/.exec(imageUri);
44
-
45
- if (match) {
46
- _context.next = 5;
47
- break;
48
- }
49
-
50
- throw new Error("failed to parse imageUri: ".concat(imageUri));
51
-
52
- case 5:
53
- _match = (0, _slicedToArray2["default"])(match, 5);
54
- registryId = _match[1];
55
- region = _match[2];
56
- repositoryName = _match[3];
57
- imageTag = _match[4];
58
-
59
- case 10:
60
- if (!region) region = awsConfig === null || awsConfig === void 0 ? void 0 : awsConfig.region;
61
- if (!ecr) ecr = new _awsSdk["default"].ECR(_objectSpread(_objectSpread({}, awsConfig), {}, {
62
- region: region
63
- }));
64
-
65
- if (!(!repositoryName || !imageTag)) {
66
- _context.next = 14;
67
- break;
68
- }
69
-
70
- throw new Error("missing repositoryName/imageTag or imageUri");
71
-
72
- case 14:
73
- _context.next = 16;
74
- return ecr.describeImages({
75
- registryId: registryId,
76
- repositoryName: repositoryName,
77
- imageIds: [{
78
- imageTag: imageTag
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
+ }
@@ -0,0 +1,6 @@
1
+ export default function formatECRImageUri({ registryId, region, repositoryName, imageTag, }: {
2
+ registryId: AWS.ECR.RegistryId;
3
+ region: string;
4
+ repositoryName: AWS.ECR.RepositoryName;
5
+ imageTag: AWS.ECR.ImageTag;
6
+ }): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = formatECRImageUri;
8
+ var _formatECRRepositoryHostname = _interopRequireDefault(require("./formatECRRepositoryHostname.js"));
9
+ function formatECRImageUri(_ref) {
10
+ var registryId = _ref.registryId,
11
+ region = _ref.region,
12
+ repositoryName = _ref.repositoryName,
13
+ imageTag = _ref.imageTag;
14
+ return "".concat((0, _formatECRRepositoryHostname["default"])({
15
+ registryId: registryId,
16
+ region: region,
17
+ repositoryName: repositoryName
18
+ }), ":").concat(imageTag);
19
+ }
20
+ module.exports = exports.default;
@@ -0,0 +1,13 @@
1
+ import formatECRRepositoryHostname from "./formatECRRepositoryHostname.mjs";
2
+ export default function formatECRImageUri({
3
+ registryId,
4
+ region,
5
+ repositoryName,
6
+ imageTag
7
+ }) {
8
+ return `${formatECRRepositoryHostname({
9
+ registryId,
10
+ region,
11
+ repositoryName
12
+ })}:${imageTag}`;
13
+ }
@@ -0,0 +1,5 @@
1
+ export default function formatECRRepositoryHostname({ registryId, region, repositoryName, }: {
2
+ registryId: AWS.ECR.RegistryId;
3
+ region: string;
4
+ repositoryName: AWS.ECR.RepositoryName;
5
+ }): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = formatECRRepositoryHostname;
7
+ function formatECRRepositoryHostname(_ref) {
8
+ var registryId = _ref.registryId,
9
+ region = _ref.region,
10
+ repositoryName = _ref.repositoryName;
11
+ return "".concat(registryId, ".dkr.ecr.").concat(region, ".amazonaws.com/").concat(repositoryName);
12
+ }
13
+ module.exports = exports.default;
@@ -0,0 +1,7 @@
1
+ export default function formatECRRepositoryHostname({
2
+ registryId,
3
+ region,
4
+ repositoryName
5
+ }) {
6
+ return `${registryId}.dkr.ecr.${region}.amazonaws.com/${repositoryName}`;
7
+ }
package/index.d.ts CHANGED
@@ -3,4 +3,9 @@ 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';
9
+ export { default as checkECRImageAccess } from './checkECRImageAccess';
10
+ export { default as formatECRRepositoryHostname } from './formatECRRepositoryHostname';
11
+ export { default as formatECRImageUri } from './formatECRImageUri';
package/index.js CHANGED
@@ -1,10 +1,21 @@
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, "checkECRImageAccess", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _checkECRImageAccess["default"];
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "checkECRRepositoryPolicy", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _checkECRRepositoryPolicy["default"];
17
+ }
18
+ });
8
19
  Object.defineProperty(exports, "copyECRImage", {
9
20
  enumerable: true,
10
21
  get: function get() {
@@ -17,6 +28,18 @@ Object.defineProperty(exports, "ecrImageExists", {
17
28
  return _ecrImageExists["default"];
18
29
  }
19
30
  });
31
+ Object.defineProperty(exports, "formatECRImageUri", {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _formatECRImageUri["default"];
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "formatECRRepositoryHostname", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _formatECRRepositoryHostname["default"];
41
+ }
42
+ });
20
43
  Object.defineProperty(exports, "loginToECR", {
21
44
  enumerable: true,
22
45
  get: function get() {
@@ -29,6 +52,12 @@ Object.defineProperty(exports, "parseECRImageUri", {
29
52
  return _parseECRImageUri["default"];
30
53
  }
31
54
  });
55
+ Object.defineProperty(exports, "parseECRRepositoryHostname", {
56
+ enumerable: true,
57
+ get: function get() {
58
+ return _parseECRRepositoryHostname["default"];
59
+ }
60
+ });
32
61
  Object.defineProperty(exports, "tagECRImage", {
33
62
  enumerable: true,
34
63
  get: function get() {
@@ -41,15 +70,14 @@ Object.defineProperty(exports, "upsertECRRepository", {
41
70
  return _upsertECRRepository["default"];
42
71
  }
43
72
  });
44
-
45
- var _copyECRImage = _interopRequireDefault(require("./copyECRImage"));
46
-
47
- var _ecrImageExists = _interopRequireDefault(require("./ecrImageExists"));
48
-
49
- var _loginToECR = _interopRequireDefault(require("./loginToECR"));
50
-
51
- var _tagECRImage = _interopRequireDefault(require("./tagECRImage"));
52
-
53
- var _parseECRImageUri = _interopRequireDefault(require("./parseECRImageUri"));
54
-
55
- var _upsertECRRepository = _interopRequireDefault(require("./upsertECRRepository"));
73
+ var _copyECRImage = _interopRequireDefault(require("./copyECRImage.js"));
74
+ var _ecrImageExists = _interopRequireDefault(require("./ecrImageExists.js"));
75
+ var _loginToECR = _interopRequireDefault(require("./loginToECR.js"));
76
+ var _tagECRImage = _interopRequireDefault(require("./tagECRImage.js"));
77
+ var _parseECRImageUri = _interopRequireDefault(require("./parseECRImageUri.js"));
78
+ var _parseECRRepositoryHostname = _interopRequireDefault(require("./parseECRRepositoryHostname.js"));
79
+ var _upsertECRRepository = _interopRequireDefault(require("./upsertECRRepository.js"));
80
+ var _checkECRRepositoryPolicy = _interopRequireDefault(require("./checkECRRepositoryPolicy.js"));
81
+ var _checkECRImageAccess = _interopRequireDefault(require("./checkECRImageAccess.js"));
82
+ var _formatECRRepositoryHostname = _interopRequireDefault(require("./formatECRRepositoryHostname.js"));
83
+ var _formatECRImageUri = _interopRequireDefault(require("./formatECRImageUri.js"));
package/index.mjs ADDED
@@ -0,0 +1,11 @@
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";
9
+ export { default as checkECRImageAccess } from "./checkECRImageAccess.mjs";
10
+ export { default as formatECRRepositoryHostname } from "./formatECRRepositoryHostname.mjs";
11
+ export { default as formatECRImageUri } from "./formatECRImageUri.mjs";