client/connection.go
func httpsLXD(url string, args *ConnectionArgs) (ContainerServer, error) {
	// Use empty args if not specified
	if args == nil {
		args = &ConnectionArgs{}
	}

	// Initialize the client struct
	server := ProtocolLXD{
		httpCertificate:  args.TLSServerCert,
		httpHost:         url,
		httpProtocol:     "https",
		httpUserAgent:    args.UserAgent,
		bakeryInteractor: args.AuthInteractor,
	}
	if args.AuthType == "candid" {
		server.RequireAuthenticated(true)
	}

	// Setup the HTTP client
	httpClient, err := tlsHTTPClient(args.HTTPClient, args.TLSClientCert, args.TLSClientKey, args.TLSCA, args.TLSServerCert, args.InsecureSkipVerify, args.Proxy)
	if err != nil {
		return nil, err
	}

	if args.CookieJar != nil {
		httpClient.Jar = args.CookieJar
	}

	server.http = httpClient
	if args.AuthType == "candid" {
		server.setupBakeryClient()
	}

	// Test the connection and seed the server information
	if !args.SkipGetServer {
		_, _, err := server.GetServer()
		if err != nil {
			return nil, err
		}
	}
	return &server, nil
}
func httpsLXD(url string, args *ConnectionArgs) (ContainerServer, error) {
	// Use empty args if not specified
	if args == nil {
		args = &ConnectionArgs{}
	}

	// Initialize the client struct
	server := ProtocolLXD{
		httpCertificate:  args.TLSServerCert,
		httpHost:         url,
		httpProtocol:     "https",
		httpUserAgent:    args.UserAgent,
		bakeryInteractor: args.AuthInteractor,
	}
	if args.AuthType == "candid" {
		server.RequireAuthenticated(true)
	}

	// Setup the HTTP client
	httpClient, err := tlsHTTPClient(args.HTTPClient, args.TLSClientCert, args.TLSClientKey, args.TLSCA, args.TLSServerCert, args.InsecureSkipVerify, args.Proxy)
	if err != nil {
		return nil, err
	}

	if args.CookieJar != nil {
		httpClient.Jar = args.CookieJar
	}

	server.http = httpClient
	if args.AuthType == "candid" {
		server.setupBakeryClient()
	}

	// Test the connection and seed the server information
	if !args.SkipGetServer {
		_, _, err := server.GetServer()
		if err != nil {
			return nil, err
		}
	}
	return &server, nil
}
func httpsLXD ( url string , args * ConnectionArgs ) ( ContainerServer , error ) { // Use empty args if not specified if args == nil { args = & ConnectionArgs { } } // Initialize the client struct server := ProtocolLXD { httpCertificate : args . TLSServerCert , httpHost : url , httpProtocol : " " , httpUserAgent : args . UserAgent , bakeryInteractor : args . AuthInteractor , } if args . AuthType == " " { server . RequireAuthenticated ( true ) } // Setup the HTTP client httpClient , err := tlsHTTPClient ( args . HTTPClient , args . TLSClientCert , args . TLSClientKey , args . TLSCA , args . TLSServerCert , args . InsecureSkipVerify , args . Proxy ) if err != nil { return nil , err } if args . CookieJar != nil { httpClient . Jar = args . CookieJar } server . http = httpClient if args . AuthType == " " { server . setupBakeryClient ( ) } // Test the connection and seed the server information if ! args . SkipGetServer { _ , _ , err := server . GetServer ( ) if err != nil { return nil , err } } return & server , nil }
// Internal function called by ConnectLXD and ConnectPublicLXD
Internal function called by ConnectLXD and ConnectPublicLXD