Files
Sankofa/crossplane-provider-proxmox/pkg/proxmox/networks.go
defiQUG 7cd7022f6e Update .gitignore, remove package-lock.json, and enhance Cloudflare and Proxmox adapters
- Added lock file exclusions for pnpm in .gitignore.
- Removed obsolete package-lock.json from the api and portal directories.
- Enhanced Cloudflare adapter with additional interfaces for zones and tunnels.
- Improved Proxmox adapter error handling and logging for API requests.
- Updated Proxmox VM parameters with validation rules in the API schema.
- Enhanced documentation for Proxmox VM specifications and examples.
2025-12-12 19:29:01 -08:00

43 lines
997 B
Go

package proxmox
import (
"context"
"fmt"
"github.com/pkg/errors"
)
// Network represents a Proxmox network bridge
type Network struct {
Name string `json:"iface"`
Type string `json:"type"`
Active bool `json:"active"`
Address string `json:"address,omitempty"`
}
// ListNetworks lists all network bridges on a node
func (c *Client) ListNetworks(ctx context.Context, node string) ([]Network, error) {
var networks []Network
if err := c.httpClient.Get(ctx, fmt.Sprintf("/nodes/%s/network", node), &networks); err != nil {
return nil, errors.Wrapf(err, "failed to list networks on node %s", node)
}
return networks, nil
}
// NetworkExists checks if a network bridge exists on a node
func (c *Client) NetworkExists(ctx context.Context, node, networkName string) (bool, error) {
networks, err := c.ListNetworks(ctx, node)
if err != nil {
return false, err
}
for _, net := range networks {
if net.Name == networkName {
return true, nil
}
}
return false, nil
}