Skip to content

Commit

Permalink
Merge pull request #168 from linkernetworks/sufuf3/update-PodNetwork-…
Browse files Browse the repository at this point in the history
…struct

Add route entity & update generateClientCommand
  • Loading branch information
John-Lin authored Jul 25, 2018
2 parents c7b3cc6 + 3d59825 commit f64e954
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/entity/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@ type Container struct {
Command []string `bson:"command" json:"command" validate:"required,dive,required"`
}

// PodRoute is the structure for add IP routing table
type PodRoute struct {
DstCIDR string `bson:"dstCIDR" json:"dstCIDR" validate:"required,cidr"`
Gateway string `bson:"gateway" json:"gateway" validate:"required,ip"`
}

// PodNetwork is the structure for pod network info
type PodNetwork struct {
Name string `bson:"name" json:"name"`
IfName string `bson:"ifName" json:"ifName"`
VlanTag *int32 `bson:"vlanTag" json:"vlanTag"`
IPAddress string `bson:"ipAddress" json:"ipAddress"`
Netmask string `bson:"netmask" json:"netmask"`
BridgeName string `bson:"bridgeName" json:"bridgeName"` //its from the entity.Network entity
Name string `bson:"name" json:"name"`
IfName string `bson:"ifName" json:"ifName"`
VlanTag *int32 `bson:"vlanTag" json:"vlanTag"`
IPAddress string `bson:"ipAddress" json:"ipAddress"`
Netmask string `bson:"netmask" json:"netmask"`
Routes []PodRoute `bson:"routes,omitempty" json:"routes"`
BridgeName string `bson:"bridgeName" json:"bridgeName"` //its from the entity.Network entity
}

// PodVolume is the structure for pof volume info
// PodVolume is the structure for pod volume info
type PodVolume struct {
Name string `bson:"name" json:"name" validate:"required"`
MountPath string `bson:"mountPath" json:"mountPath" validate:"required"`
Expand Down
8 changes: 8 additions & 0 deletions src/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func generateClientCommand(network entity.PodNetwork) (command []string) {
if network.VlanTag != nil {
command = append(command, "-v="+strconv.Itoa((int)(*network.VlanTag)))
}
// Support one command with one add route in first version
if network.Routes != nil {
if network.Routes[0].Gateway != "" {
command = append(command, "--net="+network.Routes[0].DstCIDR, "-g="+network.Routes[0].Gateway)
} else {
command = append(command, "--net="+network.Routes[0].DstCIDR)
}
}
return
}

Expand Down

0 comments on commit f64e954

Please sign in to comment.