Skip to content

Commit bcd97be

Browse files
committed
Add rootless support
Wire up `rootless` config to the new `rootless` Install option. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent e02739b commit bcd97be

7 files changed

Lines changed: 45 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ The following inputs can be used as `step.with` keys
135135
| `daemon-config` | String | | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) |
136136
| `context` | String | `setup-docker-action` | Docker context name. |
137137
| `set-host` | Bool | `false` | Set `DOCKER_HOST` environment variable to docker socket path. |
138+
| `rootless` | Bool | `false` | Start daemon in rootless mode |
138139

139140
### outputs
140141

__tests__/context.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('getInputs', () => {
1919
new Map<string, string>([
2020
['version', 'v24.0.8'],
2121
['set-host', 'false'],
22+
['rootless', 'false'],
2223
]),
2324
{
2425
source: {
@@ -28,6 +29,7 @@ describe('getInputs', () => {
2829
},
2930
context: '',
3031
daemonConfig: '',
32+
rootless: false,
3133
setHost: false
3234
} as context.Inputs
3335
],
@@ -39,6 +41,7 @@ describe('getInputs', () => {
3941
['context', 'foo'],
4042
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
4143
['set-host', 'false'],
44+
['rootless', 'false'],
4245
]),
4346
{
4447
source: {
@@ -48,13 +51,15 @@ describe('getInputs', () => {
4851
},
4952
context: 'foo',
5053
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
54+
rootless: false,
5155
setHost: false
5256
} as context.Inputs
5357
],
5458
[
5559
2,
5660
new Map<string, string>([
5761
['set-host', 'true'],
62+
['rootless', 'false'],
5863
]),
5964
{
6065
source: {
@@ -64,6 +69,7 @@ describe('getInputs', () => {
6469
},
6570
context: '',
6671
daemonConfig: '',
72+
rootless: false,
6773
setHost: true
6874
} as context.Inputs
6975
],
@@ -74,6 +80,7 @@ describe('getInputs', () => {
7480
['context', 'foo'],
7581
['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`],
7682
['set-host', 'false'],
83+
['rootless', 'false'],
7784
]),
7885
{
7986
source: {
@@ -82,6 +89,7 @@ describe('getInputs', () => {
8289
},
8390
context: 'foo',
8491
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`,
92+
rootless: false,
8593
setHost: false
8694
} as context.Inputs
8795
],
@@ -90,6 +98,7 @@ describe('getInputs', () => {
9098
new Map<string, string>([
9199
['version', 'type=image'],
92100
['set-host', 'false'],
101+
['rootless', 'false'],
93102
]),
94103
{
95104
source: {
@@ -98,6 +107,7 @@ describe('getInputs', () => {
98107
},
99108
context: '',
100109
daemonConfig: '',
110+
rootless: false,
101111
setHost: false
102112
} as context.Inputs
103113
],
@@ -106,6 +116,7 @@ describe('getInputs', () => {
106116
new Map<string, string>([
107117
['version', 'type=archive'],
108118
['set-host', 'false'],
119+
['rootless', 'false'],
109120
]),
110121
{
111122
source: {
@@ -116,13 +127,15 @@ describe('getInputs', () => {
116127
setHost: false,
117128
context: '',
118129
daemonConfig: '',
130+
rootless: false,
119131
} as context.Inputs
120132
],
121133
[
122134
6,
123135
new Map<string, string>([
124136
['version', 'version=v27.2.0,channel=test'],
125137
['set-host', 'false'],
138+
['rootless', 'false'],
126139
]),
127140
{
128141
source: {
@@ -133,13 +146,15 @@ describe('getInputs', () => {
133146
setHost: false,
134147
context: '',
135148
daemonConfig: '',
149+
rootless: false,
136150
} as context.Inputs
137151
],
138152
[
139153
7,
140154
new Map<string, string>([
141155
['version', 'type=image,tag=27.2.1'],
142156
['set-host', 'false'],
157+
['rootless', 'false'],
143158
]),
144159
{
145160
source: {
@@ -149,6 +164,25 @@ describe('getInputs', () => {
149164
setHost: false,
150165
context: '',
151166
daemonConfig: '',
167+
rootless: false,
168+
} as context.Inputs
169+
],
170+
[
171+
8,
172+
new Map<string, string>([
173+
['version', 'type=image,tag=27.2.1'],
174+
['set-host', 'false'],
175+
['rootless', 'true']
176+
]),
177+
{
178+
source: {
179+
type: 'image',
180+
tag: '27.2.1',
181+
},
182+
setHost: false,
183+
context: '',
184+
daemonConfig: '',
185+
rootless: true,
152186
} as context.Inputs
153187
],
154188
])(

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: 'Set DOCKER_HOST environment variable to docker socket path'
2525
default: 'false'
2626
required: false
27+
rootless:
28+
description: 'Enable Docker rootless mode'
29+
default: 'false'
30+
required: false
2731

2832
outputs:
2933
sock:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Inputs {
77
daemonConfig?: string;
88
context: string;
99
setHost: boolean;
10+
rootless: boolean;
1011
}
1112

1213
export function getInputs(): Inputs {
@@ -21,7 +22,8 @@ export function getInputs(): Inputs {
2122
source: source,
2223
daemonConfig: core.getInput('daemon-config'),
2324
context: core.getInput('context'),
24-
setHost: core.getBooleanInput('set-host')
25+
setHost: core.getBooleanInput('set-host'),
26+
rootless: core.getBooleanInput('rootless')
2527
};
2628
}
2729

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ actionsToolkit.run(
2222
const install = new Install({
2323
runDir: runDir,
2424
source: input.source,
25+
rootless: input.rootless,
2526
contextName: input.context || 'setup-docker-action',
2627
daemonConfig: input.daemonConfig
2728
});

0 commit comments

Comments
 (0)