You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/03/05 09:50:05 UTC
[cloudstack-cloudmonkey] branch master updated: network: get
content from file when arg=@/path is provided (#43)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git
The following commit(s) were added to refs/heads/master by this push:
new 56ea2b5 network: get content from file when arg=@/path is provided (#43)
56ea2b5 is described below
commit 56ea2b5831a92e09060fab7f26d0507fe524dcd2
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Tue Mar 5 15:17:56 2019 +0530
network: get content from file when arg=@/path is provided (#43)
This adds feature similar to `curl` where you can pass content of a file
via the `arg=@/path/to/file` syntax. This can be useful while uploading
custom certificate via cloudmonkey.
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
cmd/network.go | 12 ++++++++++++
config/config.go | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/cmd/network.go b/cmd/network.go
index 3ab1358..5bc280a 100644
--- a/cmd/network.go
+++ b/cmd/network.go
@@ -29,6 +29,7 @@ import (
"net/http"
"net/http/cookiejar"
"net/url"
+ "os"
"sort"
"strings"
"time"
@@ -174,6 +175,17 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
if strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"") {
value = value[1 : len(value)-1]
}
+ if strings.HasPrefix(value, "@") {
+ possibleFileName := value[1:]
+ if fileInfo, err := os.Stat(possibleFileName); err == nil && !fileInfo.IsDir() {
+ bytes, err := ioutil.ReadFile(possibleFileName)
+ config.Debug()
+ if err == nil {
+ value = string(bytes)
+ config.Debug("Content for argument ", key, " read from file: ", possibleFileName, " is: ", value)
+ }
+ }
+ }
params.Add(key, value)
}
}
diff --git a/config/config.go b/config/config.go
index 17d6712..d1ae6b0 100644
--- a/config/config.go
+++ b/config/config.go
@@ -307,7 +307,7 @@ func (c *Config) UpdateConfig(key string, value string, update bool) {
case "verifycert":
c.Core.VerifyCert = value == "true"
case "debug":
- if value == "true" {
+ if value == "true" || value == "on" {
EnableDebugging()
} else {
DisableDebugging()