1
0
mirror of https://github.com/rancher/os.git synced 2025-08-01 15:08:47 +00:00

golint&gofmt

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit 2017-03-13 16:30:46 +10:00
parent 2cd6ec4db6
commit 355859e707
3 changed files with 13 additions and 12 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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)