@@ -90,8 +90,8 @@ var _ = framework.KubeDescribe("Security Context", func() {
90
90
91
91
By ("create nginx container" )
92
92
prefix := "nginx-container-"
93
- containerName := prefix + framework .NewUUID ()
94
- containerID , nginxContainerName , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , nginxContainerImage , namespaceOption , nil , "" )
93
+ nginxContainerName := prefix + framework .NewUUID ()
94
+ containerID , _ := createNamespaceContainer (rc , ic , podID , podConfig , nginxContainerName , nginxContainerImage , namespaceOption , nil , "" )
95
95
96
96
By ("start container" )
97
97
startContainer (rc , containerID )
@@ -108,8 +108,8 @@ var _ = framework.KubeDescribe("Security Context", func() {
108
108
By ("create busybox container with hostPID" )
109
109
command = []string {"sh" , "-c" , "sleep 1000" }
110
110
prefix = "container-with-HostPID-test-"
111
- containerName = prefix + framework .NewUUID ()
112
- containerID , _ , _ = createNamespaceContainer (rc , ic , podID , podConfig , containerName , framework .TestContext .TestImageList .DefaultTestContainerImage , namespaceOption , command , "" )
111
+ containerName : = prefix + framework .NewUUID ()
112
+ containerID , _ = createNamespaceContainer (rc , ic , podID , podConfig , containerName , framework .TestContext .TestImageList .DefaultTestContainerImage , namespaceOption , command , "" )
113
113
114
114
By ("start container" )
115
115
startContainer (rc , containerID )
@@ -150,7 +150,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
150
150
By ("create a default container with namespace" )
151
151
prefix := "namespace-container-"
152
152
containerName := prefix + framework .NewUUID ()
153
- containerID , _ , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , framework .TestContext .TestImageList .DefaultTestContainerImage , namespaceOption , pauseCmd , "" )
153
+ containerID , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , framework .TestContext .TestImageList .DefaultTestContainerImage , namespaceOption , pauseCmd , "" )
154
154
155
155
By ("start container" )
156
156
startContainer (rc , containerID )
@@ -190,7 +190,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
190
190
By ("create nginx container" )
191
191
prefix := "nginx-container-"
192
192
containerName := prefix + framework .NewUUID ()
193
- containerID , _ , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , nginxContainerImage , namespaceOption , nil , "" )
193
+ containerID , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , nginxContainerImage , namespaceOption , nil , "" )
194
194
195
195
By ("start container" )
196
196
startContainer (rc , containerID )
@@ -216,7 +216,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
216
216
By ("create nginx container" )
217
217
prefix := "nginx-container-"
218
218
containerName := prefix + framework .NewUUID ()
219
- containerID , _ , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , nginxContainerImage , namespaceOption , nil , "" )
219
+ containerID , _ := createNamespaceContainer (rc , ic , podID , podConfig , containerName , nginxContainerImage , namespaceOption , nil , "" )
220
220
221
221
By ("start container" )
222
222
startContainer (rc , containerID )
@@ -375,7 +375,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
375
375
376
376
By ("create container with ReadOnlyRootfs_false" )
377
377
readOnlyRootfs := false
378
- logPath , containerID := createReadOnlyRootfsContainer (rc , ic , podID , podConfig , "container-with-ReadOnlyRootfs-false-test-" , readOnlyRootfs )
378
+ containerID , logPath := createReadOnlyRootfsContainer (rc , ic , podID , podConfig , "container-with-ReadOnlyRootfs-false-test-" , readOnlyRootfs )
379
379
380
380
By ("start container" )
381
381
startContainer (rc , containerID )
@@ -393,7 +393,7 @@ var _ = framework.KubeDescribe("Security Context", func() {
393
393
394
394
By ("create container with ReadOnlyRootfs_true" )
395
395
readOnlyRootfs := true
396
- logPath , containerID := createReadOnlyRootfsContainer (rc , ic , podID , podConfig , "container-with-ReadOnlyRootfs-true-test-" , readOnlyRootfs )
396
+ containerID , logPath := createReadOnlyRootfsContainer (rc , ic , podID , podConfig , "container-with-ReadOnlyRootfs-true-test-" , readOnlyRootfs )
397
397
398
398
By ("start container" )
399
399
startContainer (rc , containerID )
@@ -1118,11 +1118,11 @@ func matchContainerOutputRe(podConfig *runtimeapi.PodSandboxConfig, name, patter
1118
1118
}
1119
1119
1120
1120
// createRunAsUserContainer creates the container with specified RunAsUser in ContainerConfig.
1121
- func createRunAsUserContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , prefix string ) (string , string ) {
1121
+ func createRunAsUserContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , prefix string ) (containerID , expectedLogMessage string ) {
1122
1122
By ("create RunAsUser container" )
1123
1123
var uidV runtimeapi.Int64Value
1124
1124
uidV .Value = 1001
1125
- expectedLogMessage : = "1001\n "
1125
+ expectedLogMessage = "1001\n "
1126
1126
1127
1127
By ("create a container with RunAsUser" )
1128
1128
containerName := prefix + framework .NewUUID ()
@@ -1141,10 +1141,10 @@ func createRunAsUserContainer(rc internalapi.RuntimeService, ic internalapi.Imag
1141
1141
}
1142
1142
1143
1143
// createRunAsUserNameContainer creates the container with specified RunAsUserName in ContainerConfig.
1144
- func createRunAsUserNameContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , prefix string ) (string , string ) {
1144
+ func createRunAsUserNameContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , prefix string ) (containerID , expectedLogMessage string ) {
1145
1145
By ("create RunAsUserName container" )
1146
1146
userName := "nobody"
1147
- expectedLogMessage : = userName + "\n "
1147
+ expectedLogMessage = userName + "\n "
1148
1148
1149
1149
By ("create a container with RunAsUserName" )
1150
1150
containerName := prefix + framework .NewUUID ()
@@ -1162,12 +1162,12 @@ func createRunAsUserNameContainer(rc internalapi.RuntimeService, ic internalapi.
1162
1162
}
1163
1163
1164
1164
// createRunAsGroupContainer creates the container with specified RunAsGroup in ContainerConfig.
1165
- func createRunAsGroupContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , containerName string ) (string , string ) {
1165
+ func createRunAsGroupContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , containerName string ) (containerID , expectedLogMessage string ) {
1166
1166
By ("create RunAsGroup container" )
1167
1167
var uidV , gidV runtimeapi.Int64Value
1168
1168
uidV .Value = 1001
1169
1169
gidV .Value = 1002
1170
- expectedLogMessage : = "1001:1002\n "
1170
+ expectedLogMessage = "1001:1002\n "
1171
1171
1172
1172
By ("create a container with RunAsUser and RunAsGroup" )
1173
1173
containerConfig := & runtimeapi.ContainerConfig {
@@ -1229,7 +1229,7 @@ func createNamespacePodSandbox(rc internalapi.RuntimeService, podSandboxNamespac
1229
1229
}
1230
1230
1231
1231
// createNamespaceContainer creates container with different NamespaceOption config.
1232
- func createNamespaceContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , containerName , image string , containerNamespace * runtimeapi.NamespaceOption , command []string , path string ) (string , string , string ) {
1232
+ func createNamespaceContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , containerName , image string , containerNamespace * runtimeapi.NamespaceOption , command []string , path string ) (containerID , logPath string ) {
1233
1233
By ("create NamespaceOption container" )
1234
1234
containerConfig := & runtimeapi.ContainerConfig {
1235
1235
Metadata : framework .BuildContainerMetadata (containerName , framework .DefaultAttempt ),
@@ -1243,11 +1243,11 @@ func createNamespaceContainer(rc internalapi.RuntimeService, ic internalapi.Imag
1243
1243
LogPath : path ,
1244
1244
}
1245
1245
1246
- return framework .CreateContainer (rc , ic , containerConfig , podID , podConfig ), containerName , containerConfig .LogPath
1246
+ return framework .CreateContainer (rc , ic , containerConfig , podID , podConfig ), containerConfig .LogPath
1247
1247
}
1248
1248
1249
1249
// createReadOnlyRootfsContainer creates the container with specified ReadOnlyRootfs in ContainerConfig.
1250
- func createReadOnlyRootfsContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , prefix string , readonly bool ) (string , string ) {
1250
+ func createReadOnlyRootfsContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , podID string , podConfig * runtimeapi.PodSandboxConfig , prefix string , readonly bool ) (containerID , logPath string ) {
1251
1251
By ("create ReadOnlyRootfs container" )
1252
1252
containerName := prefix + framework .NewUUID ()
1253
1253
path := containerName + ".log"
@@ -1263,7 +1263,7 @@ func createReadOnlyRootfsContainer(rc internalapi.RuntimeService, ic internalapi
1263
1263
LogPath : path ,
1264
1264
}
1265
1265
1266
- return containerConfig . LogPath , framework .CreateContainer (rc , ic , containerConfig , podID , podConfig )
1266
+ return framework .CreateContainer (rc , ic , containerConfig , podID , podConfig ), containerConfig . LogPath
1267
1267
}
1268
1268
1269
1269
// checkRootfs checks whether the rootfs parameter of the ContainerConfig is working properly.
@@ -1370,7 +1370,7 @@ func createAndCheckHostNetwork(rc internalapi.RuntimeService, ic internalapi.Ima
1370
1370
command := []string {"sh" , "-c" , "netstat -ln" }
1371
1371
containerName := "container-with-HostNetwork-test-" + framework .NewUUID ()
1372
1372
path := containerName + ".log"
1373
- containerID , _ , logPath := createNamespaceContainer (rc , ic , podID , podConfig , containerName , framework .TestContext .TestImageList .DefaultTestContainerImage , namespaceOptions , command , path )
1373
+ containerID , logPath := createNamespaceContainer (rc , ic , podID , podConfig , containerName , framework .TestContext .TestImageList .DefaultTestContainerImage , namespaceOptions , command , path )
1374
1374
1375
1375
By ("start container" )
1376
1376
startContainer (rc , containerID )
@@ -1417,7 +1417,7 @@ func createSeccompProfile(profileContents, profileName, hostPath string) (string
1417
1417
}
1418
1418
1419
1419
// seccompTestContainer creates and starts a seccomp sandbox and a container.
1420
- func seccompTestContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , profile * runtimeapi.SecurityProfile ) (string , string ) {
1420
+ func seccompTestContainer (rc internalapi.RuntimeService , ic internalapi.ImageManagerService , profile * runtimeapi.SecurityProfile ) (podID , containerID string ) {
1421
1421
By ("create seccomp sandbox" )
1422
1422
podSandboxName := "seccomp-sandbox-" + framework .NewUUID ()
1423
1423
uid := framework .DefaultUIDPrefix + framework .NewUUID ()
@@ -1432,7 +1432,7 @@ func seccompTestContainer(rc internalapi.RuntimeService, ic internalapi.ImageMan
1432
1432
},
1433
1433
Labels : framework .DefaultPodLabels ,
1434
1434
}
1435
- podID : = framework .RunPodSandbox (rc , podConfig )
1435
+ podID = framework .RunPodSandbox (rc , podConfig )
1436
1436
1437
1437
By ("create container" )
1438
1438
containerNamePrefix := "seccomp-container-" + framework .NewUUID ()
@@ -1447,7 +1447,7 @@ func seccompTestContainer(rc internalapi.RuntimeService, ic internalapi.ImageMan
1447
1447
},
1448
1448
},
1449
1449
}
1450
- containerID : = framework .CreateContainer (rc , ic , containerConfig , podID , podConfig )
1450
+ containerID = framework .CreateContainer (rc , ic , containerConfig , podID , podConfig )
1451
1451
1452
1452
By ("start container" )
1453
1453
startContainer (rc , containerID )
0 commit comments