Line 30: warning: context.Context should be the first parameter of a function (golint)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit caec45a37faf351afc82cb6228ea2e2b48589432)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -26,8 +26,7 @@ func Create(ctx context.Context, client client.APIClient, name string, ops ...fu |
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// CreateNoError creates a network with the specified options and verifies there were no errors |
| 29 |
-// nolint: golint |
|
| 30 |
-func CreateNoError(t *testing.T, ctx context.Context, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { // nolint: golint
|
|
| 29 |
+func CreateNoError(ctx context.Context, t *testing.T, client client.APIClient, name string, ops ...func(*types.NetworkCreate)) string { // nolint: golint
|
|
| 31 | 30 |
t.Helper() |
| 32 | 31 |
|
| 33 | 32 |
name, err := createNetwork(ctx, client, name, ops...) |
| ... | ... |
@@ -28,9 +28,9 @@ func containsNetwork(nws []types.NetworkResource, networkID string) bool {
|
| 28 | 28 |
// |
| 29 | 29 |
// After successful creation, properties of all three networks is returned |
| 30 | 30 |
func createAmbiguousNetworks(t *testing.T, ctx context.Context, client dclient.APIClient) (string, string, string) { // nolint: golint
|
| 31 |
- testNet := network.CreateNoError(t, ctx, client, "testNet") |
|
| 32 |
- idPrefixNet := network.CreateNoError(t, ctx, client, testNet[:12]) |
|
| 33 |
- fullIDNet := network.CreateNoError(t, ctx, client, testNet) |
|
| 31 |
+ testNet := network.CreateNoError(ctx, t, client, "testNet") |
|
| 32 |
+ idPrefixNet := network.CreateNoError(ctx, t, client, testNet[:12]) |
|
| 33 |
+ fullIDNet := network.CreateNoError(ctx, t, client, testNet) |
|
| 34 | 34 |
|
| 35 | 35 |
nws, err := client.NetworkList(ctx, types.NetworkListOptions{})
|
| 36 | 36 |
assert.NilError(t, err) |
| ... | ... |
@@ -49,7 +49,7 @@ func TestNetworkCreateDelete(t *testing.T) {
|
| 49 | 49 |
ctx := context.Background() |
| 50 | 50 |
|
| 51 | 51 |
netName := "testnetwork_" + t.Name() |
| 52 |
- network.CreateNoError(t, ctx, client, netName, |
|
| 52 |
+ network.CreateNoError(ctx, t, client, netName, |
|
| 53 | 53 |
network.WithCheckDuplicate(), |
| 54 | 54 |
) |
| 55 | 55 |
assert.Check(t, IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -21,7 +21,7 @@ func TestInspectNetwork(t *testing.T) {
|
| 21 | 21 |
defer c.Close() |
| 22 | 22 |
|
| 23 | 23 |
networkName := "Overlay" + t.Name() |
| 24 |
- overlayID := network.CreateNoError(t, context.Background(), c, networkName, |
|
| 24 |
+ overlayID := network.CreateNoError(context.Background(), t, c, networkName, |
|
| 25 | 25 |
network.WithDriver("overlay"),
|
| 26 | 26 |
network.WithCheckDuplicate(), |
| 27 | 27 |
) |
| ... | ... |
@@ -39,7 +39,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
|
| 39 | 39 |
|
| 40 | 40 |
// create a network specifying the desired sub-interface name |
| 41 | 41 |
netName := "di-persist" |
| 42 |
- net.CreateNoError(t, context.Background(), c, netName, |
|
| 42 |
+ net.CreateNoError(context.Background(), t, c, netName, |
|
| 43 | 43 |
net.WithIPvlan("di-dummy0.70", ""),
|
| 44 | 44 |
) |
| 45 | 45 |
|
| ... | ... |
@@ -105,7 +105,7 @@ func testIpvlanSubinterface(client dclient.APIClient) func(*testing.T) {
|
| 105 | 105 |
defer n.DeleteInterface(t, master) |
| 106 | 106 |
|
| 107 | 107 |
netName := "di-subinterface" |
| 108 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 108 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 109 | 109 |
net.WithIPvlan("di-dummy0.60", ""),
|
| 110 | 110 |
) |
| 111 | 111 |
assert.Check(t, n.IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -130,7 +130,7 @@ func testIpvlanOverlapParent(client dclient.APIClient) func(*testing.T) {
|
| 130 | 130 |
n.CreateVlanInterface(t, master, parent, "30") |
| 131 | 131 |
|
| 132 | 132 |
netName := "di-subinterface" |
| 133 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 133 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 134 | 134 |
net.WithIPvlan(parent, ""), |
| 135 | 135 |
) |
| 136 | 136 |
assert.Check(t, n.IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -147,7 +147,7 @@ func testIpvlanL2NilParent(client dclient.APIClient) func(*testing.T) {
|
| 147 | 147 |
return func(t *testing.T) {
|
| 148 | 148 |
// ipvlan l2 mode - dummy parent interface is provisioned dynamically |
| 149 | 149 |
netName := "di-nil-parent" |
| 150 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 150 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 151 | 151 |
net.WithIPvlan("", ""),
|
| 152 | 152 |
) |
| 153 | 153 |
assert.Check(t, n.IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -164,7 +164,7 @@ func testIpvlanL2NilParent(client dclient.APIClient) func(*testing.T) {
|
| 164 | 164 |
func testIpvlanL2InternalMode(client dclient.APIClient) func(*testing.T) {
|
| 165 | 165 |
return func(t *testing.T) {
|
| 166 | 166 |
netName := "di-internal" |
| 167 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 167 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 168 | 168 |
net.WithIPvlan("", ""),
|
| 169 | 169 |
net.WithInternal(), |
| 170 | 170 |
) |
| ... | ... |
@@ -189,7 +189,7 @@ func testIpvlanL2InternalMode(client dclient.APIClient) func(*testing.T) {
|
| 189 | 189 |
func testIpvlanL3NilParent(client dclient.APIClient) func(*testing.T) {
|
| 190 | 190 |
return func(t *testing.T) {
|
| 191 | 191 |
netName := "di-nil-parent-l3" |
| 192 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 192 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 193 | 193 |
net.WithIPvlan("", "l3"),
|
| 194 | 194 |
net.WithIPAM("172.28.230.0/24", ""),
|
| 195 | 195 |
net.WithIPAM("172.28.220.0/24", ""),
|
| ... | ... |
@@ -214,7 +214,7 @@ func testIpvlanL3NilParent(client dclient.APIClient) func(*testing.T) {
|
| 214 | 214 |
func testIpvlanL3InternalMode(client dclient.APIClient) func(*testing.T) {
|
| 215 | 215 |
return func(t *testing.T) {
|
| 216 | 216 |
netName := "di-internal-l3" |
| 217 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 217 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 218 | 218 |
net.WithIPvlan("", "l3"),
|
| 219 | 219 |
net.WithInternal(), |
| 220 | 220 |
net.WithIPAM("172.28.230.0/24", ""),
|
| ... | ... |
@@ -247,7 +247,7 @@ func testIpvlanL3InternalMode(client dclient.APIClient) func(*testing.T) {
|
| 247 | 247 |
func testIpvlanL2MultiSubnet(client dclient.APIClient) func(*testing.T) {
|
| 248 | 248 |
return func(t *testing.T) {
|
| 249 | 249 |
netName := "dualstackl2" |
| 250 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 250 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 251 | 251 |
net.WithIPvlan("", ""),
|
| 252 | 252 |
net.WithIPv6(), |
| 253 | 253 |
net.WithIPAM("172.28.200.0/24", ""),
|
| ... | ... |
@@ -314,7 +314,7 @@ func testIpvlanL2MultiSubnet(client dclient.APIClient) func(*testing.T) {
|
| 314 | 314 |
func testIpvlanL3MultiSubnet(client dclient.APIClient) func(*testing.T) {
|
| 315 | 315 |
return func(t *testing.T) {
|
| 316 | 316 |
netName := "dualstackl3" |
| 317 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 317 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 318 | 318 |
net.WithIPvlan("", "l3"),
|
| 319 | 319 |
net.WithIPv6(), |
| 320 | 320 |
net.WithIPAM("172.28.10.0/24", ""),
|
| ... | ... |
@@ -383,7 +383,7 @@ func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) {
|
| 383 | 383 |
// Verify ipvlan l2 mode sets the proper default gateway routes via netlink |
| 384 | 384 |
// for either an explicitly set route by the user or inferred via default IPAM |
| 385 | 385 |
netNameL2 := "dualstackl2" |
| 386 |
- net.CreateNoError(t, context.Background(), client, netNameL2, |
|
| 386 |
+ net.CreateNoError(context.Background(), t, client, netNameL2, |
|
| 387 | 387 |
net.WithIPvlan("", "l2"),
|
| 388 | 388 |
net.WithIPv6(), |
| 389 | 389 |
net.WithIPAM("172.28.140.0/24", "172.28.140.254"),
|
| ... | ... |
@@ -406,7 +406,7 @@ func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) {
|
| 406 | 406 |
|
| 407 | 407 |
// Validate ipvlan l3 mode sets the v4 gateway to dev eth0 and disregards any explicit or inferred next-hops |
| 408 | 408 |
netNameL3 := "dualstackl3" |
| 409 |
- net.CreateNoError(t, context.Background(), client, netNameL3, |
|
| 409 |
+ net.CreateNoError(context.Background(), t, client, netNameL3, |
|
| 410 | 410 |
net.WithIPvlan("", "l3"),
|
| 411 | 411 |
net.WithIPv6(), |
| 412 | 412 |
net.WithIPAM("172.28.160.0/24", "172.28.160.254"),
|
| ... | ... |
@@ -33,7 +33,7 @@ func TestDockerNetworkMacvlanPersistance(t *testing.T) {
|
| 33 | 33 |
c := d.NewClientT(t) |
| 34 | 34 |
|
| 35 | 35 |
netName := "dm-persist" |
| 36 |
- net.CreateNoError(t, context.Background(), c, netName, |
|
| 36 |
+ net.CreateNoError(context.Background(), t, c, netName, |
|
| 37 | 37 |
net.WithMacvlan("dm-dummy0.60"),
|
| 38 | 38 |
) |
| 39 | 39 |
assert.Check(t, n.IsNetworkAvailable(c, netName)) |
| ... | ... |
@@ -86,7 +86,7 @@ func testMacvlanOverlapParent(client client.APIClient) func(*testing.T) {
|
| 86 | 86 |
|
| 87 | 87 |
netName := "dm-subinterface" |
| 88 | 88 |
parentName := "dm-dummy0.40" |
| 89 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 89 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 90 | 90 |
net.WithMacvlan(parentName), |
| 91 | 91 |
) |
| 92 | 92 |
assert.Check(t, n.IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -116,7 +116,7 @@ func testMacvlanSubinterface(client client.APIClient) func(*testing.T) {
|
| 116 | 116 |
n.CreateVlanInterface(t, master, parentName, "20") |
| 117 | 117 |
|
| 118 | 118 |
netName := "dm-subinterface" |
| 119 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 119 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 120 | 120 |
net.WithMacvlan(parentName), |
| 121 | 121 |
) |
| 122 | 122 |
assert.Check(t, n.IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -135,7 +135,7 @@ func testMacvlanNilParent(client client.APIClient) func(*testing.T) {
|
| 135 | 135 |
return func(t *testing.T) {
|
| 136 | 136 |
// macvlan bridge mode - dummy parent interface is provisioned dynamically |
| 137 | 137 |
netName := "dm-nil-parent" |
| 138 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 138 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 139 | 139 |
net.WithMacvlan(""),
|
| 140 | 140 |
) |
| 141 | 141 |
assert.Check(t, n.IsNetworkAvailable(client, netName)) |
| ... | ... |
@@ -153,7 +153,7 @@ func testMacvlanInternalMode(client client.APIClient) func(*testing.T) {
|
| 153 | 153 |
return func(t *testing.T) {
|
| 154 | 154 |
// macvlan bridge mode - dummy parent interface is provisioned dynamically |
| 155 | 155 |
netName := "dm-internal" |
| 156 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 156 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 157 | 157 |
net.WithMacvlan(""),
|
| 158 | 158 |
net.WithInternal(), |
| 159 | 159 |
) |
| ... | ... |
@@ -178,7 +178,7 @@ func testMacvlanInternalMode(client client.APIClient) func(*testing.T) {
|
| 178 | 178 |
func testMacvlanMultiSubnet(client client.APIClient) func(*testing.T) {
|
| 179 | 179 |
return func(t *testing.T) {
|
| 180 | 180 |
netName := "dualstackbridge" |
| 181 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 181 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 182 | 182 |
net.WithMacvlan(""),
|
| 183 | 183 |
net.WithIPv6(), |
| 184 | 184 |
net.WithIPAM("172.28.100.0/24", ""),
|
| ... | ... |
@@ -247,7 +247,7 @@ func testMacvlanAddressing(client client.APIClient) func(*testing.T) {
|
| 247 | 247 |
return func(t *testing.T) {
|
| 248 | 248 |
// Ensure the default gateways, next-hops and default dev devices are properly set |
| 249 | 249 |
netName := "dualstackbridge" |
| 250 |
- net.CreateNoError(t, context.Background(), client, netName, |
|
| 250 |
+ net.CreateNoError(context.Background(), t, client, netName, |
|
| 251 | 251 |
net.WithMacvlan(""),
|
| 252 | 252 |
net.WithIPv6(), |
| 253 | 253 |
net.WithOption("macvlan_mode", "bridge"),
|
| ... | ... |
@@ -71,7 +71,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
| 71 | 71 |
|
| 72 | 72 |
// Create a bridge network and verify its subnet is the second default pool |
| 73 | 73 |
name := "elango" + t.Name() |
| 74 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 74 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 75 | 75 |
network.WithDriver("bridge"),
|
| 76 | 76 |
) |
| 77 | 77 |
out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
|
| ... | ... |
@@ -80,7 +80,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) {
|
| 80 | 80 |
|
| 81 | 81 |
// Create a bridge network and verify its subnet is the third default pool |
| 82 | 82 |
name = "saanvi" + t.Name() |
| 83 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 83 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 84 | 84 |
network.WithDriver("bridge"),
|
| 85 | 85 |
) |
| 86 | 86 |
out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
|
| ... | ... |
@@ -103,7 +103,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) {
|
| 103 | 103 |
|
| 104 | 104 |
// Create a bridge network |
| 105 | 105 |
name := "elango" + t.Name() |
| 106 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 106 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 107 | 107 |
network.WithDriver("bridge"),
|
| 108 | 108 |
) |
| 109 | 109 |
|
| ... | ... |
@@ -136,7 +136,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
| 136 | 136 |
|
| 137 | 137 |
// Create a bridge network |
| 138 | 138 |
name := "elango" + t.Name() |
| 139 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 139 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 140 | 140 |
network.WithDriver("bridge"),
|
| 141 | 141 |
) |
| 142 | 142 |
|
| ... | ... |
@@ -147,7 +147,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
| 147 | 147 |
|
| 148 | 148 |
// Create a bridge network |
| 149 | 149 |
name = "sthira" + t.Name() |
| 150 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 150 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 151 | 151 |
network.WithDriver("bridge"),
|
| 152 | 152 |
) |
| 153 | 153 |
out, err = c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
|
| ... | ... |
@@ -162,7 +162,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
|
| 162 | 162 |
|
| 163 | 163 |
// Create a bridge network |
| 164 | 164 |
name = "saanvi" + t.Name() |
| 165 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 165 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 166 | 166 |
network.WithDriver("bridge"),
|
| 167 | 167 |
) |
| 168 | 168 |
out1, err := c.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
|
| ... | ... |
@@ -343,7 +343,7 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
|
| 343 | 343 |
|
| 344 | 344 |
// Create a overlay network |
| 345 | 345 |
name := "saanvisthira" + t.Name() |
| 346 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 346 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 347 | 347 |
network.WithDriver("overlay"))
|
| 348 | 348 |
|
| 349 | 349 |
var instances uint64 = 1 |
| ... | ... |
@@ -369,7 +369,7 @@ func TestServiceWithDataPathPortInit(t *testing.T) {
|
| 369 | 369 |
|
| 370 | 370 |
// Create a overlay network |
| 371 | 371 |
name = "saanvisthira" + t.Name() |
| 372 |
- network.CreateNoError(t, context.Background(), c, name, |
|
| 372 |
+ network.CreateNoError(context.Background(), t, c, name, |
|
| 373 | 373 |
network.WithDriver("overlay"))
|
| 374 | 374 |
|
| 375 | 375 |
serviceID = swarm.CreateService(t, d, |
| ... | ... |
@@ -402,7 +402,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) {
|
| 402 | 402 |
|
| 403 | 403 |
// Create a overlay network |
| 404 | 404 |
name := "saanvisthira" + t.Name() |
| 405 |
- network.CreateNoError(t, context.Background(), cli, name, |
|
| 405 |
+ network.CreateNoError(context.Background(), t, cli, name, |
|
| 406 | 406 |
network.WithDriver("overlay"))
|
| 407 | 407 |
|
| 408 | 408 |
var instances uint64 = 1 |
| ... | ... |
@@ -84,7 +84,7 @@ func TestCreateServiceMultipleTimes(t *testing.T) {
|
| 84 | 84 |
ctx := context.Background() |
| 85 | 85 |
|
| 86 | 86 |
overlayName := "overlay1_" + t.Name() |
| 87 |
- overlayID := network.CreateNoError(t, ctx, client, overlayName, |
|
| 87 |
+ overlayID := network.CreateNoError(ctx, t, client, overlayName, |
|
| 88 | 88 |
network.WithCheckDuplicate(), |
| 89 | 89 |
network.WithDriver("overlay"),
|
| 90 | 90 |
) |
| ... | ... |
@@ -175,11 +175,11 @@ func TestCreateWithDuplicateNetworkNames(t *testing.T) {
|
| 175 | 175 |
ctx := context.Background() |
| 176 | 176 |
|
| 177 | 177 |
name := "foo_" + t.Name() |
| 178 |
- n1 := network.CreateNoError(t, ctx, client, name, network.WithDriver("bridge"))
|
|
| 179 |
- n2 := network.CreateNoError(t, ctx, client, name, network.WithDriver("bridge"))
|
|
| 178 |
+ n1 := network.CreateNoError(ctx, t, client, name, network.WithDriver("bridge"))
|
|
| 179 |
+ n2 := network.CreateNoError(ctx, t, client, name, network.WithDriver("bridge"))
|
|
| 180 | 180 |
|
| 181 | 181 |
// Duplicates with name but with different driver |
| 182 |
- n3 := network.CreateNoError(t, ctx, client, name, network.WithDriver("overlay"))
|
|
| 182 |
+ n3 := network.CreateNoError(ctx, t, client, name, network.WithDriver("overlay"))
|
|
| 183 | 183 |
|
| 184 | 184 |
// Create Service with the same name |
| 185 | 185 |
var instances uint64 = 1 |
| ... | ... |
@@ -24,7 +24,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
|
| 24 | 24 |
ctx := context.Background() |
| 25 | 25 |
|
| 26 | 26 |
name := t.Name() + "test-alias" |
| 27 |
- net.CreateNoError(t, ctx, client, name, |
|
| 27 |
+ net.CreateNoError(ctx, t, client, name, |
|
| 28 | 28 |
net.WithDriver("overlay"),
|
| 29 | 29 |
net.WithAttachable(), |
| 30 | 30 |
) |
| ... | ... |
@@ -207,7 +207,7 @@ func TestServiceUpdateNetwork(t *testing.T) {
|
| 207 | 207 |
|
| 208 | 208 |
// Create a overlay network |
| 209 | 209 |
testNet := "testNet" + t.Name() |
| 210 |
- overlayID := network.CreateNoError(t, ctx, cli, testNet, |
|
| 210 |
+ overlayID := network.CreateNoError(ctx, t, cli, testNet, |
|
| 211 | 211 |
network.WithDriver("overlay"))
|
| 212 | 212 |
|
| 213 | 213 |
var instances uint64 = 1 |