diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-30 20:22:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 20:22:55 +0200 |
commit | 1d14e6ed3c49777bc2b35e7c49d9232b2810935e (patch) | |
tree | 15a3413da3a8b79905bce0e712a453016c69cdd3 /pkg/bindings | |
parent | 6189232ef8f92c9d76894667758005edbbb371ce (diff) | |
parent | e731e624ca70288a1a16468deecd9b0d2de7f069 (diff) | |
download | podman-1d14e6ed3c49777bc2b35e7c49d9232b2810935e.tar.gz podman-1d14e6ed3c49777bc2b35e7c49d9232b2810935e.tar.bz2 podman-1d14e6ed3c49777bc2b35e7c49d9232b2810935e.zip |
Merge pull request #9878 from jwhonce/wip/version
[NO TESTS NEEDED] Remove semantic version suffices from API calls
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/connection.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go index 21a8e7a8b..fd93c5ac7 100644 --- a/pkg/bindings/connection.go +++ b/pkg/bindings/connection.go @@ -22,14 +22,6 @@ import ( "golang.org/x/crypto/ssh/agent" ) -var ( - BasePath = &url.URL{ - Scheme: "http", - Host: "d", - Path: "/v" + version.APIVersion[version.Libpod][version.CurrentAPI].String() + "/libpod", - } -) - type APIResponse struct { *http.Response Request *http.Request @@ -318,16 +310,24 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string, err error response *http.Response ) - safePathValues := make([]interface{}, len(pathValues)) - // Make sure path values are http url safe + + params := make([]interface{}, len(pathValues)+3) + + // Including the semver suffices breaks older services... so do not include them + v := version.APIVersion[version.Libpod][version.CurrentAPI] + params[0] = v.Major + params[1] = v.Minor + params[2] = v.Patch for i, pv := range pathValues { - safePathValues[i] = url.PathEscape(pv) + // url.URL lacks the semantics for escaping embedded path parameters... so we manually + // escape each one and assume the caller included the correct formatting in "endpoint" + params[i+3] = url.PathEscape(pv) } - // Lets eventually use URL for this which might lead to safer - // usage - safeEndpoint := fmt.Sprintf(endpoint, safePathValues...) - e := BasePath.String() + safeEndpoint - req, err := http.NewRequest(httpMethod, e, httpBody) + + uri := fmt.Sprintf("http://d/v%d.%d.%d/libpod"+endpoint, params...) + logrus.Debugf("DoRequest Method: %s URI: %v", httpMethod, uri) + + req, err := http.NewRequest(httpMethod, uri, httpBody) if err != nil { return nil, err } |