lint: fix failures (#171)
Fixes `make lint`
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
diff --git a/Makefile b/Makefile
index b54b956..ee8b657 100644
--- a/Makefile
+++ b/Makefile
@@ -67,9 +67,12 @@
# 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 1c1f67c..8665e81 100644
--- a/cmd/network.go
+++ b/cmd/network.go
@@ -299,8 +299,7 @@
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 767cd4e..89bd5dc 100644
--- a/cmk.go
+++ b/cmk.go
@@ -47,7 +47,7 @@
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 @@
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 52ee9f0..3245f4e 100644
--- a/config/config.go
+++ b/config/config.go
@@ -45,7 +45,8 @@
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 @@
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 defaultProfile() ServerProfile {
return ServerProfile{
- URL: DEFAULT_ACS_API_ENDPOINT,
+ URL: DefaultACSAPIEndpoint,
Username: "admin",
Password: "password",
Domain: "/",
@@ -189,6 +192,7 @@
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)