@@ -95,7 +95,7 @@ func TestPushArchs(t *testing.T) {
95
95
t .Run (testCase .name , func (t * testing.T ) {
96
96
cmd := info .configuredCmd
97
97
ref := info .registryAddress + "/test/push-pull:1"
98
- args := []string {"app" , "push" , "--tag" , ref , "--insecure-registries=" + info . registryAddress }
98
+ args := []string {"app" , "push" , "--tag" , ref }
99
99
args = append (args , testCase .args ... )
100
100
args = append (args , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
101
101
cmd .Command = dockerCli .Command (args ... )
@@ -121,14 +121,31 @@ func TestPushArchs(t *testing.T) {
121
121
})
122
122
}
123
123
124
+ func TestPushInsecureRegistry (t * testing.T ) {
125
+ runWithDindSwarmAndRegistry (t , func (info dindSwarmAndRegistryInfo ) {
126
+ ref := info .registryAddress + "/test/push-insecure"
127
+
128
+ // create a command outside of the dind context so without the insecure registry configured
129
+ cmd2 , cleanup2 := dockerCli .createTestCmd ()
130
+ defer cleanup2 ()
131
+ cmd2 .Command = dockerCli .Command ("app" , "push" , "--tag" , ref , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
132
+ icmd .RunCmd (cmd2 ).Assert (t , icmd.Expected {ExitCode : 1 })
133
+
134
+ // run the push with the command inside dind context configured to allow access to the insecure registry
135
+ cmd := info .configuredCmd
136
+ cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
137
+ icmd .RunCmd (cmd ).Assert (t , icmd .Success )
138
+ })
139
+ }
140
+
124
141
func TestPushInstall (t * testing.T ) {
125
142
runWithDindSwarmAndRegistry (t , func (info dindSwarmAndRegistryInfo ) {
126
143
cmd := info .configuredCmd
127
144
ref := info .registryAddress + "/test/push-pull"
128
- cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref , "--insecure-registries=" + info . registryAddress , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
145
+ cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
129
146
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
130
147
131
- cmd .Command = dockerCli .Command ("app" , "install" , "--insecure-registries=" + info . registryAddress , ref , "--name" , t .Name ())
148
+ cmd .Command = dockerCli .Command ("app" , "install" , ref , "--name" , t .Name ())
132
149
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
133
150
cmd .Command = dockerCli .Command ("service" , "ls" )
134
151
assert .Check (t , cmp .Contains (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), ref ))
@@ -140,16 +157,16 @@ func TestPushPullInstall(t *testing.T) {
140
157
cmd := info .configuredCmd
141
158
ref := info .registryAddress + "/test/push-pull"
142
159
tag := ":v.0.0.1"
143
- cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref + tag , "--insecure-registries=" + info . registryAddress , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
160
+ cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref + tag , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
144
161
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
145
- cmd .Command = dockerCli .Command ("app" , "pull" , ref + tag , "--insecure-registries=" + info . registryAddress )
162
+ cmd .Command = dockerCli .Command ("app" , "pull" , ref + tag )
146
163
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
147
164
148
165
// stop the registry
149
166
info .stopRegistry ()
150
167
151
168
// install without --pull should succeed (rely on local store)
152
- cmd .Command = dockerCli .Command ("app" , "install" , "--insecure-registries=" + info . registryAddress , ref + tag , "--name" , t .Name ())
169
+ cmd .Command = dockerCli .Command ("app" , "install" , ref + tag , "--name" , t .Name ())
153
170
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
154
171
cmd .Command = dockerCli .Command ("service" , "ls" )
155
172
assert .Check (t , cmp .Contains (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), ref ))
@@ -162,7 +179,7 @@ func TestPushPullInstall(t *testing.T) {
162
179
})
163
180
164
181
// install with --pull should fail (registry is stopped)
165
- cmd .Command = dockerCli .Command ("app" , "install" , "--pull" , "--insecure-registries=" + info . registryAddress , ref , "--name" , t .Name ()+ "2" )
182
+ cmd .Command = dockerCli .Command ("app" , "install" , "--pull" , ref , "--name" , t .Name ()+ "2" )
166
183
assert .Check (t , cmp .Contains (icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 1 }).Combined (), "failed to resolve bundle manifest" ))
167
184
})
168
185
}
@@ -183,10 +200,10 @@ func TestPushInstallBundle(t *testing.T) {
183
200
// push it and install to check it is available
184
201
t .Run ("push-bundle" , func (t * testing.T ) {
185
202
name := strings .Replace (t .Name (), "/" , "_" , 1 )
186
- cmd .Command = dockerCli .Command ("app" , "push" , "--insecure-registries=" + info . registryAddress , "-- tag" , ref , bundleFile )
203
+ cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref , bundleFile )
187
204
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
188
205
189
- cmd .Command = dockerCli .Command ("app" , "install" , "--insecure-registries=" + info . registryAddress , ref , "--name" , name )
206
+ cmd .Command = dockerCli .Command ("app" , "install" , ref , "--name" , name )
190
207
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
191
208
cmd .Command = dockerCli .Command ("service" , "ls" )
192
209
assert .Check (t , cmp .Contains (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), ref ))
@@ -203,10 +220,10 @@ func TestPushInstallBundle(t *testing.T) {
203
220
t .Run ("push-ref" , func (t * testing.T ) {
204
221
name := strings .Replace (t .Name (), "/" , "_" , 1 )
205
222
ref2 := info .registryAddress + "/test/push-ref"
206
- cmd .Command = dockerCli .Command ("app" , "push" , "--insecure-registries=" + info . registryAddress , "-- tag" , ref2 , ref + ":latest" )
223
+ cmd .Command = dockerCli .Command ("app" , "push" , "--tag" , ref2 , ref + ":latest" )
207
224
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
208
225
209
- cmd .Command = dockerCli .Command ("app" , "install" , "--insecure-registries=" + info . registryAddress , ref2 , "--name" , name )
226
+ cmd .Command = dockerCli .Command ("app" , "install" , ref2 , "--name" , name )
210
227
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
211
228
cmd .Command = dockerCli .Command ("service" , "ls" )
212
229
assert .Check (t , cmp .Contains (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), ref2 ))
@@ -218,16 +235,22 @@ func TestPushInstallBundle(t *testing.T) {
218
235
ref2 := ref + ":v0.42"
219
236
// Create a new command so the bundle store can be trashed before installing the app
220
237
cmd2 , cleanup2 := dockerCli .createTestCmd ()
238
+
239
+ // Enter the same context as `cmd` to run commands within the same environment
240
+ cmd2 .Command = dockerCli .Command ("context" , "create" , "swarm-context" , "--docker" , fmt .Sprintf (`"host=tcp://%s"` , info .swarmAddress ))
241
+ icmd .RunCmd (cmd2 ).Assert (t , icmd .Success )
242
+ cmd2 .Env = append (cmd2 .Env , "DOCKER_CONTEXT=swarm-context" )
243
+
221
244
// bundle the app again but this time with a tag to store it into the bundle store
222
245
cmd2 .Command = dockerCli .Command ("app" , "bundle" , "--tag" , ref2 , "-o" , bundleFile , filepath .Join ("testdata" , "push-pull" , "push-pull.dockerapp" ))
223
246
icmd .RunCmd (cmd2 ).Assert (t , icmd .Success )
224
247
// Push the app without tagging it explicitly
225
- cmd2 .Command = dockerCli .Command ("app" , "push" , "--insecure-registries=" + info . registryAddress , ref2 )
248
+ cmd2 .Command = dockerCli .Command ("app" , "push" , ref2 )
226
249
icmd .RunCmd (cmd2 ).Assert (t , icmd .Success )
227
250
// remove the bundle from the bundle store to be sure it won't be used instead of registry
228
251
cleanup2 ()
229
252
// install from the registry
230
- cmd .Command = dockerCli .Command ("app" , "install" , "--insecure-registries=" + info . registryAddress , ref2 , "--name" , name )
253
+ cmd .Command = dockerCli .Command ("app" , "install" , ref2 , "--name" , name )
231
254
icmd .RunCmd (cmd ).Assert (t , icmd .Success )
232
255
cmd .Command = dockerCli .Command ("service" , "ls" )
233
256
assert .Check (t , cmp .Contains (icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined (), ref ))
0 commit comments