@docker/actions-toolkit 0.1.0-beta.1 → 0.1.0-beta.10

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 (59) hide show
  1. package/README.md +46 -0
  2. package/lib/buildkit/buildkit.d.ts +32 -0
  3. package/lib/{buildkit.js → buildkit/buildkit.js} +28 -44
  4. package/lib/buildkit/buildkit.js.map +1 -0
  5. package/lib/buildkit/config.d.ts +23 -0
  6. package/lib/buildkit/config.js +46 -0
  7. package/lib/buildkit/config.js.map +1 -0
  8. package/lib/buildx/builder.d.ts +29 -0
  9. package/lib/{builder.js → buildx/builder.js} +15 -0
  10. package/lib/buildx/builder.js.map +1 -0
  11. package/lib/buildx/buildx.d.ts +43 -0
  12. package/lib/buildx/buildx.js +196 -0
  13. package/lib/buildx/buildx.js.map +1 -0
  14. package/lib/buildx/inputs.d.ts +35 -0
  15. package/lib/{buildx.js → buildx/inputs.js} +35 -106
  16. package/lib/buildx/inputs.js.map +1 -0
  17. package/lib/buildx/install.d.ts +35 -0
  18. package/lib/buildx/install.js +255 -0
  19. package/lib/buildx/install.js.map +1 -0
  20. package/lib/context.d.ts +15 -0
  21. package/lib/context.js +15 -0
  22. package/lib/context.js.map +1 -1
  23. package/lib/docker.d.ts +21 -1
  24. package/lib/docker.js +56 -21
  25. package/lib/docker.js.map +1 -1
  26. package/lib/dockerhub.d.ts +31 -0
  27. package/lib/dockerhub.js +156 -0
  28. package/lib/dockerhub.js.map +1 -0
  29. package/lib/git.d.ts +15 -0
  30. package/lib/git.js +15 -0
  31. package/lib/git.js.map +1 -1
  32. package/lib/github.d.ts +21 -10
  33. package/lib/github.js +72 -7
  34. package/lib/github.js.map +1 -1
  35. package/lib/toolkit.d.ts +23 -10
  36. package/lib/toolkit.js +25 -20
  37. package/lib/toolkit.js.map +1 -1
  38. package/lib/types/builder.d.ts +37 -0
  39. package/lib/types/builder.js +18 -0
  40. package/lib/types/builder.js.map +1 -0
  41. package/lib/types/buildx.d.ts +20 -0
  42. package/lib/types/buildx.js +18 -0
  43. package/lib/types/buildx.js.map +1 -0
  44. package/lib/types/dockerhub.d.ts +104 -0
  45. package/lib/types/dockerhub.js +18 -0
  46. package/lib/types/dockerhub.js.map +1 -0
  47. package/lib/types/github.d.ts +31 -0
  48. package/lib/types/github.js +18 -0
  49. package/lib/types/github.js.map +1 -0
  50. package/lib/util.d.ts +21 -1
  51. package/lib/util.js +28 -7
  52. package/lib/util.js.map +1 -1
  53. package/package.json +12 -5
  54. package/lib/builder.d.ts +0 -28
  55. package/lib/builder.js.map +0 -1
  56. package/lib/buildkit.d.ts +0 -19
  57. package/lib/buildkit.js.map +0 -1
  58. package/lib/buildx.d.ts +0 -36
  59. package/lib/buildx.js.map +0 -1
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
+ [![Version](https://img.shields.io/npm/v/@docker/actions-toolkit?label=version&logo=npm&style=flat-square)](https://www.npmjs.com/package/@docker/actions-toolkit)
2
+ [![Downloads](https://img.shields.io/npm/dw/@docker/actions-toolkit?logo=npm&style=flat-square)](https://www.npmjs.com/package/@docker/actions-toolkit)
3
+ [![Test workflow](https://img.shields.io/github/actions/workflow/status/docker/actions-toolkit/test.yml?label=test&logo=github&style=flat-square)](https://github.com/docker/actions-toolkit/actions?workflow=test)
4
+ [![Codecov](https://img.shields.io/codecov/c/github/docker/actions-toolkit?logo=codecov&style=flat-square)](https://codecov.io/gh/docker/actions-toolkit)
5
+
1
6
  # Actions Toolkit
2
7
 
3
8
  Toolkit for Docker (GitHub) Actions.
9
+
10
+ ## :test_tube: Experimental
11
+
12
+ This repository is considered **EXPERIMENTAL** and under active development
13
+ until further notice. It is subject to non-backward compatible changes or
14
+ removal in any future version.
15
+
16
+ ## About
17
+
18
+ This repository contains the source code for the toolkit that is consumed as
19
+ a library by most of our GitHub Actions:
20
+
21
+ * [docker/bake-action](https://github.com/docker/bake-action)
22
+ * [docker/build-push-action](https://github.com/docker/build-push-action)
23
+ * [docker/login-action](https://github.com/docker/login-action)
24
+ * [docker/metadata-action](https://github.com/docker/metadata-action)
25
+ * [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action)
26
+ * [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action)
27
+
28
+ This toolkit provides some utilities and common logic when developing GitHub
29
+ Actions and also acts as a minimal wrapper around our build tooling such as
30
+ [Buildx](https://github.com/docker/buildx) and [BuildKit](https://github.com/moby/buildkit)
31
+ and provides an easier API for interacting with them.
32
+
33
+ ## Installation
34
+
35
+ ```console
36
+ $ npm install @docker/actions-toolkit
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```js
42
+ const { Toolkit } = require('@docker/actions-toolkit')
43
+ const toolkit = new Toolkit()
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ Want to contribute to the Actions Toolkit? Awesome! You can find information
49
+ about contributing to this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright 2023 actions-toolkit authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Context } from '../context';
17
+ import { Buildx } from '../buildx/buildx';
18
+ import { Config } from './config';
19
+ import { BuilderInfo, NodeInfo } from '../types/builder';
20
+ export interface BuildKitOpts {
21
+ context: Context;
22
+ buildx?: Buildx;
23
+ }
24
+ export declare class BuildKit {
25
+ private readonly context;
26
+ private readonly buildx;
27
+ readonly config: Config;
28
+ constructor(opts: BuildKitOpts);
29
+ getVersion(node: NodeInfo): Promise<string | undefined>;
30
+ private getVersionWithinImage;
31
+ versionSatisfies(builderName: string, range: string, builderInfo?: BuilderInfo): Promise<boolean>;
32
+ }
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright 2023 actions-toolkit authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
2
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
18
  if (k2 === undefined) k2 = k;
4
19
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -31,45 +46,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
46
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
47
  });
33
48
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
49
  Object.defineProperty(exports, "__esModule", { value: true });
38
50
  exports.BuildKit = void 0;
39
- const fs_1 = __importDefault(require("fs"));
40
51
  const core = __importStar(require("@actions/core"));
41
52
  const exec = __importStar(require("@actions/exec"));
42
53
  const semver = __importStar(require("semver"));
43
- const buildx_1 = require("./buildx");
44
- const builder_1 = require("./builder");
54
+ const buildx_1 = require("../buildx/buildx");
55
+ const builder_1 = require("../buildx/builder");
56
+ const config_1 = require("./config");
45
57
  class BuildKit {
46
58
  constructor(opts) {
47
- this.containerNamePrefix = 'buildx_buildkit_';
48
59
  this.context = opts.context;
60
+ this.config = new config_1.Config(this.context);
49
61
  this.buildx =
50
62
  (opts === null || opts === void 0 ? void 0 : opts.buildx) ||
51
63
  new buildx_1.Buildx({
52
64
  context: this.context
53
65
  });
54
66
  }
55
- getBuilderInfo(name) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const builder = new builder_1.Builder({
58
- context: this.context,
59
- buildx: this.buildx
60
- });
61
- return builder.inspect(name);
62
- });
63
- }
64
- getVersion(builderName) {
67
+ getVersion(node) {
65
68
  return __awaiter(this, void 0, void 0, function* () {
66
- const builderInfo = yield this.getBuilderInfo(builderName);
67
- if (builderInfo.nodes.length == 0) {
68
- // a builder always have on node, should not happen.
69
- return undefined;
70
- }
71
- // TODO: get version for all nodes
72
- const node = builderInfo.nodes[0];
73
69
  if (!node.buildkitVersion && node.name) {
74
70
  try {
75
71
  return yield this.getVersionWithinImage(node.name);
@@ -84,7 +80,7 @@ class BuildKit {
84
80
  getVersionWithinImage(nodeName) {
85
81
  return __awaiter(this, void 0, void 0, function* () {
86
82
  return exec
87
- .getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${this.containerNamePrefix}${nodeName}`], {
83
+ .getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${buildx_1.Buildx.containerNamePrefix}${nodeName}`], {
88
84
  ignoreReturnCode: true,
89
85
  silent: true
90
86
  })
@@ -112,9 +108,14 @@ class BuildKit {
112
108
  });
113
109
  });
114
110
  }
115
- versionSatisfies(builderName, range) {
111
+ versionSatisfies(builderName, range, builderInfo) {
116
112
  return __awaiter(this, void 0, void 0, function* () {
117
- const builderInfo = yield this.getBuilderInfo(builderName);
113
+ if (!builderInfo) {
114
+ builderInfo = yield new builder_1.Builder({
115
+ context: this.context,
116
+ buildx: this.buildx
117
+ }).inspect(builderName);
118
+ }
118
119
  for (const node of builderInfo.nodes) {
119
120
  let bkversion = node.buildkitVersion;
120
121
  if (!bkversion) {
@@ -136,23 +137,6 @@ class BuildKit {
136
137
  return true;
137
138
  });
138
139
  }
139
- generateConfigInline(s) {
140
- return this.generateConfig(s, false);
141
- }
142
- generateConfigFile(s) {
143
- return this.generateConfig(s, true);
144
- }
145
- generateConfig(s, file) {
146
- if (file) {
147
- if (!fs_1.default.existsSync(s)) {
148
- throw new Error(`config file ${s} not found`);
149
- }
150
- s = fs_1.default.readFileSync(s, { encoding: 'utf-8' });
151
- }
152
- const configFile = this.context.tmpName({ tmpdir: this.context.tmpDir() });
153
- fs_1.default.writeFileSync(configFile, s);
154
- return configFile;
155
- }
156
140
  }
157
141
  exports.BuildKit = BuildKit;
158
142
  //# sourceMappingURL=buildkit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildkit.js","sourceRoot":"","sources":["../../src/buildkit/buildkit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AACtC,oDAAsC;AACtC,+CAAiC;AAGjC,6CAAwC;AACxC,+CAA0C;AAC1C,qCAAgC;AAShC,MAAa,QAAQ;IAMnB,YAAY,IAAkB;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM;YACT,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM;gBACZ,IAAI,eAAM,CAAC;oBACT,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CAAC,CAAC;IACP,CAAC;IAEY,UAAU,CAAC,IAAc;;YACpC,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,EAAE;gBACtC,IAAI;oBACF,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACpD;gBAAC,OAAO,CAAC,EAAE;oBACV,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;iBACjB;aACF;YACD,OAAO,IAAI,CAAC,eAAe,CAAC;QAC9B,CAAC;KAAA;IAEa,qBAAqB,CAAC,QAAgB;;YAClD,OAAO,IAAI;i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jC,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;IAEY,gBAAgB,CAAC,WAAmB,EAAE,KAAa,EAAE,WAAyB;;YACzF,IAAI,CAAC,WAAW,EAAE;gBAChB,WAAW,GAAG,MAAM,IAAI,iBAAO,CAAC;oBAC9B,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,MAAM,EAAE,IAAI,CAAC,MAAM;iBACpB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;aACzB;YACD,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE;gBACpC,IAAI,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;gBACrC,IAAI,CAAC,SAAS,EAAE;oBACd,IAAI;wBACF,SAAS,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;qBAC/D;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,KAAK,CAAC;qBACd;iBACF;gBACD,uEAAuE;gBACvE,IAAI,WAAW,CAAC,MAAM,IAAI,QAAQ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAClE,OAAO,KAAK,CAAC;iBACd;gBACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE;oBAC7D,OAAO,KAAK,CAAC;iBACd;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AAjFD,4BAiFC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2023 actions-toolkit authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Context } from '../context';
17
+ export declare class Config {
18
+ private readonly context;
19
+ constructor(context: Context);
20
+ resolveFromString(s: string): string;
21
+ resolveFromFile(s: string): string;
22
+ private resolve;
23
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2023 actions-toolkit authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.Config = void 0;
22
+ const fs_1 = __importDefault(require("fs"));
23
+ class Config {
24
+ constructor(context) {
25
+ this.context = context;
26
+ }
27
+ resolveFromString(s) {
28
+ return this.resolve(s, false);
29
+ }
30
+ resolveFromFile(s) {
31
+ return this.resolve(s, true);
32
+ }
33
+ resolve(s, file) {
34
+ if (file) {
35
+ if (!fs_1.default.existsSync(s)) {
36
+ throw new Error(`config file ${s} not found`);
37
+ }
38
+ s = fs_1.default.readFileSync(s, { encoding: 'utf-8' });
39
+ }
40
+ const configFile = this.context.tmpName({ tmpdir: this.context.tmpDir() });
41
+ fs_1.default.writeFileSync(configFile, s);
42
+ return configFile;
43
+ }
44
+ }
45
+ exports.Config = Config;
46
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/buildkit/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAEH,4CAAoB;AAIpB,MAAa,MAAM;IAGjB,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,iBAAiB,CAAC,CAAS;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAEM,eAAe,CAAC,CAAS;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAEO,OAAO,CAAC,CAAS,EAAE,IAAa;QACtC,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;gBACrB,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;aAC/C;YACD,CAAC,GAAG,YAAE,CAAC,YAAY,CAAC,CAAC,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;SAC7C;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAC,CAAC,CAAC;QACzE,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA1BD,wBA0BC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright 2023 actions-toolkit authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Buildx } from './buildx';
17
+ import { Context } from '../context';
18
+ import { BuilderInfo } from '../types/builder';
19
+ export interface BuilderOpts {
20
+ context: Context;
21
+ buildx?: Buildx;
22
+ }
23
+ export declare class Builder {
24
+ private readonly context;
25
+ private readonly buildx;
26
+ constructor(opts: BuilderOpts);
27
+ inspect(name: string): Promise<BuilderInfo>;
28
+ static parseInspect(data: string): BuilderInfo;
29
+ }
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright 2023 actions-toolkit authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
2
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
18
  if (k2 === undefined) k2 = k;
4
19
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/buildx/builder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,qCAAgC;AAUhC,MAAa,OAAO;IAIlB,YAAY,IAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM;YACT,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM;gBACZ,IAAI,eAAM,CAAC;oBACT,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CAAC,CAAC;IACP,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;oBAChB,IAAI,SAAS,GAAkB,EAAE,CAAC;oBAClC,2DAA2D;oBAC3D,gHAAgH;oBAChH,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;wBACvB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;4BACxC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gCAC1B,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;6BAC3C;yBACF;qBACF;yBAAM;wBACL,wCAAwC;wBACxC,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;qBAC/B;oBACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACrC,MAAM;iBACP;aACF;SACF;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1B;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAxGD,0BAwGC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Copyright 2023 actions-toolkit authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Context } from '../context';
17
+ import { Inputs } from './inputs';
18
+ import { Cert } from '../types/buildx';
19
+ export interface BuildxOpts {
20
+ context: Context;
21
+ standalone?: boolean;
22
+ }
23
+ export declare class Buildx {
24
+ private readonly context;
25
+ private _version;
26
+ readonly inputs: Inputs;
27
+ readonly standalone: boolean;
28
+ static readonly containerNamePrefix = "buildx_buildkit_";
29
+ constructor(opts: BuildxOpts);
30
+ static get configDir(): string;
31
+ static get certsDir(): string;
32
+ getCommand(args: Array<string>): {
33
+ command: string;
34
+ args: string[];
35
+ };
36
+ isAvailable(): Promise<boolean>;
37
+ printInspect(name: string): Promise<void>;
38
+ get version(): Promise<string | undefined>;
39
+ printVersion(): Promise<void>;
40
+ static parseVersion(stdout: string): string;
41
+ versionSatisfies(range: string, version?: string): Promise<boolean>;
42
+ static resolveCertsDriverOpts(driver: string, endpoint: string, cert: Cert): Array<string>;
43
+ }
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2023 actions-toolkit authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
+ return new (P || (P = Promise))(function (resolve, reject) {
43
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
47
+ });
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.Buildx = void 0;
54
+ const fs_1 = __importDefault(require("fs"));
55
+ const path_1 = __importDefault(require("path"));
56
+ const core = __importStar(require("@actions/core"));
57
+ const exec = __importStar(require("@actions/exec"));
58
+ const semver = __importStar(require("semver"));
59
+ const docker_1 = require("../docker");
60
+ const inputs_1 = require("./inputs");
61
+ class Buildx {
62
+ constructor(opts) {
63
+ var _a;
64
+ this.context = opts.context;
65
+ this.standalone = (_a = opts === null || opts === void 0 ? void 0 : opts.standalone) !== null && _a !== void 0 ? _a : !docker_1.Docker.getInstance().available;
66
+ this.inputs = new inputs_1.Inputs(this.context);
67
+ }
68
+ static get configDir() {
69
+ return process.env.BUILDX_CONFIG || path_1.default.join(docker_1.Docker.configDir, 'buildx');
70
+ }
71
+ static get certsDir() {
72
+ return path_1.default.join(Buildx.configDir, 'certs');
73
+ }
74
+ getCommand(args) {
75
+ return {
76
+ command: this.standalone ? 'buildx' : 'docker',
77
+ args: this.standalone ? args : ['buildx', ...args]
78
+ };
79
+ }
80
+ isAvailable() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const cmd = this.getCommand([]);
83
+ return yield exec
84
+ .getExecOutput(cmd.command, cmd.args, {
85
+ ignoreReturnCode: true,
86
+ silent: true
87
+ })
88
+ .then(res => {
89
+ if (res.stderr.length > 0 && res.exitCode != 0) {
90
+ return false;
91
+ }
92
+ return res.exitCode == 0;
93
+ })
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
95
+ .catch(error => {
96
+ return false;
97
+ });
98
+ });
99
+ }
100
+ printInspect(name) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ const cmd = this.getCommand(['inspect', name]);
103
+ yield exec.exec(cmd.command, cmd.args, {
104
+ failOnStdErr: false
105
+ });
106
+ });
107
+ }
108
+ get version() {
109
+ return (() => __awaiter(this, void 0, void 0, function* () {
110
+ if (!this._version) {
111
+ const cmd = this.getCommand(['version']);
112
+ this._version = yield exec
113
+ .getExecOutput(cmd.command, cmd.args, {
114
+ ignoreReturnCode: true,
115
+ silent: true
116
+ })
117
+ .then(res => {
118
+ if (res.stderr.length > 0 && res.exitCode != 0) {
119
+ throw new Error(res.stderr.trim());
120
+ }
121
+ return Buildx.parseVersion(res.stdout.trim());
122
+ });
123
+ }
124
+ return this._version;
125
+ }))();
126
+ }
127
+ printVersion() {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const cmd = this.getCommand(['version']);
130
+ yield exec.exec(cmd.command, cmd.args, {
131
+ failOnStdErr: false
132
+ });
133
+ });
134
+ }
135
+ static parseVersion(stdout) {
136
+ const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
137
+ if (!matches) {
138
+ throw new Error(`Cannot parse buildx version`);
139
+ }
140
+ return matches[1];
141
+ }
142
+ versionSatisfies(range, version) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ const ver = version !== null && version !== void 0 ? version : (yield this.version);
145
+ if (!ver) {
146
+ core.debug(`Buildx.versionSatisfies false: undefined version`);
147
+ return false;
148
+ }
149
+ const res = semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
150
+ core.debug(`Buildx.versionSatisfies ${ver} statisfies ${range}: ${res}`);
151
+ return res;
152
+ });
153
+ }
154
+ static resolveCertsDriverOpts(driver, endpoint, cert) {
155
+ let url;
156
+ try {
157
+ url = new URL(endpoint);
158
+ }
159
+ catch (e) {
160
+ return [];
161
+ }
162
+ if (url.protocol != 'tcp:') {
163
+ return [];
164
+ }
165
+ const driverOpts = [];
166
+ if (Object.keys(cert).length == 0) {
167
+ return driverOpts;
168
+ }
169
+ let host = url.hostname;
170
+ if (url.port.length > 0) {
171
+ host += `-${url.port}`;
172
+ }
173
+ if (cert.cacert !== undefined) {
174
+ const cacertpath = path_1.default.join(Buildx.certsDir, `cacert_${host}.pem`);
175
+ fs_1.default.writeFileSync(cacertpath, cert.cacert);
176
+ driverOpts.push(`cacert=${cacertpath}`);
177
+ }
178
+ if (cert.cert !== undefined) {
179
+ const certpath = path_1.default.join(Buildx.certsDir, `cert_${host}.pem`);
180
+ fs_1.default.writeFileSync(certpath, cert.cert);
181
+ driverOpts.push(`cert=${certpath}`);
182
+ }
183
+ if (cert.key !== undefined) {
184
+ const keypath = path_1.default.join(Buildx.certsDir, `key_${host}.pem`);
185
+ fs_1.default.writeFileSync(keypath, cert.key);
186
+ driverOpts.push(`key=${keypath}`);
187
+ }
188
+ if (driver != 'remote') {
189
+ return [];
190
+ }
191
+ return driverOpts;
192
+ }
193
+ }
194
+ exports.Buildx = Buildx;
195
+ Buildx.containerNamePrefix = 'buildx_buildkit_';
196
+ //# sourceMappingURL=buildx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildx.js","sourceRoot":"","sources":["../../src/buildx/buildx.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;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YAC9D,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YACpC,UAAU,CAAC,IAAI,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC;SACnC;QACD,IAAI,MAAM,IAAI,QAAQ,EAAE;YACtB,OAAO,EAAE,CAAC;SACX;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;;AA1IH,wBA2IC;AArIwB,0BAAmB,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2023 actions-toolkit authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Context } from '../context';
17
+ export declare class Inputs {
18
+ private readonly context;
19
+ constructor(context: Context);
20
+ getBuildImageIDFilePath(): string;
21
+ getBuildMetadataFilePath(): string;
22
+ resolveBuildImageID(): string | undefined;
23
+ resolveBuildMetadata(): string | undefined;
24
+ resolveDigest(): string | undefined;
25
+ resolveBuildSecretString(kvp: string): string;
26
+ resolveBuildSecretFile(kvp: string): string;
27
+ resolveBuildSecret(kvp: string, file: boolean): string;
28
+ getProvenanceInput(name: string): string;
29
+ resolveProvenanceAttrs(input: string): string;
30
+ static hasLocalExporter(exporters: string[]): boolean;
31
+ static hasTarExporter(exporters: string[]): boolean;
32
+ static hasDockerExporter(exporters: string[], load?: boolean): boolean;
33
+ static hasExporterType(name: string, exporters: string[]): boolean;
34
+ static hasGitAuthTokenSecret(secrets: string[]): boolean;
35
+ }