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 mounts option for tinet spec #2

Merged
merged 1 commit into from
Jan 19, 2020
Merged
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
15 changes: 15 additions & 0 deletions internal/pkg/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Node struct {
Image string `yaml:"image"`
Interfaces []Interface `yaml:"interfaces" mapstructure:"interfaces"`
Sysctls []Sysctl `yaml:"sysctls" mapstructure:"sysctls"`
Mounts []string `yaml:"mounts,flow"`
}

// Interface
Expand Down Expand Up @@ -367,6 +368,13 @@ func CreateNode(node Node) []string {
createNodeCmd += fmt.Sprintf("--sysctl %s ", sysctl.Sysctl)
}
}

if len(node.Mounts) != 0 {
for _, mount := range node.Mounts {
createNodeCmd += fmt.Sprintf("-v %s ", mount)
}
}

createNodeCmd += node.Image
} else if node.Type == "netns" {
createNodeCmd = fmt.Sprintf("ip netns add %s", node.Name)
Expand All @@ -377,6 +385,13 @@ func CreateNode(node Node) []string {
createNodeCmd += fmt.Sprintf("--sysctl %s ", sysctl.Sysctl)
}
}

if len(node.Mounts) != 0 {
for _, mount := range node.Mounts {
createNodeCmd += fmt.Sprintf("-v %s ", mount)
}
}

createNodeCmd += node.Image
} else {
// err := fmt.Errorf("unknown nodetype %s", node.Type)
Expand Down