0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 19:12:59 +00:00
terraform-provider-proxmox/proxmox/nodes/containers/client.go
Leah beef9b1219
feat(lxc): add support for lxc mount points (#394)
* feat(lxc): add support for lxc mount points

* update docs and examples

* improve error handling for container creation / start operations, fix size propagation for storage mounts

---------

Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2023-07-16 20:41:07 -04:00

51 lines
1.3 KiB
Go

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package containers
import (
"fmt"
"github.com/bpg/terraform-provider-proxmox/proxmox/api"
"github.com/bpg/terraform-provider-proxmox/proxmox/firewall"
containerfirewall "github.com/bpg/terraform-provider-proxmox/proxmox/nodes/containers/firewall"
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/tasks"
)
// Client is an interface for accessing the Proxmox container API.
type Client struct {
api.Client
VMID int
}
func (c *Client) basePath() string {
return c.Client.ExpandPath("lxc")
}
// ExpandPath expands a relative path to a full container API path.
func (c *Client) ExpandPath(path string) string {
ep := fmt.Sprintf("%s/%d", c.basePath(), c.VMID)
if path != "" {
ep = fmt.Sprintf("%s/%s", ep, path)
}
return ep
}
// Tasks returns a client for managing container tasks.
func (c *Client) Tasks() *tasks.Client {
return &tasks.Client{
Client: c.Client,
}
}
// Firewall returns a client for managing the container firewall.
func (c *Client) Firewall() firewall.API {
return &containerfirewall.Client{
Client: firewall.Client{Client: c},
}
}