cmd/tailscale/cli,ipn/conffile: add declarative config mode for Services (#17435)

This commit adds the subcommands `get-config` and `set-config` to Serve,
which can be used to read the current Tailscale Services configuration
in a standard syntax and provide a configuration to declaratively apply
with that same syntax.

Both commands must be provided with either `--service=svc:service` for
one service, or `--all` for all services. When writing a config,
`--set-config --all` will overwrite all existing Services configuration,
and `--set-config --service=svc:service` will overwrite all
configuration for that particular Service. Incremental changes are not
supported.

Fixes tailscale/corp#30983.

cmd/tailscale/cli: hide serve "get-config"/"set-config" commands for now

tailscale/corp#33152 tracks unhiding them when docs exist.

Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
Naman Sood
2025-10-10 11:02:35 -04:00
committed by GitHub
parent 08eae9affd
commit f157f3288d
6 changed files with 556 additions and 13 deletions
+10
View File
@@ -17,6 +17,7 @@ import (
"net/netip"
"reflect"
"slices"
"strconv"
"strings"
"time"
@@ -1478,6 +1479,15 @@ func (pr PortRange) Contains(port uint16) bool {
var PortRangeAny = PortRange{0, 65535}
func (pr PortRange) String() string {
if pr.First == pr.Last {
return strconv.FormatUint(uint64(pr.First), 10)
} else if pr == PortRangeAny {
return "*"
}
return fmt.Sprintf("%d-%d", pr.First, pr.Last)
}
// NetPortRange represents a range of ports that's allowed for one or more IPs.
type NetPortRange struct {
_ structs.Incomparable