Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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…)
Expand Down
5 changes: 2 additions & 3 deletions cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions cmk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 != "" {
Expand Down
8 changes: 6 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -158,7 +161,7 @@ func defaultCoreConfig() Core {

func defaultProfile() ServerProfile {
return ServerProfile{
URL: DEFAULT_ACS_API_ENDPOINT,
URL: DefaultACSAPIEndpoint,
Username: "admin",
Password: "password",
Domain: "/",
Expand Down Expand Up @@ -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)
Expand Down