Skip to content

Commit

Permalink
initContainer use long commands
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Lin committed Aug 31, 2018
1 parent a53be40 commit 9b12b0e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ func generateClientCommand(network entity.DeploymentNetwork) (command []string)
ip := utils.IPToCIDR(network.IPAddress, network.Netmask)

command = []string{
"-s=unix:///tmp/vortex.sock",
"-b=" + network.BridgeName,
"-n=" + network.IfName,
"-i=" + ip,
"--server=unix:///tmp/vortex.sock",
"--bridge=" + network.BridgeName,
"--nic=" + network.IfName,
"--ip=" + ip,
}

if network.VlanTag != nil {
command = append(command, "-v="+strconv.Itoa((int)(*network.VlanTag)))
command = append(command, "--vlan="+strconv.Itoa((int)(*network.VlanTag)))
}
if len(network.RoutesGw) != 0 {
for _, netroute := range network.RoutesGw {
Expand Down
15 changes: 13 additions & 2 deletions src/deployment/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,25 @@ func (suite *DeploymentTestSuite) TestGenerateClientCommand() {
BridgeName: bName,
}
command := generateClientCommand(deployNetwork)
ans := []string{"-s=unix:///tmp/vortex.sock", "-b=" + bName, "-n=" + ifName, "-i=1.2.3.4/24"}
ans := []string{
"--server=unix:///tmp/vortex.sock",
"--bridge=" + bName,
"--nic=" + ifName,
"--ip=1.2.3.4/24",
}
suite.Equal(ans, command)

var vlanTag int32
vlanTag = 123
deployNetwork.VlanTag = &vlanTag
command = generateClientCommand(deployNetwork)
ans = []string{"-s=unix:///tmp/vortex.sock", "-b=" + bName, "-n=" + ifName, "-i=1.2.3.4/24", "-v=123"}
ans = []string{
"--server=unix:///tmp/vortex.sock",
"--bridge=" + bName,
"--nic=" + ifName,
"--ip=1.2.3.4/24",
"--vlan=123",
}
suite.Equal(ans, command)

}
Expand Down
10 changes: 5 additions & 5 deletions src/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ func generateClientCommand(network entity.PodNetwork) (command []string) {
ip := utils.IPToCIDR(network.IPAddress, network.Netmask)

command = []string{
"-s=unix:///tmp/vortex.sock",
"-b=" + network.BridgeName,
"-n=" + network.IfName,
"-i=" + ip,
"--server=unix:///tmp/vortex.sock",
"--bridge=" + network.BridgeName,
"--nic=" + network.IfName,
"--ip=" + ip,
}

if network.VlanTag != nil {
command = append(command, "-v="+strconv.Itoa((int)(*network.VlanTag)))
command = append(command, "--vlan="+strconv.Itoa((int)(*network.VlanTag)))
}
if len(network.RoutesGw) != 0 {
for _, netroute := range network.RoutesGw {
Expand Down
18 changes: 9 additions & 9 deletions src/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ func (suite *PodTestSuite) TestGenerateClientCommand() {
}
command := generateClientCommand(podNetwork)
ans := []string{
"-s=unix:///tmp/vortex.sock",
"-b=" + bName,
"-n=" + ifName,
"-i=1.2.3.4/24",
"--server=unix:///tmp/vortex.sock",
"--bridge=" + bName,
"--nic=" + ifName,
"--ip=1.2.3.4/24",
"--route-gw=192.168.2.0/24,192.168.2.254",
"--route-intf=192.168.3.0/24",
}
Expand All @@ -287,11 +287,11 @@ func (suite *PodTestSuite) TestGenerateClientCommand() {
podNetwork.VlanTag = &vlanTag
command = generateClientCommand(podNetwork)
ans = []string{
"-s=unix:///tmp/vortex.sock",
"-b=" + bName,
"-n=" + ifName,
"-i=1.2.3.4/24",
"-v=123",
"--server=unix:///tmp/vortex.sock",
"--bridge=" + bName,
"--nic=" + ifName,
"--ip=1.2.3.4/24",
"--vlan=123",
"--route-gw=192.168.2.0/24,192.168.2.254",
"--route-intf=192.168.3.0/24",
}
Expand Down

0 comments on commit 9b12b0e

Please sign in to comment.