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

Fix bug yaml parsing #12

Merged
merged 2 commits into from
Jan 31, 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
27 changes: 6 additions & 21 deletions internal/pkg/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ type PostFini struct {

// Node
type Node struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
NetBase string `yaml:"net_base"`
Image string `yaml:"image"`
Name string `yaml:"name" mapstructure:"name"`
Type string `yaml:"type" mapstructure:"type"`
NetBase string `yaml:"net_base" mapstructure:"net_base"`
Image string `yaml:"image" mapstructure:"image"`
Interfaces []Interface `yaml:"interfaces" mapstructure:"interfaces"`
Sysctls []Sysctl `yaml:"sysctls" mapstructure:"sysctls"`
Mounts []string `yaml:"mounts,flow"`
Mounts []string `yaml:"mounts,flow" mapstructure:"mounts,flow"`
}

// Interface
Expand Down Expand Up @@ -351,7 +351,7 @@ func (node *Node) CreateNode() []string {
if node.NetBase == "" {
node.NetBase = "none"
}
if node.Type == "docker" {
if node.Type == "docker" || node.Type == "" {
createNodeCmd = fmt.Sprintf("docker run -td --hostname %s --net %s --name %s --rm --privileged ", node.Name, node.NetBase, node.Name)
if len(node.Sysctls) != 0 {
for _, sysctl := range node.Sysctls {
Expand All @@ -368,21 +368,6 @@ func (node *Node) CreateNode() []string {
createNodeCmd += node.Image
} else if node.Type == "netns" {
createNodeCmd = fmt.Sprintf("ip netns add %s", node.Name)
} else if node.Type == "" {
createNodeCmd = fmt.Sprintf("docker run -td --hostname %s --net %s --name %s --rm --privileged ", node.Name, node.NetBase, node.Name)
if len(node.Sysctls) != 0 {
for _, sysctl := range node.Sysctls {
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)
// log.Fatal(err)
Expand Down