Skip to content

Commit

Permalink
feat: return error if validation is failed
Browse files Browse the repository at this point in the history
  • Loading branch information
restanrm committed May 13, 2022
1 parent ad4401a commit fdbc965
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions grpcv1.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package headscale

import (
"context"
"strings"
"time"

v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
Expand Down Expand Up @@ -191,6 +192,15 @@ func (api headscaleV1APIServer) SetTags(
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())

log.Trace().
Expand Down

0 comments on commit fdbc965

Please sign in to comment.