migrate to integer ID
This commit is contained in:
parent
ffb356182e
commit
7ff2a92118
4 changed files with 27 additions and 22 deletions
14
scheme.go
14
scheme.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -17,9 +18,10 @@ const (
|
|||
var (
|
||||
ErrInvalidPVEURL = errors.New("invalid pve url scheme")
|
||||
ErrNoID = errors.New("missing id in url")
|
||||
ErrParsingID = errors.New("error parsing id in url")
|
||||
)
|
||||
|
||||
func ParseURL(s string) (pool, node, id string, err error) {
|
||||
func ParseURL(s string) (pool, node string, id int, err error) {
|
||||
u, err := url.Parse(s)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -37,7 +39,11 @@ func ParseURL(s string) (pool, node, id string, err error) {
|
|||
err = ErrNoID
|
||||
return
|
||||
}
|
||||
return u.Host, a[1], a[2], nil
|
||||
id, err = strconv.Atoi(a[2])
|
||||
if err != nil {
|
||||
err = ErrParsingID
|
||||
}
|
||||
return u.Host, a[1], id, nil
|
||||
}
|
||||
|
||||
func ServerRefFromURL(s string) (ref *ServerRef, err error) {
|
||||
|
|
@ -53,8 +59,8 @@ func ServerRefFromURL(s string) (ref *ServerRef, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func NewURL(pool, node, id string) string {
|
||||
return fmt.Sprintf("%s%s/%s/%s", PVESchemeURL, pool, node, id)
|
||||
func NewURL(pool, node string, id int) string {
|
||||
return fmt.Sprintf("%s%s/%s/%d", PVESchemeURL, pool, node, id)
|
||||
}
|
||||
|
||||
func K8sURL(url string) (string, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue