mirror of
https://github.com/rancher/os.git
synced 2025-08-10 19:12:30 +00:00
golint&gofmt
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
2cd6ec4db6
commit
355859e707
@ -185,7 +185,7 @@ func fetchAndSave(ds datasource.Datasource) error {
|
|||||||
scriptBytes = userDataBytes
|
scriptBytes = userDataBytes
|
||||||
userDataBytes = []byte{}
|
userDataBytes = []byte{}
|
||||||
} else if isCompose(userData) {
|
} 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)
|
log.Errorf("Failed to convert compose to cloud-config syntax: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -328,8 +328,9 @@ func isCompose(content string) bool {
|
|||||||
return strings.HasPrefix(content, "#compose\n")
|
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) {
|
func ComposeToCloudConfig(bytes []byte) ([]byte, error) {
|
||||||
|
//TODO: move to config?
|
||||||
compose := make(map[interface{}]interface{})
|
compose := make(map[interface{}]interface{})
|
||||||
err := yaml.Unmarshal(bytes, &compose)
|
err := yaml.Unmarshal(bytes, &compose)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -202,11 +202,11 @@ func listServices(c *cli.Context) error {
|
|||||||
fmt.Printf("Enabled\n")
|
fmt.Printf("Enabled\n")
|
||||||
enabledServices := make([]string, len(currentConfig.Rancher.Services)+len(currentConfig.Rancher.ServicesInclude))
|
enabledServices := make([]string, len(currentConfig.Rancher.Services)+len(currentConfig.Rancher.ServicesInclude))
|
||||||
i := 0
|
i := 0
|
||||||
for k, _ := range currentConfig.Rancher.Services {
|
for k := range currentConfig.Rancher.Services {
|
||||||
enabledServices[i] = k
|
enabledServices[i] = k
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
for k, _ := range currentConfig.Rancher.ServicesInclude {
|
for k := range currentConfig.Rancher.ServicesInclude {
|
||||||
enabledServices[i] = k
|
enabledServices[i] = k
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ func listServices(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
if len(cachedConfigs[serviceName]) > 0 {
|
if len(cachedConfigs[serviceName]) > 0 {
|
||||||
fmt.Printf("\t\tAlternatives: ")
|
fmt.Printf("\t\tAlternatives: ")
|
||||||
for serviceLongName, _ := range cachedConfigs[serviceName] {
|
for serviceLongName := range cachedConfigs[serviceName] {
|
||||||
fmt.Printf("%s, ", serviceLongName)
|
fmt.Printf("%s, ", serviceLongName)
|
||||||
}
|
}
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
@ -235,7 +235,7 @@ func listServices(c *cli.Context) error {
|
|||||||
if _, ok := currentConfig.Rancher.Services[serviceName]; ok {
|
if _, ok := currentConfig.Rancher.Services[serviceName]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for serviceLongName, _ := range service {
|
for serviceLongName := range service {
|
||||||
fmt.Printf("\t%s: %s\n", serviceName, serviceLongName)
|
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)
|
result := make(map[string]map[string]*libcomposeConfig.ServiceConfigV1)
|
||||||
|
|
||||||
cfg := config.LoadConfig()
|
cfg := config.LoadConfig()
|
||||||
for repoName, _ := range cfg.Rancher.Repositories {
|
for repoName := range cfg.Rancher.Repositories {
|
||||||
indexPath := fmt.Sprintf("%s/index.yml", repoName)
|
indexPath := fmt.Sprintf("%s/index.yml", repoName)
|
||||||
//content, err := network.LoadResource(indexPath, false)
|
//content, err := network.LoadResource(indexPath, false)
|
||||||
content, err := network.CacheLookup(indexPath)
|
content, err := network.CacheLookup(indexPath)
|
||||||
|
@ -141,8 +141,8 @@ func Del(c *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: copied from cloudinitsave, move to config.
|
|
||||||
func ComposeToCloudConfig(bytes []byte) ([]byte, error) {
|
func ComposeToCloudConfig(bytes []byte) ([]byte, error) {
|
||||||
|
//TODO: copied from cloudinitsave, move to config.
|
||||||
compose := make(map[interface{}]interface{})
|
compose := make(map[interface{}]interface{})
|
||||||
err := yaml.Unmarshal(bytes, &compose)
|
err := yaml.Unmarshal(bytes, &compose)
|
||||||
if err != nil {
|
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) {
|
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)
|
servicePath := fmt.Sprintf("%s/%s.yml", repoName, serviceLongName)
|
||||||
//log.Infof("loading %s", serviceLongName)
|
//log.Infof("loading %s", serviceLongName)
|
||||||
content, err := network.CacheLookup(servicePath)
|
content, err := network.CacheLookup(servicePath)
|
||||||
@ -176,8 +176,8 @@ func LoadService(repoName, serviceLongName string) (*config.CloudConfig, error)
|
|||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this should move to something like config/service.go?
|
|
||||||
func IsConsole(serviceCfg *config.CloudConfig) bool {
|
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.
|
//the service is called console, and has an io.rancher.os.console label.
|
||||||
for serviceName, service := range serviceCfg.Rancher.Services {
|
for serviceName, service := range serviceCfg.Rancher.Services {
|
||||||
if serviceName == "console" {
|
if serviceName == "console" {
|
||||||
@ -191,8 +191,8 @@ func IsConsole(serviceCfg *config.CloudConfig) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this should move to something like config/service.go?
|
|
||||||
func IsEngine(serviceCfg *config.CloudConfig) bool {
|
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"
|
//the service is called docker, and the command is "ros user-docker"
|
||||||
for serviceName, service := range serviceCfg.Rancher.Services {
|
for serviceName, service := range serviceCfg.Rancher.Services {
|
||||||
log.Infof("serviceName == %s", serviceName)
|
log.Infof("serviceName == %s", serviceName)
|
||||||
|
Loading…
Reference in New Issue
Block a user