This is an automated email from the ASF dual-hosted git repository.

shwstppr 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 ccb6470  config: fix setting postrequest config (#190)
ccb6470 is described below

commit ccb647066121270dfdce64c9125cbc25aa601b95
Author: Abhishek Kumar <[email protected]>
AuthorDate: Tue Aug 26 15:31:52 2025 +0530

    config: fix setting postrequest config (#190)
    
    PR #161 introduced `postrequest` config but there was no way to update that 
config other than updating the config file.
    This PR fixes the behaviour. Also adds a log to highlight what HTTP method 
is used.
    
    Signed-off-by: Abhishek Kumar <[email protected]>
---
 cmd/network.go   | 4 +++-
 cmd/set.go       | 1 +
 config/config.go | 4 +++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/cmd/network.go b/cmd/network.go
index 7b5807a..286abb5 100644
--- a/cmd/network.go
+++ b/cmd/network.go
@@ -411,9 +411,11 @@ func NewAPIRequest(r *Request, api string, args []string, 
isAsync bool) (map[str
 func executeRequest(r *Request, requestURL string, params url.Values) 
(*http.Response, error) {
        config.SetupContext(r.Config)
        if params.Has("password") || params.Has("userdata") || 
r.Config.Core.PostRequest {
-               requestURL = fmt.Sprintf("%s", r.Config.ActiveProfile.URL)
+               requestURL = r.Config.ActiveProfile.URL
+               config.Debug("Using HTTP POST for the request: ", requestURL)
                return r.Client().PostForm(requestURL, params)
        }
+       config.Debug("Using HTTP GET for the request: ", requestURL)
        req, _ := http.NewRequestWithContext(*r.Config.Context, "GET", 
requestURL, nil)
        return r.Client().Do(req)
 }
diff --git a/cmd/set.go b/cmd/set.go
index ee7c737..c8bba8a 100644
--- a/cmd/set.go
+++ b/cmd/set.go
@@ -45,6 +45,7 @@ func init() {
                        "verifycert":   {"true", "false"},
                        "debug":        {"true", "false"},
                        "autocomplete": {"true", "false"},
+                       "postrequest":  {"true", "false"},
                },
                Handle: func(r *Request) error {
                        if len(r.Args) < 1 {
diff --git a/config/config.go b/config/config.go
index bcd3f6f..cf32b69 100644
--- a/config/config.go
+++ b/config/config.go
@@ -76,7 +76,7 @@ type Core struct {
        VerifyCert   bool   `ini:"verifycert"`
        ProfileName  string `ini:"profile"`
        AutoComplete bool   `ini:"autocomplete"`
-       PostRequest  bool   `ini:postrequest`
+       PostRequest  bool   `ini:"postrequest"`
 }
 
 // Config describes CLI config file and default options
@@ -401,6 +401,8 @@ func (c *Config) UpdateConfig(key string, value string, 
update bool) {
                }
        case "autocomplete":
                c.Core.AutoComplete = value == "true"
+       case "postrequest":
+               c.Core.PostRequest = value == "true"
        default:
                fmt.Println("Invalid option provided:", key)
                return

Reply via email to