1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 14:48:55 +00:00

Fix golint errors

This commit is contained in:
Josh Curl
2016-11-28 00:06:00 -08:00
parent fa1dc760f2
commit a7c34b9855
35 changed files with 205 additions and 212 deletions

View File

@@ -14,7 +14,7 @@ func Main() {
app.Name = os.Args[0]
app.Usage = "Control and configure RancherOS"
app.Version = config.VERSION
app.Version = config.Version
app.Author = "Rancher Labs, Inc."
app.EnableBashCompletion = true
app.Before = func(c *cli.Context) error {

View File

@@ -104,7 +104,7 @@ func imagesFromConfig(cfg *config.CloudConfig) []string {
i := 0
for image := range imagesMap {
images[i] = image
i += 1
i++
}
sort.Strings(images)
return images

View File

@@ -79,9 +79,9 @@ func consoleSwitch(c *cli.Context) error {
Privileged: true,
Net: "host",
Pid: "host",
Image: config.OS_BASE,
Image: config.OsBase,
Labels: map[string]string{
config.SCOPE: config.SYSTEM,
config.ScopeLabel: config.System,
},
Command: []string{"/usr/bin/ros", "switch-console", newConsole},
VolumesFrom: []string{"all-volumes"},

View File

@@ -219,8 +219,8 @@ func setupSSH(cfg *config.CloudConfig) error {
continue
}
saved, savedExists := cfg.Rancher.Ssh.Keys[keyType]
pub, pubExists := cfg.Rancher.Ssh.Keys[keyType+"-pub"]
saved, savedExists := cfg.Rancher.SSH.Keys[keyType]
pub, pubExists := cfg.Rancher.SSH.Keys[keyType+"-pub"]
if savedExists && pubExists {
// TODO check permissions

View File

@@ -60,7 +60,7 @@ func entrypointAction(c *cli.Context) error {
}
func writeFiles(cfg *config.CloudConfig) error {
id, err := util.GetCurrentContainerId()
id, err := util.GetCurrentContainerID()
if err != nil {
return err
}
@@ -92,10 +92,10 @@ func setupPowerOperations() {
}
for _, link := range []symlink{
{config.ROS_BIN, "/sbin/poweroff"},
{config.ROS_BIN, "/sbin/reboot"},
{config.ROS_BIN, "/sbin/halt"},
{config.ROS_BIN, "/sbin/shutdown"},
{config.RosBin, "/sbin/poweroff"},
{config.RosBin, "/sbin/reboot"},
{config.RosBin, "/sbin/halt"},
{config.RosBin, "/sbin/shutdown"},
} {
if err := os.Symlink(link.oldname, link.newname); err != nil {
log.Error(err)

View File

@@ -66,7 +66,7 @@ func installAction(c *cli.Context) error {
image := c.String("image")
cfg := config.LoadConfig()
if image == "" {
image = cfg.Rancher.Upgrade.Image + ":" + config.VERSION + config.SUFFIX
image = cfg.Rancher.Upgrade.Image + ":" + config.Version + config.Suffix
}
installType := c.String("install-type")

View File

@@ -80,30 +80,30 @@ func osSubcommands() []cli.Command {
// TODO: this and the getLatestImage should probably move to utils/network and be suitably cached.
func getImages() (*Images, error) {
upgradeUrl, err := getUpgradeUrl()
upgradeURL, err := getUpgradeURL()
if err != nil {
return nil, err
}
var body []byte
if strings.HasPrefix(upgradeUrl, "/") {
body, err = ioutil.ReadFile(upgradeUrl)
if strings.HasPrefix(upgradeURL, "/") {
body, err = ioutil.ReadFile(upgradeURL)
if err != nil {
return nil, err
}
} else {
u, err := url.Parse(upgradeUrl)
u, err := url.Parse(upgradeURL)
if err != nil {
return nil, err
}
q := u.Query()
q.Set("current", config.VERSION)
q.Set("current", config.Version)
u.RawQuery = q.Encode()
upgradeUrl = u.String()
upgradeURL = u.String()
resp, err := http.Get(upgradeUrl)
resp, err := http.Get(upgradeURL)
if err != nil {
return nil, err
}
@@ -129,7 +129,7 @@ func osMetaDataGet(c *cli.Context) error {
}
cfg := config.LoadConfig()
runningName := cfg.Rancher.Upgrade.Image + ":" + config.VERSION
runningName := cfg.Rancher.Upgrade.Image + ":" + config.Version
foundRunning := false
for i := len(images.Available) - 1; i >= 0; i-- {
@@ -151,7 +151,7 @@ func osMetaDataGet(c *cli.Context) error {
fmt.Println(image, local, available, running)
}
if !foundRunning {
fmt.Println(config.VERSION, "running")
fmt.Println(config.Version, "running")
}
return nil
@@ -190,14 +190,14 @@ func osUpgrade(c *cli.Context) error {
}
func osVersion(c *cli.Context) error {
fmt.Println(config.VERSION)
fmt.Println(config.Version)
return nil
}
func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgradeConsole bool, kernelArgs string) error {
command := []string{
"-t", "rancher-upgrade",
"-r", config.VERSION,
"-r", config.Version,
}
if kexec {
@@ -218,7 +218,7 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgra
fmt.Printf("Upgrading to %s\n", image)
confirmation := "Continue"
imageSplit := strings.Split(image, ":")
if len(imageSplit) > 1 && imageSplit[1] == config.VERSION+config.SUFFIX {
if len(imageSplit) > 1 && imageSplit[1] == config.Version+config.Suffix {
confirmation = fmt.Sprintf("Already at version %s. Continue anyway", imageSplit[1])
}
if !force && !yes(confirmation) {
@@ -232,7 +232,7 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool, upgra
Pid: "host",
Image: image,
Labels: map[string]string{
config.SCOPE: config.SYSTEM,
config.ScopeLabel: config.System,
},
Command: command,
})
@@ -290,7 +290,7 @@ func parseBody(body []byte) (*Images, error) {
return update, nil
}
func getUpgradeUrl() (string, error) {
func getUpgradeURL() (string, error) {
cfg := config.LoadConfig()
return cfg.Rancher.Upgrade.Url, nil
return cfg.Rancher.Upgrade.URL, nil
}

View File

@@ -50,7 +50,7 @@ func selinuxCommand() cli.Command {
"-v", "/etc/selinux:/etc/selinux",
"-v", "/var/lib/selinux:/var/lib/selinux",
"-v", "/usr/share/selinux:/usr/share/selinux",
fmt.Sprintf("%s/os-selinuxtools:%s%s", config.OS_REPO, config.VERSION, config.SUFFIX), "bash"}
fmt.Sprintf("%s/os-selinuxtools:%s%s", config.OsRepo, config.Version, config.Suffix), "bash"}
syscall.Exec("/bin/system-docker", argv, []string{})
return nil
}

View File

@@ -16,8 +16,8 @@ import (
const (
NAME string = "rancher"
BITS int = 2048
ServerTlsPath string = "/etc/docker/tls"
ClientTlsPath string = "/home/rancher/.docker"
ServerTLSPath string = "/etc/docker/tls"
ClientTLSPath string = "/home/rancher/.docker"
Cert string = "cert.pem"
Key string = "key.pem"
ServerCert string = "server-cert.pem"
@@ -141,9 +141,9 @@ func generate(c *cli.Context) error {
func Generate(generateServer bool, outDir string, hostnames []string) error {
if outDir == "" {
if generateServer {
outDir = ServerTlsPath
outDir = ServerTLSPath
} else {
outDir = ClientTlsPath
outDir = ClientTLSPath
}
log.Infof("Out directory (-d, --dir) not specified, using default: %s", outDir)
}

View File

@@ -23,15 +23,15 @@ import (
)
const (
DEFAULT_STORAGE_CONTEXT = "console"
DOCKER_PID_FILE = "/var/run/docker.pid"
userDocker = "user-docker"
sourceDirectory = "/engine"
destDirectory = "/var/lib/rancher/engine"
defaultStorageContext = "console"
dockerPidFile = "/var/run/docker.pid"
userDocker = "user-docker"
sourceDirectory = "/engine"
destDirectory = "/var/lib/rancher/engine"
)
var (
DOCKER_COMMAND = []string{
dockerCommand = []string{
"ros",
"docker-init",
}
@@ -105,7 +105,7 @@ func copyBinaries(source, dest string) error {
}
func writeConfigCerts(cfg *config.CloudConfig) error {
outDir := ServerTlsPath
outDir := ServerTLSPath
if err := os.MkdirAll(outDir, 0700); err != nil {
return err
}
@@ -137,7 +137,7 @@ func writeConfigCerts(cfg *config.CloudConfig) error {
func startDocker(cfg *config.CloudConfig) error {
storageContext := cfg.Rancher.Docker.StorageContext
if storageContext == "" {
storageContext = DEFAULT_STORAGE_CONTEXT
storageContext = defaultStorageContext
}
log.Infof("Starting Docker in context: %s", storageContext)
@@ -179,7 +179,7 @@ func startDocker(cfg *config.CloudConfig) error {
cmd := []string{"docker-runc", "exec", "--", info.ID, "env"}
log.Info(dockerCfg.AppendEnv())
cmd = append(cmd, dockerCfg.AppendEnv()...)
cmd = append(cmd, DOCKER_COMMAND...)
cmd = append(cmd, dockerCommand...)
cmd = append(cmd, args...)
log.Infof("Running %v", cmd)
@@ -214,7 +214,7 @@ func getPid(service string, project *project.Project) (int, error) {
}
client, err := composeClient.Create(composeClient.Options{
Host: config.DOCKER_SYSTEM_HOST,
Host: config.SystemDockerHost,
})
if err != nil {
return 0, err