mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-11 08:15:02 +00:00
export httpClient from the API
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
c1374a5c10
commit
98f16fc97c
@ -52,6 +52,9 @@ type Client interface {
|
|||||||
// IsRootTicket returns true if the authenticator is configured to use the root directly using a login ticket.
|
// IsRootTicket returns true if the authenticator is configured to use the root directly using a login ticket.
|
||||||
// (root using token is weaker, cannot change VM arch)
|
// (root using token is weaker, cannot change VM arch)
|
||||||
IsRootTicket() bool
|
IsRootTicket() bool
|
||||||
|
|
||||||
|
// HTTP returns a lower-level HTTP client.
|
||||||
|
HTTP() *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection represents a connection to the Proxmox Virtual Environment API.
|
// Connection represents a connection to the Proxmox Virtual Environment API.
|
||||||
@ -298,6 +301,10 @@ func (c *client) IsRootTicket() bool {
|
|||||||
return c.auth.IsRootTicket()
|
return c.auth.IsRootTicket()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *client) HTTP() *http.Client {
|
||||||
|
return c.conn.httpClient
|
||||||
|
}
|
||||||
|
|
||||||
// validateResponseCode ensures that a response is valid.
|
// validateResponseCode ensures that a response is valid.
|
||||||
func validateResponseCode(res *http.Response) error {
|
func validateResponseCode(res *http.Response) error {
|
||||||
if res.StatusCode < 200 || res.StatusCode >= 300 {
|
if res.StatusCode < 200 || res.StatusCode >= 300 {
|
||||||
|
@ -739,7 +739,7 @@ func fileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
|||||||
|
|
||||||
readFileAttrs := readFile
|
readFileAttrs := readFile
|
||||||
if fileIsURL(d) {
|
if fileIsURL(d) {
|
||||||
readFileAttrs = readURL
|
readFileAttrs = readURL(capi.API().HTTP())
|
||||||
}
|
}
|
||||||
|
|
||||||
var diags diag.Diagnostics
|
var diags diag.Diagnostics
|
||||||
@ -838,10 +838,16 @@ func readFile(
|
|||||||
|
|
||||||
//nolint:nonamedreturns
|
//nolint:nonamedreturns
|
||||||
func readURL(
|
func readURL(
|
||||||
|
httClient *http.Client,
|
||||||
|
) func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
sourceFilePath string,
|
sourceFilePath string,
|
||||||
) (fileModificationDate string, fileSize int64, fileTag string, err error) {
|
) (fileModificationDate string, fileSize int64, fileTag string, err error) {
|
||||||
res, err := http.Head(sourceFilePath)
|
return func(
|
||||||
|
ctx context.Context,
|
||||||
|
sourceFilePath string,
|
||||||
|
) (fileModificationDate string, fileSize int64, fileTag string, err error) {
|
||||||
|
res, err := httClient.Head(sourceFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -881,6 +887,7 @@ func readURL(
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func fileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func fileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
config := m.(proxmoxtf.ProviderConfiguration)
|
config := m.(proxmoxtf.ProviderConfiguration)
|
||||||
|
Loading…
Reference in New Issue
Block a user