From bfb27e383a323ae0740128c70f21029e7313b825 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 6 Aug 2025 17:14:12 +0530 Subject: [PATCH] lint: fix failures Signed-off-by: Abhishek Kumar --- Makefile | 7 +++++-- cmd/network.go | 5 ++--- cmk.go | 6 +++--- config/config.go | 8 ++++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b54b9565..ee8b6572 100644 --- a/Makefile +++ b/Makefile @@ -67,9 +67,12 @@ dist: dist-linux # Tools +$(BIN): + @mkdir -p $(BIN) + GOLINT = $(BIN)/golint -$(BIN)/golint: $(BASE) ; $(info $(M) Building golint…) - $Q go get github.com/golang/lint/golint +$(BIN)/golint: | $(BIN) ; $(info $(M) Building golint…) + $Q GOBIN=$(BIN) go install golang.org/x/lint/golint@latest GOCOVMERGE = $(BIN)/gocovmerge $(BIN)/gocovmerge: | $(BASE) ; $(info $(M) building gocovmerge…) diff --git a/cmd/network.go b/cmd/network.go index 1c1f67c4..8665e812 100644 --- a/cmd/network.go +++ b/cmd/network.go @@ -299,8 +299,7 @@ func executeRequest(r *Request, requestURL string, params url.Values) (*http.Res if params.Has("password") || params.Has("userdata") || r.Config.Core.PostRequest { requestURL = fmt.Sprintf("%s", r.Config.ActiveProfile.URL) return r.Client().PostForm(requestURL, params) - } else { - req, _ := http.NewRequestWithContext(*r.Config.Context, "GET", requestURL, nil) - return r.Client().Do(req) } + req, _ := http.NewRequestWithContext(*r.Config.Context, "GET", requestURL, nil) + return r.Client().Do(req) } diff --git a/cmk.go b/cmk.go index 767cd4ec..89bd5dc1 100644 --- a/cmk.go +++ b/cmk.go @@ -47,7 +47,7 @@ func main() { debug := flag.Bool("d", false, "enable debug mode") profile := flag.String("p", "", "server profile") configFilePath := flag.String("c", "", "config file path") - acsUrl := flag.String("u", config.DEFAULT_ACS_API_ENDPOINT, "cloudStack's API endpoint URL") + acsURL := flag.String("u", config.DefaultACSAPIEndpoint, "cloudStack's API endpoint URL") apiKey := flag.String("k", "", "cloudStack user's API Key") secretKey := flag.String("s", "", "cloudStack user's secret Key") flag.Parse() @@ -72,8 +72,8 @@ func main() { cfg.UpdateConfig("output", *outputFormat, false) } - if *acsUrl != config.DEFAULT_ACS_API_ENDPOINT { - cfg.UpdateConfig("url", *acsUrl, false) + if *acsURL != config.DefaultACSAPIEndpoint { + cfg.UpdateConfig("url", *acsURL, false) } if *apiKey != "" { diff --git a/config/config.go b/config/config.go index 52ee9f0a..3245f4ed 100644 --- a/config/config.go +++ b/config/config.go @@ -45,7 +45,8 @@ const ( DEFAULT = "default" ) -const DEFAULT_ACS_API_ENDPOINT = "http://localhost:8080/client/api" +// DefaultACSAPIEndpoint is the default API endpoint for CloudStack. +const DefaultACSAPIEndpoint = "http://localhost:8080/client/api" // ServerProfile describes a management server type ServerProfile struct { @@ -84,10 +85,12 @@ type Config struct { C chan bool } +// GetOutputFormats returns the supported output formats. func GetOutputFormats() []string { return []string{"column", "csv", "json", "table", "text", "default"} } +// CheckIfValuePresent checks if an element is present in the dataset. func CheckIfValuePresent(dataset []string, element string) bool { for _, arg := range dataset { if arg == element { @@ -158,7 +161,7 @@ func defaultCoreConfig() Core { func defaultProfile() ServerProfile { return ServerProfile{ - URL: DEFAULT_ACS_API_ENDPOINT, + URL: DefaultACSAPIEndpoint, Username: "admin", Password: "password", Domain: "/", @@ -189,6 +192,7 @@ func GetProfiles() []string { return profiles } +// SetupContext initializes the context and signal handling for the config. func SetupContext(cfg *Config) { cfg.C = make(chan bool) signals := make(chan os.Signal, 1)