cmd/tailscale/cli, tailcfg: allow tag without "tag:" prefix in 'tailscale up'

Fixes #861
This commit is contained in:
Brad Fitzpatrick
2020-10-28 07:59:57 -07:00
parent d6ad41dcea
commit cd07437ade
2 changed files with 35 additions and 18 deletions
+11 -4
View File
@@ -182,11 +182,18 @@ func runUp(ctx context.Context, args []string) error {
var tags []string
if upArgs.advertiseTags != "" {
tags = strings.Split(upArgs.advertiseTags, ",")
for _, tag := range tags {
err := tailcfg.CheckTag(tag)
if err != nil {
fatalf("tag: %q: %s", tag, err)
for i, tag := range tags {
if strings.HasPrefix(tag, "tag:") {
// Accept fully-qualified tags (starting with
// "tag:"), as we do in the ACL file.
err := tailcfg.CheckTag(tag)
if err != nil {
fatalf("tag: %q: %v", tag, err)
}
} else if err := tailcfg.CheckTagSuffix(tag); err != nil {
fatalf("tag: %q: %v", tag, err)
}
tags[i] = "tag:" + tag
}
}