You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2021/09/22 10:39:12 UTC
[cloudstack-cloudmonkey] branch main updated: cmk: fix formating
using gofmt
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
The following commit(s) were added to refs/heads/main by this push:
new 8aae61e cmk: fix formating using gofmt
8aae61e is described below
commit 8aae61e20c6789133c1d97d49e58f354ba7428c3
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Wed Sep 22 16:08:57 2021 +0530
cmk: fix formating using gofmt
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
cmd/output.go | 2 +-
cmd/set.go | 4 ++--
cmk.go | 2 +-
config/config.go | 31 ++++++++++++++++---------------
4 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/cmd/output.go b/cmd/output.go
index 9a02369..b697da9 100644
--- a/cmd/output.go
+++ b/cmd/output.go
@@ -37,7 +37,7 @@ func jsonify(value interface{}, format string) string {
if reflect.TypeOf(value).Kind() == reflect.Map || reflect.TypeOf(value).Kind() == reflect.Slice {
var jsonStr []byte
var err error
- if (format == "text") {
+ if format == "text" {
jsonStr, err = json.MarshalIndent(value, "", "")
} else {
jsonStr, err = json.Marshal(value)
diff --git a/cmd/set.go b/cmd/set.go
index c426948..ee7c737 100644
--- a/cmd/set.go
+++ b/cmd/set.go
@@ -18,10 +18,10 @@
package cmd
import (
+ "errors"
"fmt"
"reflect"
"strings"
- "errors"
"github.com/apache/cloudstack-cloudmonkey/config"
)
@@ -64,7 +64,7 @@ func init() {
validArgs := r.Command.SubCommands[subCommand]
if len(validArgs) != 0 && subCommand != "timeout" {
if !config.CheckIfValuePresent(validArgs, value) {
- return errors.New("Invalid value set for " + subCommand +". Supported values: " + strings.Join(validArgs, ", ") )
+ return errors.New("Invalid value set for " + subCommand + ". Supported values: " + strings.Join(validArgs, ", "))
}
}
r.Config.UpdateConfig(subCommand, value, true)
diff --git a/cmk.go b/cmk.go
index b614b95..ff9325e 100644
--- a/cmk.go
+++ b/cmk.go
@@ -42,7 +42,7 @@ func init() {
func main() {
validFormats := strings.Join(config.GetOutputFormats(), ",")
- outputFormat := flag.String("o", "", "output format: " + validFormats)
+ outputFormat := flag.String("o", "", "output format: "+validFormats)
showVersion := flag.Bool("v", false, "show version")
debug := flag.Bool("d", false, "enable debug mode")
profile := flag.String("p", "", "server profile")
diff --git a/config/config.go b/config/config.go
index cca7913..5be1336 100644
--- a/config/config.go
+++ b/config/config.go
@@ -35,12 +35,12 @@ import (
// Output formats
const (
- COLUMN = "column"
- CSV = "csv"
- JSON = "json"
- TABLE = "table"
- TEXT = "text"
- DEFAULT= "default"
+ COLUMN = "column"
+ CSV = "csv"
+ JSON = "json"
+ TABLE = "table"
+ TEXT = "text"
+ DEFAULT = "default"
)
// ServerProfile describes a management server
@@ -77,7 +77,7 @@ type Config struct {
}
func GetOutputFormats() []string {
- return []string {"column", "csv", "json", "table", "text", "default"}
+ return []string{"column", "csv", "json", "table", "text", "default"}
}
func CheckIfValuePresent(dataset []string, element string) bool {
@@ -88,6 +88,7 @@ func CheckIfValuePresent(dataset []string, element string) bool {
}
return false
}
+
// CacheFile returns the path to the cache file for a server profile
func (c Config) CacheFile() string {
cacheDir := path.Join(c.Dir, "profiles")
@@ -102,7 +103,7 @@ func (c Config) CacheFile() string {
func hasAccess(path string) bool {
status := true
file, err := os.Open(path)
- if (err != nil) {
+ if err != nil {
status = false
}
file.Close()
@@ -136,12 +137,12 @@ func getDefaultConfigDir() string {
func defaultCoreConfig() Core {
return Core{
- Prompt: "🐱",
- AsyncBlock: true,
- Timeout: 1800,
- Output: JSON,
- VerifyCert: true,
- ProfileName: "localcloud",
+ Prompt: "🐱",
+ AsyncBlock: true,
+ Timeout: 1800,
+ Output: JSON,
+ VerifyCert: true,
+ ProfileName: "localcloud",
AutoComplete: true,
}
}
@@ -253,7 +254,7 @@ func saveConfig(cfg *Config) *Config {
// Update
core := new(Core)
conf.Section(ini.DEFAULT_SECTION).MapTo(core)
- if (!conf.Section(ini.DEFAULT_SECTION).HasKey("autocomplete")) {
+ if !conf.Section(ini.DEFAULT_SECTION).HasKey("autocomplete") {
core.AutoComplete = true
}
cfg.Core = core