mirror of
https://github.com/docker/setup-buildx-action.git
synced 2024-11-25 07:40:56 -05:00
Merge pull request #209 from crazy-max/docker-context
fix current context as builder name for docker driver
This commit is contained in:
commit
03a7a3d9fb
7 changed files with 34 additions and 11 deletions
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
|
@ -464,3 +464,20 @@ jobs:
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
docker-context:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Create Docker context
|
||||||
|
run: |
|
||||||
|
docker context create foo
|
||||||
|
docker context use foo
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
driver: docker
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
|
import {Docker} from '@docker/actions-toolkit/lib/docker';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
import {Node} from '@docker/actions-toolkit/lib/types/builder';
|
import {Node} from '@docker/actions-toolkit/lib/types/builder';
|
||||||
|
|
||||||
|
@ -8,6 +9,10 @@ import * as context from '../src/context';
|
||||||
jest.mock('uuid');
|
jest.mock('uuid');
|
||||||
jest.spyOn(uuid, 'v4').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
|
jest.spyOn(uuid, 'v4').mockReturnValue('9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d');
|
||||||
|
|
||||||
|
jest.spyOn(Docker, 'context').mockImplementation((): Promise<string> => {
|
||||||
|
return Promise.resolve('default');
|
||||||
|
});
|
||||||
|
|
||||||
describe('getCreateArgs', () => {
|
describe('getCreateArgs', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env = Object.keys(process.env).reduce((object, key) => {
|
process.env = Object.keys(process.env).reduce((object, key) => {
|
||||||
|
|
4
dist/index.js
generated
vendored
4
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -29,7 +29,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@docker/actions-toolkit": "^0.1.0-beta.15",
|
"@docker/actions-toolkit": "^0.1.0-beta.16",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import {Docker} from '@docker/actions-toolkit/lib/docker';
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
import {Util} from '@docker/actions-toolkit/lib/util';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
||||||
import {Node} from '@docker/actions-toolkit/lib/types/builder';
|
import {Node} from '@docker/actions-toolkit/lib/types/builder';
|
||||||
|
@ -24,7 +25,7 @@ export interface Inputs {
|
||||||
export async function getInputs(): Promise<Inputs> {
|
export async function getInputs(): Promise<Inputs> {
|
||||||
return {
|
return {
|
||||||
version: core.getInput('version'),
|
version: core.getInput('version'),
|
||||||
name: getBuilderName(core.getInput('driver') || 'docker-container'),
|
name: await getBuilderName(core.getInput('driver') || 'docker-container'),
|
||||||
driver: core.getInput('driver') || 'docker-container',
|
driver: core.getInput('driver') || 'docker-container',
|
||||||
driverOpts: Util.getInputList('driver-opts', {ignoreComma: true, quote: false}),
|
driverOpts: Util.getInputList('driver-opts', {ignoreComma: true, quote: false}),
|
||||||
buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
buildkitdFlags: core.getInput('buildkitd-flags') || '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
|
||||||
|
@ -38,8 +39,8 @@ export async function getInputs(): Promise<Inputs> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBuilderName(driver: string): string {
|
export async function getBuilderName(driver: string): Promise<string> {
|
||||||
return driver == 'docker' ? 'default' : `builder-${uuid.v4()}`;
|
return driver == 'docker' ? await Docker.context() : `builder-${uuid.v4()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
|
||||||
|
|
|
@ -563,10 +563,10 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cspotcode/source-map-consumer" "0.8.0"
|
"@cspotcode/source-map-consumer" "0.8.0"
|
||||||
|
|
||||||
"@docker/actions-toolkit@^0.1.0-beta.15":
|
"@docker/actions-toolkit@^0.1.0-beta.16":
|
||||||
version "0.1.0-beta.15"
|
version "0.1.0-beta.16"
|
||||||
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.1.0-beta.15.tgz#46d9f4b1582f19ce3cb68cf272fbee335e693212"
|
resolved "https://registry.yarnpkg.com/@docker/actions-toolkit/-/actions-toolkit-0.1.0-beta.16.tgz#a34915e2957872296c8d5334809e707e6628ed4e"
|
||||||
integrity sha512-YdOHXz+r1fkoYYA5tR+Ji6jiqw5wU7gYsL8ISW+mQicm6f4Ckw4PNNADEZR+X8paEc+96Xl5Osr2tKmM3mOZOA==
|
integrity sha512-uWdhvQdpinyC633C+3RjFXZdE5bVJoJ4ADWE3568ldEBARWxRfw04VGUa4+cQ8/UqPS5goXoTjU6c7ws0jn5RQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@actions/core" "^1.10.0"
|
"@actions/core" "^1.10.0"
|
||||||
"@actions/exec" "^1.1.1"
|
"@actions/exec" "^1.1.1"
|
||||||
|
|
Loading…
Reference in a new issue