From 355859e707e5baffa7ddc8cf6488ae60400eb541 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 13 Mar 2017 16:30:46 +1000 Subject: [PATCH] golint&gofmt Signed-off-by: Sven Dowideit --- cmd/cloudinitsave/cloudinitsave.go | 5 +++-- cmd/control/cli.go | 10 +++++----- cmd/control/service/service.go | 10 +++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/cloudinitsave/cloudinitsave.go b/cmd/cloudinitsave/cloudinitsave.go index b2f135b6..2473bd61 100755 --- a/cmd/cloudinitsave/cloudinitsave.go +++ b/cmd/cloudinitsave/cloudinitsave.go @@ -185,7 +185,7 @@ func fetchAndSave(ds datasource.Datasource) error { scriptBytes = userDataBytes userDataBytes = []byte{} } else if isCompose(userData) { - if userDataBytes, err = composeToCloudConfig(userDataBytes); err != nil { + if userDataBytes, err = ComposeToCloudConfig(userDataBytes); err != nil { log.Errorf("Failed to convert compose to cloud-config syntax: %v", err) return err } @@ -328,8 +328,9 @@ func isCompose(content string) bool { return strings.HasPrefix(content, "#compose\n") } -//TODO: move to config? +// ComposeToCloudConfig converts a loaded compose file into a ros config struct func ComposeToCloudConfig(bytes []byte) ([]byte, error) { + //TODO: move to config? compose := make(map[interface{}]interface{}) err := yaml.Unmarshal(bytes, &compose) if err != nil { diff --git a/cmd/control/cli.go b/cmd/control/cli.go index e612ffbe..5bab850e 100755 --- a/cmd/control/cli.go +++ b/cmd/control/cli.go @@ -202,11 +202,11 @@ func listServices(c *cli.Context) error { fmt.Printf("Enabled\n") enabledServices := make([]string, len(currentConfig.Rancher.Services)+len(currentConfig.Rancher.ServicesInclude)) i := 0 - for k, _ := range currentConfig.Rancher.Services { + for k := range currentConfig.Rancher.Services { enabledServices[i] = k i++ } - for k, _ := range currentConfig.Rancher.ServicesInclude { + for k := range currentConfig.Rancher.ServicesInclude { enabledServices[i] = k i++ } @@ -224,7 +224,7 @@ func listServices(c *cli.Context) error { } if len(cachedConfigs[serviceName]) > 0 { fmt.Printf("\t\tAlternatives: ") - for serviceLongName, _ := range cachedConfigs[serviceName] { + for serviceLongName := range cachedConfigs[serviceName] { fmt.Printf("%s, ", serviceLongName) } fmt.Printf("\n") @@ -235,7 +235,7 @@ func listServices(c *cli.Context) error { if _, ok := currentConfig.Rancher.Services[serviceName]; ok { continue } - for serviceLongName, _ := range service { + for serviceLongName := range service { fmt.Printf("\t%s: %s\n", serviceName, serviceLongName) } } @@ -248,7 +248,7 @@ func GetAllServices() map[string]map[string]*libcomposeConfig.ServiceConfigV1 { result := make(map[string]map[string]*libcomposeConfig.ServiceConfigV1) cfg := config.LoadConfig() - for repoName, _ := range cfg.Rancher.Repositories { + for repoName := range cfg.Rancher.Repositories { indexPath := fmt.Sprintf("%s/index.yml", repoName) //content, err := network.LoadResource(indexPath, false) content, err := network.CacheLookup(indexPath) diff --git a/cmd/control/service/service.go b/cmd/control/service/service.go index 68ed0980..9a0b0290 100755 --- a/cmd/control/service/service.go +++ b/cmd/control/service/service.go @@ -141,8 +141,8 @@ func Del(c *cli.Context) error { return nil } -//TODO: copied from cloudinitsave, move to config. func ComposeToCloudConfig(bytes []byte) ([]byte, error) { + //TODO: copied from cloudinitsave, move to config. compose := make(map[interface{}]interface{}) err := yaml.Unmarshal(bytes, &compose) if err != nil { @@ -156,9 +156,9 @@ func ComposeToCloudConfig(bytes []byte) ([]byte, error) { }) } -// TODO: this should move to something like config/service.go? -// WARNING: this can contain more than one service - Josh and I aren't sure this is worth it func LoadService(repoName, serviceLongName string) (*config.CloudConfig, error) { + // TODO: this should move to something like config/service.go? + // WARNING: this can contain more than one service - Josh and I aren't sure this is worth it servicePath := fmt.Sprintf("%s/%s.yml", repoName, serviceLongName) //log.Infof("loading %s", serviceLongName) content, err := network.CacheLookup(servicePath) @@ -176,8 +176,8 @@ func LoadService(repoName, serviceLongName string) (*config.CloudConfig, error) return p, nil } -// TODO: this should move to something like config/service.go? func IsConsole(serviceCfg *config.CloudConfig) bool { + // TODO: this should move to something like config/service.go? //the service is called console, and has an io.rancher.os.console label. for serviceName, service := range serviceCfg.Rancher.Services { if serviceName == "console" { @@ -191,8 +191,8 @@ func IsConsole(serviceCfg *config.CloudConfig) bool { return false } -// TODO: this should move to something like config/service.go? func IsEngine(serviceCfg *config.CloudConfig) bool { + // TODO: this should move to something like config/service.go? //the service is called docker, and the command is "ros user-docker" for serviceName, service := range serviceCfg.Rancher.Services { log.Infof("serviceName == %s", serviceName)