mirror of
https://github.com/rancher/os.git
synced 2025-09-05 16:52:20 +00:00
gofmt
This commit is contained in:
@@ -37,13 +37,13 @@ func Main() {
|
|||||||
// Action: reload,
|
// Action: reload,
|
||||||
//},
|
//},
|
||||||
{
|
{
|
||||||
Name: "os",
|
Name: "os",
|
||||||
Usage: "operating system upgrade/downgrade",
|
Usage: "operating system upgrade/downgrade",
|
||||||
Subcommands: osSubcommands(),
|
Subcommands: osSubcommands(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "tlsconf",
|
Name: "tlsconf",
|
||||||
Usage: "setup tls configuration",
|
Usage: "setup tls configuration",
|
||||||
Subcommands: tlsConfCommands(),
|
Subcommands: tlsConfCommands(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -30,27 +30,27 @@ func osSubcommands() []cli.Command {
|
|||||||
Action: osUpgrade,
|
Action: osUpgrade,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "stage, s",
|
Name: "stage, s",
|
||||||
Usage: "Only stage the new upgrade, don't apply it",
|
Usage: "Only stage the new upgrade, don't apply it",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "image, i",
|
Name: "image, i",
|
||||||
Usage: "upgrade to a certain image",
|
Usage: "upgrade to a certain image",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "channel, c",
|
Name: "channel, c",
|
||||||
Usage: "upgrade to the latest in a specific channel",
|
Usage: "upgrade to the latest in a specific channel",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "list the current available versions",
|
Usage: "list the current available versions",
|
||||||
Action: osMetaDataGet,
|
Action: osMetaDataGet,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "rollback",
|
Name: "rollback",
|
||||||
Usage: "rollback to the previous version",
|
Usage: "rollback to the previous version",
|
||||||
Action: osRollback,
|
Action: osRollback,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -65,9 +65,9 @@ func osRollback(c *cli.Context) {
|
|||||||
|
|
||||||
fileReader := bufio.NewScanner(file)
|
fileReader := bufio.NewScanner(file)
|
||||||
line := " "
|
line := " "
|
||||||
for ; line[len(line)-1:] != "*"; {
|
for line[len(line)-1:] != "*" {
|
||||||
if !fileReader.Scan() {
|
if !fileReader.Scan() {
|
||||||
log.Error("Current version not indicated in "+ osVersionsFile)
|
log.Error("Current version not indicated in " + osVersionsFile)
|
||||||
}
|
}
|
||||||
line = fileReader.Text()
|
line = fileReader.Text()
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,8 @@ func osRollback(c *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func osMetaDataGet(c *cli.Context) {
|
func osMetaDataGet(c *cli.Context) {
|
||||||
osChannel, ok := getChannelUrl("meta"); if !ok {
|
osChannel, ok := getChannelUrl("meta")
|
||||||
|
if !ok {
|
||||||
log.Fatal("unrecognized channel meta")
|
log.Fatal("unrecognized channel meta")
|
||||||
}
|
}
|
||||||
resp, err := http.Get(osChannel)
|
resp, err := http.Get(osChannel)
|
||||||
@@ -113,7 +114,7 @@ func osUpgrade(c *cli.Context) {
|
|||||||
|
|
||||||
func startUpgradeContainer(image string, stage bool) {
|
func startUpgradeContainer(image string, stage bool) {
|
||||||
container := docker.NewContainer(config.DOCKER_SYSTEM_HOST, &config.ContainerConfig{
|
container := docker.NewContainer(config.DOCKER_SYSTEM_HOST, &config.ContainerConfig{
|
||||||
Cmd: "--name=upgrade " +
|
Cmd: "--name=upgrade " +
|
||||||
"--privileged " +
|
"--privileged " +
|
||||||
"--net=host " +
|
"--net=host " +
|
||||||
"--ipc=host " +
|
"--ipc=host " +
|
||||||
@@ -153,15 +154,16 @@ func getLatestImage(channel string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch currentChannel := val.(type) {
|
switch currentChannel := val.(type) {
|
||||||
case string:
|
case string:
|
||||||
pivot = currentChannel
|
pivot = currentChannel
|
||||||
default:
|
default:
|
||||||
return "", errors.New("invalid format of rancherctl config get os_upgrade_channel")
|
return "", errors.New("invalid format of rancherctl config get os_upgrade_channel")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pivot = channel
|
pivot = channel
|
||||||
}
|
}
|
||||||
osChannel, ok := getChannelUrl(pivot); if !ok {
|
osChannel, ok := getChannelUrl(pivot)
|
||||||
|
if !ok {
|
||||||
return "", errors.New("unrecognized channel " + pivot)
|
return "", errors.New("unrecognized channel " + pivot)
|
||||||
}
|
}
|
||||||
resp, err := http.Get(osChannel)
|
resp, err := http.Get(osChannel)
|
||||||
@@ -184,14 +186,13 @@ func parseBody(body []byte, channel string) string {
|
|||||||
|
|
||||||
func getChannelUrl(channel string) (string, bool) {
|
func getChannelUrl(channel string) (string, bool) {
|
||||||
if osChannels == nil {
|
if osChannels == nil {
|
||||||
osChannels = map[string]string {
|
osChannels = map[string]string{
|
||||||
"stable" : "",
|
"stable": "",
|
||||||
"alpha" : "",
|
"alpha": "",
|
||||||
"beta" : "",
|
"beta": "",
|
||||||
"meta" : "",
|
"meta": "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channel, ok := osChannels[channel];
|
channel, ok := osChannels[channel]
|
||||||
return channel, ok
|
return channel, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,26 +10,26 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func tlsConfCommands() []cli.Command {
|
func tlsConfCommands() []cli.Command {
|
||||||
return []cli.Command {
|
return []cli.Command{
|
||||||
{
|
{
|
||||||
Name: "create",
|
Name: "create",
|
||||||
Usage: "use it to create a new set of tls configuration certs and keys or upload existing ones",
|
Usage: "use it to create a new set of tls configuration certs and keys or upload existing ones",
|
||||||
Action: tlsConfCreate,
|
Action: tlsConfCreate,
|
||||||
Flags: []cli.Flag {
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag {
|
cli.StringFlag{
|
||||||
Name: "cakey",
|
Name: "cakey",
|
||||||
Usage: "path to existing certificate authority key (only use with --generate)",
|
Usage: "path to existing certificate authority key (only use with --generate)",
|
||||||
},
|
},
|
||||||
cli.StringFlag {
|
cli.StringFlag{
|
||||||
Name: "ca",
|
Name: "ca",
|
||||||
Usage: "path to existing certificate authority (only use with --genreate)",
|
Usage: "path to existing certificate authority (only use with --genreate)",
|
||||||
},
|
},
|
||||||
cli.BoolFlag {
|
cli.BoolFlag{
|
||||||
Name: "generate, g",
|
Name: "generate, g",
|
||||||
Usage: "generate the client key and client cert from existing ca and cakey",
|
Usage: "generate the client key and client cert from existing ca and cakey",
|
||||||
},
|
},
|
||||||
cli.StringFlag {
|
cli.StringFlag{
|
||||||
Name: "outDir, o",
|
Name: "outDir, o",
|
||||||
Usage: "the output directory to save the generated certs or keys",
|
Usage: "the output directory to save the generated certs or keys",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -100,7 +100,6 @@ func tlsConfCreate(c *cli.Context) {
|
|||||||
serverKeyPath = "client-key.pem"
|
serverKeyPath = "client-key.pem"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
serverCertPath = filepath.Join(outDir, serverCertPath)
|
serverCertPath = filepath.Join(outDir, serverCertPath)
|
||||||
serverKeyPath = filepath.Join(outDir, serverKeyPath)
|
serverKeyPath = filepath.Join(outDir, serverKeyPath)
|
||||||
|
|
||||||
|
@@ -8,8 +8,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/fsouza/go-dockerclient"
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Reference in New Issue
Block a user