@@ -19,21 +19,15 @@ import fs from 'fs';
19
19
import os from 'os' ;
20
20
import path from 'path' ;
21
21
22
- import { Install , InstallSourceArchive , InstallSourceImage } from '../../src/docker/install' ;
22
+ import { Install , InstallSource , InstallSourceArchive , InstallSourceImage } from '../../src/docker/install' ;
23
23
import { Docker } from '../../src/docker/docker' ;
24
24
import { Exec } from '../../src/exec' ;
25
25
26
26
const tmpDir = ( ) => fs . mkdtempSync ( path . join ( process . env . TEMP || os . tmpdir ( ) , 'docker-install-itg-' ) ) ;
27
27
28
- describe ( 'install ' , ( ) => {
28
+ describe ( 'root ' , ( ) => {
29
29
// prettier-ignore
30
- test . each ( [
31
- { type : 'image' , tag : '27.3.1' } as InstallSourceImage ,
32
- { type : 'image' , tag : 'master' } as InstallSourceImage ,
33
- { type : 'image' , tag : 'latest' } as InstallSourceImage ,
34
- { type : 'archive' , version : 'v26.1.4' , channel : 'stable' } as InstallSourceArchive ,
35
- { type : 'archive' , version : 'latest' , channel : 'stable' } as InstallSourceArchive ,
36
- ] ) (
30
+ test . each ( getSources ( true ) ) (
37
31
'install docker %s' , async ( source ) => {
38
32
await ensureNoSystemContainerd ( ) ;
39
33
const install = new Install ( {
@@ -48,16 +42,12 @@ describe('install', () => {
48
42
49
43
describe ( 'rootless' , ( ) => {
50
44
// prettier-ignore
51
- test . each ( [
52
- { type : 'image' , tag : 'latest' } as InstallSourceImage ,
53
- { type : 'archive' , version : 'latest' , channel : 'stable' } as InstallSourceArchive ,
54
- ] ) (
45
+ test . each ( getSources ( false ) ) (
55
46
'install %s' , async ( source ) => {
56
47
// Skip on non linux
57
48
if ( os . platform ( ) !== 'linux' ) {
58
49
return ;
59
50
}
60
-
61
51
await ensureNoSystemContainerd ( ) ;
62
52
const install = new Install ( {
63
53
source : source ,
@@ -109,3 +99,37 @@ async function ensureNoSystemContainerd() {
109
99
} ) ;
110
100
}
111
101
}
102
+
103
+ function getSources ( root : boolean ) : Array < InstallSource > {
104
+ const dockerInstallType = process . env . DOCKER_INSTALL_TYPE ;
105
+ const dockerInstallVersion = process . env . DOCKER_INSTALL_VERSION ;
106
+ if ( dockerInstallType && dockerInstallVersion ) {
107
+ if ( dockerInstallType === 'archive' ) {
108
+ // prettier-ignore
109
+ return [
110
+ { type : dockerInstallType , version : dockerInstallVersion , channel : 'stable' } as InstallSourceArchive
111
+ ] ;
112
+ } else {
113
+ // prettier-ignore
114
+ return [
115
+ { type : dockerInstallType , tag : dockerInstallVersion } as InstallSourceImage
116
+ ] ;
117
+ }
118
+ }
119
+ if ( root ) {
120
+ // prettier-ignore
121
+ return [
122
+ { type : 'image' , tag : '27.3.1' } as InstallSourceImage ,
123
+ { type : 'image' , tag : 'master' } as InstallSourceImage ,
124
+ { type : 'image' , tag : 'latest' } as InstallSourceImage ,
125
+ { type : 'archive' , version : 'v26.1.4' , channel : 'stable' } as InstallSourceArchive ,
126
+ { type : 'archive' , version : 'latest' , channel : 'stable' } as InstallSourceArchive
127
+ ] ;
128
+ } else {
129
+ // prettier-ignore
130
+ return [
131
+ { type : 'image' , tag : 'latest' } as InstallSourceImage ,
132
+ { type : 'archive' , version : 'latest' , channel : 'stable' } as InstallSourceArchive
133
+ ] ;
134
+ }
135
+ }
0 commit comments