Skip to content

Commit

Permalink
cmk: fix formating using gofmt
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Yadav <[email protected]>
  • Loading branch information
rohityadavcloud committed Sep 22, 2021
1 parent 6ffe9ab commit 8aae61e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
package cmd

import (
"errors"
"fmt"
"reflect"
"strings"
"errors"

"github.com/apache/cloudstack-cloudmonkey/config"
)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
31 changes: 16 additions & 15 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
Expand All @@ -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()
Expand Down Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8aae61e

Please sign in to comment.