added server ref

This commit is contained in:
ston1th 2020-10-25 21:29:19 +01:00
commit 78911eca56
4 changed files with 107 additions and 68 deletions

View file

@ -37,6 +37,19 @@ func ParseURL(s string) (pool, node, id string, err error) {
return u.Host, a[1], a[2], nil
}
func ServerRefFromURL(s string) (ref *ServerRef, err error) {
pool, node, id, err := ParseURL(s)
if err != nil {
return
}
ref = &ServerRef{
ID: id,
Node: node,
Pool: pool,
}
return
}
func NewURL(pool, node, id string) string {
return fmt.Sprintf("%s://%s/%s/%s", PVEScheme, pool, node, id)
}