Join the community to discuss ongoing client development usage, the proxmox API or tooling in the #go-proxmox channel on the Gophers Slack and see the self generated docs for more usage details.
A go client for Proxmox VE. The client implements /api2/json and inspiration was drawn from the existing Telmate package but looking to improve in the following ways...
Core developers are home lab enthusiasts working in the virtualization and kubernetes space. The common use case we have for Proxmox is dev stress testing and validation of functionality in the products we work on, we plan to build the following tooling around this library to make that easier.
Create a client and use the public methods to access Proxmox resources.
package main
import (
"context"
"fmt"
"github.com/luthermonson/go-proxmox"
)
func main() {
credentials := proxmox.Credentials{
Username: "root@pam",
Password: "12345",
}
client := proxmox.NewClient("https://localhost:8006/api2/json",
proxmox.WithCredentials(&credentials),
)
version, err := client.Version(context.Background())
if err != nil {
panic(err)
}
fmt.Println(version.Release) // 7.4
}
package main
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"github.com/luthermonson/go-proxmox"
)
func main() {
insecureHTTPClient := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
tokenID := "root@pam!mytoken"
secret := "somegeneratedapitokenguidefromtheproxmoxui"
client := proxmox.NewClient("https://localhost:8006/api2/json",
proxmox.WithHTTPClient(&insecureHTTPClient),
proxmox.WithAPIToken(tokenID, secret),
)
version, err := client.Version(context.Background())
if err != nil {
panic(err)
}
fmt.Println(version.Release) // 6.3
}
This project relies on Mage for cross os/arch compatibility, please see their installation guide.
Run mage test
to run the unit tests in the root directory.
To run the integration testing suite against an existing Proxmox API set some env vars in your shell before running mage testIntegration
. The integration tests will test logging in and using an API token credentials so make sure you set all five env vars before running tests for them to pass.
Please leave no trace when developing integration tests. All tests should create and remove all testing data they generate then they can be repeatably run against the same proxmox environment. Most people working on this package will likely use their personal Proxmox VE home lab and consuming extra resources via tests will lead to frustration.
export PROXMOX_URL="https://192.168.1.6:8006/api2/json"
export PROXMOX_USERNAME="root@pam"
export PROXMOX_PASSWORD="password"
export PROXMOX_TOKENID="root@pam!mytoken"
export PROXMOX_SECRET="somegeneratedapitokenguidefromtheproxmoxui"
mage test:integration
$Env:PROXMOX_URL = "https://192.168.1.6:8006/api2/json"
$Env:PROXMOX_USERNAME = "root@pam"
$Env:PROXMOX_PASSWORD = "password"
$Env:PROXMOX_TOKENID = "root@pam!mytoken"
$Env:PROXMOX_SECRET = "somegeneratedapitokenguidefromtheproxmoxui"
mage test:integration