Add rootless support

Wire up `rootless` config to the new `rootless` Install option.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2024-11-06 15:54:40 +01:00
parent e02739be38
commit bcd97be19b
No known key found for this signature in database
GPG Key ID: B85EFCFE26DEF92A
7 changed files with 45 additions and 3 deletions

View File

@ -135,6 +135,7 @@ The following inputs can be used as `step.with` keys
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
| `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 |
### outputs

View File

@ -19,6 +19,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'v24.0.8'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -28,6 +29,7 @@ describe('getInputs', () => {
},
context: '',
daemonConfig: '',
rootless: false,
setHost: false
} as context.Inputs
],
@ -39,6 +41,7 @@ describe('getInputs', () => {
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -48,6 +51,7 @@ describe('getInputs', () => {
},
context: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
rootless: false,
setHost: false
} as context.Inputs
],
@ -55,6 +59,7 @@ describe('getInputs', () => {
2,
new Map<string, string>([
['set-host', 'true'],
['rootless', 'false'],
]),
{
source: {
@ -64,6 +69,7 @@ describe('getInputs', () => {
},
context: '',
daemonConfig: '',
rootless: false,
setHost: true
} as context.Inputs
],
@ -74,6 +80,7 @@ describe('getInputs', () => {
['context', 'foo'],
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -82,6 +89,7 @@ describe('getInputs', () => {
},
context: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
rootless: false,
setHost: false
} as context.Inputs
],
@ -90,6 +98,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'type=image'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -98,6 +107,7 @@ describe('getInputs', () => {
},
context: '',
daemonConfig: '',
rootless: false,
setHost: false
} as context.Inputs
],
@ -106,6 +116,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'type=archive'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -116,6 +127,7 @@ describe('getInputs', () => {
setHost: false,
context: '',
daemonConfig: '',
rootless: false,
} as context.Inputs
],
[
@ -123,6 +135,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'version=v27.2.0,channel=test'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -133,6 +146,7 @@ describe('getInputs', () => {
setHost: false,
context: '',
daemonConfig: '',
rootless: false,
} as context.Inputs
],
[
@ -140,6 +154,7 @@ describe('getInputs', () => {
new Map<string, string>([
['version', 'type=image,tag=27.2.1'],
['set-host', 'false'],
['rootless', 'false'],
]),
{
source: {
@ -149,6 +164,25 @@ describe('getInputs', () => {
setHost: false,
context: '',
daemonConfig: '',
rootless: false,
} as context.Inputs
],
[
8,
new Map<string, string>([
['version', 'type=image,tag=27.2.1'],
['set-host', 'false'],
['rootless', 'true']
]),
{
source: {
type: 'image',
tag: '27.2.1',
},
setHost: false,
context: '',
daemonConfig: '',
rootless: true,
} as context.Inputs
],
])(

View File

@ -24,6 +24,10 @@ inputs:
description: 'Set DOCKER_HOST environment variable to docker socket path'
default: 'false'
required: false
rootless:
description: 'Enable Docker rootless mode'
default: 'false'
required: false
outputs:
sock:

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@ export interface Inputs {
daemonConfig?: string;
context: string;
setHost: boolean;
rootless: boolean;
}
export function getInputs(): Inputs {
@ -21,7 +22,8 @@ export function getInputs(): Inputs {
source: source,
daemonConfig: core.getInput('daemon-config'),
context: core.getInput('context'),
setHost: core.getBooleanInput('set-host')
setHost: core.getBooleanInput('set-host'),
rootless: core.getBooleanInput('rootless')
};
}

View File

@ -22,6 +22,7 @@ actionsToolkit.run(
const install = new Install({
runDir: runDir,
source: input.source,
rootless: input.rootless,
contextName: input.context || 'setup-docker-action',
daemonConfig: input.daemonConfig
});