mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
feat: return error if validation is failed
This commit is contained in:
parent
ad4401aa40
commit
fdbc9657bc
1 changed files with 10 additions and 0 deletions
10
grpcv1.go
10
grpcv1.go
|
@ -3,6 +3,7 @@ package headscale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
|
@ -191,6 +192,15 @@ func (api headscaleV1APIServer) SetTags(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, tag := range request.GetTags() {
|
||||||
|
if strings.Index(tag, "tag:") != 0 {
|
||||||
|
return &v1.SetTagsResponse{Machine: nil, Error: &v1.Error{
|
||||||
|
Status: 400,
|
||||||
|
Message: "Invalid tag detected. Each tag must start with the string 'tag:'",
|
||||||
|
}}, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
api.h.SetTags(machine, request.GetTags())
|
api.h.SetTags(machine, request.GetTags())
|
||||||
|
|
||||||
log.Trace().
|
log.Trace().
|
||||||
|
|
Loading…
Reference in a new issue