fix(namespace): remove name validation for destroy and get

This commit is contained in:
Adrien Raffin-Caboisse 2022-02-23 13:35:57 +01:00
parent cef0a2b0b3
commit 7e4709c13f

View File

@ -65,10 +65,6 @@ func (h *Headscale) CreateNamespace(name string) (*Namespace, error) {
// DestroyNamespace destroys a Namespace. Returns error if the Namespace does // DestroyNamespace destroys a Namespace. Returns error if the Namespace does
// not exist or if there are machines associated with it. // not exist or if there are machines associated with it.
func (h *Headscale) DestroyNamespace(name string) error { func (h *Headscale) DestroyNamespace(name string) error {
err := CheckNamespaceName(name)
if err != nil {
return err
}
namespace, err := h.GetNamespace(name) namespace, err := h.GetNamespace(name)
if err != nil { if err != nil {
return errNamespaceNotFound return errNamespaceNotFound
@ -131,10 +127,6 @@ func (h *Headscale) RenameNamespace(oldName, newName string) error {
// GetNamespace fetches a namespace by name. // GetNamespace fetches a namespace by name.
func (h *Headscale) GetNamespace(name string) (*Namespace, error) { func (h *Headscale) GetNamespace(name string) (*Namespace, error) {
err := CheckNamespaceName(name)
if err != nil {
return nil, err
}
namespace := Namespace{} namespace := Namespace{}
if result := h.db.First(&namespace, "name = ?", name); errors.Is( if result := h.db.First(&namespace, "name = ?", name); errors.Is(
result.Error, result.Error,