minor refactoring
tronnet/workflows: Static Analysis -- Golang / static-go (push) Successful in 13s

This commit is contained in:
alu
2026-08-31 20:32:45 +00:00
parent 8b9c8c14d5
commit 30a4264bb1
8 changed files with 80 additions and 63 deletions
+2 -12
View File
@@ -7,7 +7,6 @@ import (
"log"
"net/http"
"slices"
"strings"
common "access-manager-api/app/common"
@@ -19,14 +18,6 @@ type ProxmoxClient struct {
client *proxmox.Client
}
func IsProxmoxNotFound(err error) bool {
if err != nil {
// for whatever reason proxmox returns 500 for user/group/pool not found
return proxmox.IsNotFound(err) || strings.Contains(err.Error(), "no such") || strings.Contains(err.Error(), "does not exist")
}
return false
}
// creates a new client binding with associated permissions
func NewClientFromCredentials(config common.PVEConfig, username common.Username, password string) (common.Backend, int, error) {
HTTPClient := http.Client{
@@ -52,16 +43,15 @@ func NewClientFromCredentials(config common.PVEConfig, username common.Username,
}
// creates a new client binding with associated permissions
func NewClientFromAPIToken(config common.PVEConfig) (common.Backend, int, error) {
func NewClientFromAPIToken(config common.PVEConfig, token common.PVEAPIToken) (common.Backend, int, error) {
HTTPClient := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{},
},
}
token := fmt.Sprintf(`%s@%s!%s`, config.Token.User, config.Token.Realm, config.Token.ID)
client := proxmox.NewClient(config.URL,
proxmox.WithHTTPClient(&HTTPClient),
proxmox.WithAPIToken(token, config.Token.UUID),
proxmox.WithAPIToken(token.ToString(), config.Token.UUID),
)
// check that the user is authenticated because proxmox.NewClient does not return an error