Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route entity & update generateClientCommand #168

Merged
merged 3 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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