func upCommandFunc(c *cli.Context) { config, err := config.ParseConfig("vanguard.yml") if err != nil { fmt.Println(err) return } tiers, err := config.GetTiers() if err != nil { fmt.Println(err) return } err = config.PullRemoteFiles(c.Bool("replace-files")) if err != nil { fmt.Println(err) return } if c.Bool("dry") { ShowTiers(tiers) return } manager := &ContainerManager{ EnvVariables: make(map[string]string), Clients: make(map[string]*client.Client), RunningContainers: make(map[string][]*container.Container), UsedContainerNames: make(map[string][]string), } for _, server := range config.Servers { c := client.NewClient(server.Hostname) bindings, err := c.Bindings() for _, binding := range bindings { err = c.Hide(binding.Port, "", "") if err != nil { fmt.Println(err) return } } if server.Label != "" { host, err := c.Host() if err == nil && host.InternalIp != "" { manager.EnvVariables[server.Label] = host.InternalIp } } if server.Expose == nil { continue } for _, expose := range server.Expose { arr := strings.Split(expose, ":") if len(arr) != 3 { continue } manager.CustomExpose(server.Hostname, arr[0], arr[1], arr[2]) } } for _, tier := range tiers { for _, server := range tier.Servers { for _, cont := range server.Containers { manager.Manage(server.Hostname, cont) if err != nil { fmt.Println(err) return } } } } manager.StopUnused() }