mirror of
https://github.moeyy.xyz/https://github.com/docker/setup-docker-action.git
synced 2025-10-27 16:16:47 +08:00
Merge pull request #168 from ArunKumarT1995/feature/rundirinput
Add input for runtime basedir
This commit is contained in:
commit
74ac62f5d7
@ -114,7 +114,7 @@ jobs:
|
||||
The following inputs can be used as `step.with` keys
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|-----------------|--------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
|-------------------|--------|------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
| `version` | String | `latest` | Docker version to use. See [inputs.version](#inputs.version). |
|
||||
| `channel` | String | `stable` | Docker CE [channel](https://download.docker.com/linux/static/) (`stable` or `test`). Only applicable to `type=archive` |
|
||||
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
|
||||
@ -122,6 +122,7 @@ The following inputs can be used as `step.with` keys
|
||||
| `context` | String | `setup-docker-action` | Docker context name. |
|
||||
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
|
||||
| `rootless` | Bool | `false` | Start daemon in rootless mode |
|
||||
| `runtime-basedir` | String | `<home>/setup-docker-action` | Docker runtime base directory |
|
||||
|
||||
### inputs.version
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import {beforeEach, describe, expect, test} from '@jest/globals';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as context from '../src/context';
|
||||
|
||||
@ -30,7 +32,8 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: false,
|
||||
setHost: false
|
||||
setHost: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -52,7 +55,8 @@ describe('getInputs', () => {
|
||||
context: 'foo',
|
||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
|
||||
rootless: false,
|
||||
setHost: false
|
||||
setHost: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -70,7 +74,8 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: false,
|
||||
setHost: true
|
||||
setHost: true,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -90,7 +95,8 @@ describe('getInputs', () => {
|
||||
context: 'foo',
|
||||
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
|
||||
rootless: false,
|
||||
setHost: false
|
||||
setHost: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -108,7 +114,8 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: false,
|
||||
setHost: false
|
||||
setHost: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -128,6 +135,7 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -147,6 +155,7 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -165,6 +174,7 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -183,6 +193,7 @@ describe('getInputs', () => {
|
||||
context: '',
|
||||
daemonConfig: '',
|
||||
rootless: true,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
[
|
||||
@ -203,7 +214,8 @@ describe('getInputs', () => {
|
||||
daemonConfig: '',
|
||||
tcpPort: 2378,
|
||||
rootless: false,
|
||||
setHost: false
|
||||
setHost: false,
|
||||
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
|
||||
} as context.Inputs
|
||||
],
|
||||
])(
|
||||
|
||||
@ -31,6 +31,9 @@ inputs:
|
||||
description: 'Enable Docker rootless mode'
|
||||
default: 'false'
|
||||
required: false
|
||||
runtime-basedir:
|
||||
description: 'Docker runtime base directory'
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
sock:
|
||||
|
||||
2
dist/index.js
generated
vendored
2
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
@ -1,3 +1,5 @@
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import {parse} from 'csv-parse/sync';
|
||||
|
||||
@ -11,6 +13,7 @@ export interface Inputs {
|
||||
context: string;
|
||||
setHost: boolean;
|
||||
rootless: boolean;
|
||||
runtimeBasedir: string;
|
||||
}
|
||||
|
||||
export function getInputs(): Inputs {
|
||||
@ -27,7 +30,8 @@ export function getInputs(): Inputs {
|
||||
tcpPort: Util.getInputNumber('tcp-port'),
|
||||
context: core.getInput('context'),
|
||||
setHost: core.getBooleanInput('set-host'),
|
||||
rootless: core.getBooleanInput('rootless')
|
||||
rootless: core.getBooleanInput('rootless'),
|
||||
runtimeBasedir: core.getInput('runtime-basedir') || path.join(os.homedir(), `setup-docker-action`)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import * as crypto from 'crypto';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||
@ -18,7 +17,7 @@ actionsToolkit.run(
|
||||
// main
|
||||
async () => {
|
||||
const input: context.Inputs = context.getInputs();
|
||||
const runDir = path.join(os.homedir(), `setup-docker-action-${crypto.randomUUID().slice(0, 8)}`);
|
||||
const runDir = path.join(input.runtimeBasedir, `run-${crypto.randomUUID().slice(0, 8)}`);
|
||||
|
||||
if (input.context == 'default') {
|
||||
throw new Error(`'default' context cannot be used.`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user