@docker/actions-toolkit 0.1.0-beta.1 → 0.1.0-beta.11
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 +46 -0
- package/lib/buildkit/buildkit.d.ts +32 -0
- package/lib/{buildkit.js → buildkit/buildkit.js} +33 -44
- package/lib/buildkit/buildkit.js.map +1 -0
- package/lib/buildkit/config.d.ts +23 -0
- package/lib/buildkit/config.js +46 -0
- package/lib/buildkit/config.js.map +1 -0
- package/lib/buildx/builder.d.ts +29 -0
- package/lib/{builder.js → buildx/builder.js} +16 -1
- package/lib/buildx/builder.js.map +1 -0
- package/lib/buildx/buildx.d.ts +44 -0
- package/lib/buildx/buildx.js +206 -0
- package/lib/buildx/buildx.js.map +1 -0
- package/lib/buildx/inputs.d.ts +35 -0
- package/lib/{buildx.js → buildx/inputs.js} +35 -106
- package/lib/buildx/inputs.js.map +1 -0
- package/lib/buildx/install.d.ts +36 -0
- package/lib/buildx/install.js +268 -0
- package/lib/buildx/install.js.map +1 -0
- package/lib/context.d.ts +15 -0
- package/lib/context.js +15 -0
- package/lib/context.js.map +1 -1
- package/lib/docker.d.ts +21 -1
- package/lib/docker.js +57 -20
- package/lib/docker.js.map +1 -1
- package/lib/dockerhub.d.ts +31 -0
- package/lib/dockerhub.js +156 -0
- package/lib/dockerhub.js.map +1 -0
- package/lib/git.d.ts +15 -0
- package/lib/git.js +15 -0
- package/lib/git.js.map +1 -1
- package/lib/github.d.ts +21 -10
- package/lib/github.js +72 -7
- package/lib/github.js.map +1 -1
- package/lib/toolkit.d.ts +21 -10
- package/lib/toolkit.js +22 -19
- package/lib/toolkit.js.map +1 -1
- package/lib/types/builder.d.ts +37 -0
- package/lib/types/builder.js +18 -0
- package/lib/types/builder.js.map +1 -0
- package/lib/types/buildx.d.ts +20 -0
- package/lib/types/buildx.js +18 -0
- package/lib/types/buildx.js.map +1 -0
- package/lib/types/dockerhub.d.ts +104 -0
- package/lib/types/dockerhub.js +18 -0
- package/lib/types/dockerhub.js.map +1 -0
- package/lib/types/github.d.ts +31 -0
- package/lib/types/github.js +18 -0
- package/lib/types/github.js.map +1 -0
- package/lib/util.d.ts +21 -1
- package/lib/util.js +28 -7
- package/lib/util.js.map +1 -1
- package/package.json +12 -5
- package/lib/builder.d.ts +0 -28
- package/lib/builder.js.map +0 -1
- package/lib/buildkit.d.ts +0 -19
- package/lib/buildkit.js.map +0 -1
- package/lib/buildx.d.ts +0 -36
- package/lib/buildx.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@docker/actions-toolkit)
|
|
2
|
+
[](https://www.npmjs.com/package/@docker/actions-toolkit)
|
|
3
|
+
[](https://github.com/docker/actions-toolkit/actions?workflow=test)
|
|
4
|
+
[](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("
|
|
44
|
-
const builder_1 = require("
|
|
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
|
-
|
|
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);
|
|
@@ -83,13 +79,15 @@ class BuildKit {
|
|
|
83
79
|
}
|
|
84
80
|
getVersionWithinImage(nodeName) {
|
|
85
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
core.debug(`BuildKit.getVersionWithinImage nodeName: ${nodeName}`);
|
|
86
83
|
return exec
|
|
87
|
-
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${
|
|
84
|
+
.getExecOutput(`docker`, ['inspect', '--format', '{{.Config.Image}}', `${buildx_1.Buildx.containerNamePrefix}${nodeName}`], {
|
|
88
85
|
ignoreReturnCode: true,
|
|
89
86
|
silent: true
|
|
90
87
|
})
|
|
91
88
|
.then(bkitimage => {
|
|
92
89
|
if (bkitimage.exitCode == 0 && bkitimage.stdout.length > 0) {
|
|
90
|
+
core.debug(`BuildKit.getVersionWithinImage image: ${bkitimage.stdout.trim()}`);
|
|
93
91
|
return exec
|
|
94
92
|
.getExecOutput(`docker`, ['run', '--rm', bkitimage.stdout.trim(), '--version'], {
|
|
95
93
|
ignoreReturnCode: true,
|
|
@@ -112,19 +110,27 @@ class BuildKit {
|
|
|
112
110
|
});
|
|
113
111
|
});
|
|
114
112
|
}
|
|
115
|
-
versionSatisfies(builderName, range) {
|
|
113
|
+
versionSatisfies(builderName, range, builderInfo) {
|
|
116
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
|
|
115
|
+
if (!builderInfo) {
|
|
116
|
+
builderInfo = yield new builder_1.Builder({
|
|
117
|
+
context: this.context,
|
|
118
|
+
buildx: this.buildx
|
|
119
|
+
}).inspect(builderName);
|
|
120
|
+
}
|
|
118
121
|
for (const node of builderInfo.nodes) {
|
|
122
|
+
core.debug(`BuildKit.versionSatisfies ${node}: ${range}`);
|
|
119
123
|
let bkversion = node.buildkitVersion;
|
|
120
124
|
if (!bkversion) {
|
|
121
125
|
try {
|
|
122
126
|
bkversion = yield this.getVersionWithinImage(node.name || '');
|
|
123
127
|
}
|
|
124
128
|
catch (e) {
|
|
129
|
+
core.debug(`BuildKit.versionSatisfies ${node}: can't get version`);
|
|
125
130
|
return false;
|
|
126
131
|
}
|
|
127
132
|
}
|
|
133
|
+
core.debug(`BuildKit.versionSatisfies ${node}: version ${bkversion}`);
|
|
128
134
|
// BuildKit version reported by moby is in the format of `v0.11.0-moby`
|
|
129
135
|
if (builderInfo.driver == 'docker' && !bkversion.endsWith('-moby')) {
|
|
130
136
|
return false;
|
|
@@ -136,23 +142,6 @@ class BuildKit {
|
|
|
136
142
|
return true;
|
|
137
143
|
});
|
|
138
144
|
}
|
|
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
145
|
}
|
|
157
146
|
exports.BuildKit = BuildKit;
|
|
158
147
|
//# 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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AC,IAAI,IAAI,EAAE,CAAC,CAAC;qBAC/D;oBAAC,OAAO,CAAC,EAAE;wBACV,IAAI,CAAC,KAAK,CAAC,6BAA6B,IAAI,qBAAqB,CAAC,CAAC;wBACnE,OAAO,KAAK,CAAC;qBACd;iBACF;gBACD,IAAI,CAAC,KAAK,CAAC,6BAA6B,IAAI,aAAa,SAAS,EAAE,CAAC,CAAC;gBACtE,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;AAtFD,4BAsFC"}
|
|
@@ -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);
|
|
@@ -46,7 +61,7 @@ class Builder {
|
|
|
46
61
|
}
|
|
47
62
|
inspect(name) {
|
|
48
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const cmd = this.buildx.getCommand(['inspect', name]);
|
|
64
|
+
const cmd = yield this.buildx.getCommand(['inspect', name]);
|
|
50
65
|
return yield exec
|
|
51
66
|
.getExecOutput(cmd.command, cmd.args, {
|
|
52
67
|
ignoreReturnCode: true,
|
|
@@ -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,CAAC;IAEY,OAAO,CAAC,IAAY;;YAC/B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;YAC5D,OAAO,MAAM,IAAI;iBACd,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE;gBACpC,gBAAgB,EAAE,IAAI;gBACtB,MAAM,EAAE,IAAI;aACb,CAAC;iBACD,IAAI,CAAC,GAAG,CAAC,EAAE;gBACV,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ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,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,44 @@
|
|
|
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 _version;
|
|
25
|
+
private readonly _standalone;
|
|
26
|
+
private readonly context;
|
|
27
|
+
readonly inputs: Inputs;
|
|
28
|
+
static readonly containerNamePrefix = "buildx_buildkit_";
|
|
29
|
+
constructor(opts: BuildxOpts);
|
|
30
|
+
static get configDir(): string;
|
|
31
|
+
static get certsDir(): string;
|
|
32
|
+
isStandalone(): Promise<boolean>;
|
|
33
|
+
getCommand(args: Array<string>): Promise<{
|
|
34
|
+
command: string;
|
|
35
|
+
args: string[];
|
|
36
|
+
}>;
|
|
37
|
+
isAvailable(): Promise<boolean>;
|
|
38
|
+
printInspect(name: string): Promise<void>;
|
|
39
|
+
get version(): Promise<string | undefined>;
|
|
40
|
+
printVersion(): Promise<void>;
|
|
41
|
+
static parseVersion(stdout: string): string;
|
|
42
|
+
versionSatisfies(range: string, version?: string): Promise<boolean>;
|
|
43
|
+
static resolveCertsDriverOpts(driver: string, endpoint: string, cert: Cert): Array<string>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
this._standalone = opts === null || opts === void 0 ? void 0 : opts.standalone;
|
|
64
|
+
this.context = opts.context;
|
|
65
|
+
this.inputs = new inputs_1.Inputs(this.context);
|
|
66
|
+
}
|
|
67
|
+
static get configDir() {
|
|
68
|
+
return process.env.BUILDX_CONFIG || path_1.default.join(docker_1.Docker.configDir, 'buildx');
|
|
69
|
+
}
|
|
70
|
+
static get certsDir() {
|
|
71
|
+
return path_1.default.join(Buildx.configDir, 'certs');
|
|
72
|
+
}
|
|
73
|
+
isStandalone() {
|
|
74
|
+
var _a;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const standalone = (_a = this._standalone) !== null && _a !== void 0 ? _a : !(yield docker_1.Docker.getInstance().isAvailable());
|
|
77
|
+
core.debug(`Buildx.isStandalone: ${standalone}`);
|
|
78
|
+
return standalone;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
getCommand(args) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const standalone = yield this.isStandalone();
|
|
84
|
+
return {
|
|
85
|
+
command: standalone ? 'buildx' : 'docker',
|
|
86
|
+
args: standalone ? args : ['buildx', ...args]
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
isAvailable() {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const cmd = yield this.getCommand([]);
|
|
93
|
+
return yield exec
|
|
94
|
+
.getExecOutput(cmd.command, cmd.args, {
|
|
95
|
+
ignoreReturnCode: true,
|
|
96
|
+
silent: true
|
|
97
|
+
})
|
|
98
|
+
.then(res => {
|
|
99
|
+
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return res.exitCode == 0;
|
|
103
|
+
})
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
105
|
+
.catch(error => {
|
|
106
|
+
return false;
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
printInspect(name) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const cmd = yield this.getCommand(['inspect', name]);
|
|
113
|
+
yield exec.exec(cmd.command, cmd.args, {
|
|
114
|
+
failOnStdErr: false
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
get version() {
|
|
119
|
+
return (() => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
if (!this._version) {
|
|
121
|
+
const cmd = yield this.getCommand(['version']);
|
|
122
|
+
this._version = yield exec
|
|
123
|
+
.getExecOutput(cmd.command, cmd.args, {
|
|
124
|
+
ignoreReturnCode: true,
|
|
125
|
+
silent: true
|
|
126
|
+
})
|
|
127
|
+
.then(res => {
|
|
128
|
+
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
129
|
+
throw new Error(res.stderr.trim());
|
|
130
|
+
}
|
|
131
|
+
return Buildx.parseVersion(res.stdout.trim());
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return this._version;
|
|
135
|
+
}))();
|
|
136
|
+
}
|
|
137
|
+
printVersion() {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const cmd = yield this.getCommand(['version']);
|
|
140
|
+
yield exec.exec(cmd.command, cmd.args, {
|
|
141
|
+
failOnStdErr: false
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
static parseVersion(stdout) {
|
|
146
|
+
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
|
|
147
|
+
if (!matches) {
|
|
148
|
+
throw new Error(`Cannot parse buildx version`);
|
|
149
|
+
}
|
|
150
|
+
return matches[1];
|
|
151
|
+
}
|
|
152
|
+
versionSatisfies(range, version) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const ver = version !== null && version !== void 0 ? version : (yield this.version);
|
|
155
|
+
if (!ver) {
|
|
156
|
+
core.debug(`Buildx.versionSatisfies false: undefined version`);
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const res = semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
|
|
160
|
+
core.debug(`Buildx.versionSatisfies ${ver} statisfies ${range}: ${res}`);
|
|
161
|
+
return res;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
static resolveCertsDriverOpts(driver, endpoint, cert) {
|
|
165
|
+
let url;
|
|
166
|
+
try {
|
|
167
|
+
url = new URL(endpoint);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
if (url.protocol != 'tcp:') {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
const driverOpts = [];
|
|
176
|
+
if (Object.keys(cert).length == 0) {
|
|
177
|
+
return driverOpts;
|
|
178
|
+
}
|
|
179
|
+
let host = url.hostname;
|
|
180
|
+
if (url.port.length > 0) {
|
|
181
|
+
host += `-${url.port}`;
|
|
182
|
+
}
|
|
183
|
+
if (cert.cacert !== undefined) {
|
|
184
|
+
const cacertpath = path_1.default.join(Buildx.certsDir, `cacert_${host}.pem`);
|
|
185
|
+
fs_1.default.writeFileSync(cacertpath, cert.cacert);
|
|
186
|
+
driverOpts.push(`cacert=${cacertpath}`);
|
|
187
|
+
}
|
|
188
|
+
if (cert.cert !== undefined) {
|
|
189
|
+
const certpath = path_1.default.join(Buildx.certsDir, `cert_${host}.pem`);
|
|
190
|
+
fs_1.default.writeFileSync(certpath, cert.cert);
|
|
191
|
+
driverOpts.push(`cert=${certpath}`);
|
|
192
|
+
}
|
|
193
|
+
if (cert.key !== undefined) {
|
|
194
|
+
const keypath = path_1.default.join(Buildx.certsDir, `key_${host}.pem`);
|
|
195
|
+
fs_1.default.writeFileSync(keypath, cert.key);
|
|
196
|
+
driverOpts.push(`key=${keypath}`);
|
|
197
|
+
}
|
|
198
|
+
if (driver != 'remote') {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
return driverOpts;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.Buildx = Buildx;
|
|
205
|
+
Buildx.containerNamePrefix = 'buildx_buildkit_';
|
|
206
|
+
//# sourceMappingURL=buildx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildx.js","sourceRoot":"","sources":["../../src/buildx/buildx.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,gDAAwB;AACxB,oDAAsC;AACtC,oDAAsC;AACtC,+CAAiC;AAEjC,sCAAiC;AAEjC,qCAAgC;AAShC,MAAa,MAAM;IASjB,YAAY,IAAgB;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,KAAK,SAAS;QAClB,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,cAAI,CAAC,IAAI,CAAC,eAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,KAAK,QAAQ;QACjB,OAAO,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAEY,YAAY;;;YACvB,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,WAAW,mCAAI,CAAC,CAAC,MAAM,eAAM,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC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