mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
client: Replaces r.httpHost with r.httpBaseURL from net/url package
The old name was misleading as it didn't represent a host name, but rather a URL. Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
This commit is contained in:
@@ -104,12 +104,17 @@ func ConnectLXDHTTPWithContext(ctx context.Context, args *ConnectionArgs, client
|
||||
args = &ConnectionArgs{}
|
||||
}
|
||||
|
||||
httpBaseURL, err := url.Parse("https://custom.socket")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctxConnected, ctxConnectedCancel := context.WithCancel(context.Background())
|
||||
|
||||
// Initialize the client struct
|
||||
server := ProtocolLXD{
|
||||
ctx: ctx,
|
||||
httpHost: "https://custom.socket",
|
||||
httpBaseURL: *httpBaseURL,
|
||||
httpProtocol: "custom",
|
||||
httpUserAgent: args.UserAgent,
|
||||
ctxConnected: ctxConnected,
|
||||
@@ -157,12 +162,17 @@ func ConnectLXDUnixWithContext(ctx context.Context, path string, args *Connectio
|
||||
args = &ConnectionArgs{}
|
||||
}
|
||||
|
||||
httpBaseURL, err := url.Parse("http://unix.socket")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctxConnected, ctxConnectedCancel := context.WithCancel(context.Background())
|
||||
|
||||
// Initialize the client struct
|
||||
server := ProtocolLXD{
|
||||
ctx: ctx,
|
||||
httpHost: "http://unix.socket",
|
||||
httpBaseURL: *httpBaseURL,
|
||||
httpUnixPath: path,
|
||||
httpProtocol: "unix",
|
||||
httpUserAgent: args.UserAgent,
|
||||
@@ -287,19 +297,24 @@ func ConnectSimpleStreams(url string, args *ConnectionArgs) (ImageServer, error)
|
||||
}
|
||||
|
||||
// Internal function called by ConnectLXD and ConnectPublicLXD
|
||||
func httpsLXD(ctx context.Context, url string, args *ConnectionArgs) (InstanceServer, error) {
|
||||
func httpsLXD(ctx context.Context, requestURL string, args *ConnectionArgs) (InstanceServer, error) {
|
||||
// Use empty args if not specified
|
||||
if args == nil {
|
||||
args = &ConnectionArgs{}
|
||||
}
|
||||
|
||||
httpBaseURL, err := url.Parse(requestURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctxConnected, ctxConnectedCancel := context.WithCancel(context.Background())
|
||||
|
||||
// Initialize the client struct
|
||||
server := ProtocolLXD{
|
||||
ctx: ctx,
|
||||
httpCertificate: args.TLSServerCert,
|
||||
httpHost: url,
|
||||
httpBaseURL: *httpBaseURL,
|
||||
httpProtocol: "https",
|
||||
httpUserAgent: args.UserAgent,
|
||||
bakeryInteractor: args.AuthInteractor,
|
||||
|
||||
Reference in New Issue
Block a user