initial commit

This commit is contained in:
ston1th 2020-06-01 12:18:20 +02:00
commit 501d579a90
35 changed files with 11357 additions and 0 deletions

30
scheme.go Normal file
View file

@ -0,0 +1,30 @@
// Copyright (C) 2020 Marius Schellenberger
package pve
import (
"errors"
"fmt"
"net/url"
"strings"
)
const PVEScheme = "pve"
var ErrInvalidPVEURL = errors.New("invalid pve url scheme")
func ParseURL(s string) (node, id string, err error) {
u, err := url.Parse(s)
if err != nil {
return
}
if u.Scheme != PVEScheme {
err = ErrInvalidPVEURL
return
}
return u.Host, strings.TrimPrefix(u.Path, "/"), nil
}
func NewURL(node, id string) string {
return fmt.Sprintf("%s://%s/%s", PVEScheme, node, id)
}