mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-25 19:21:18 -08:00
cmd/tailscale/cli: drop node-local prefs from blueprint locked-fields
Brings the v1 locked-field set to spec v2 (§11). The v1 list inherited
ten entries from the v1.1-era KB doc; the latest spec narrowed the set
to fields the blueprint actually owns, dropping:
- hostname / operator: node-local concerns the blueprint has no
opinion on, per the join-flag rationale at the bottom of §11.
- shields-up / webclient: not in the v2 prefs allowlist (the v1
projection also drops them; see the followup commit).
Six entries remain: advertise-tags, advertise-routes,
advertise-connector, ssh, accept-dns, accept-routes. advertise-routes
also covers advertise-exit-node, since exit-node advertisement is
stored as the v4+v6 default routes in Prefs.AdvertiseRoutes and shares
its MaskedPrefs bit.
TestCheckBlueprintSetLocked_AllLockedFields shrinks accordingly. A new
TestCheckBlueprintSetLocked_NodeLocalFieldsAllowed pins the negative
contract: each of the four dropped fields must NOT be rejected on a
bound node, so a future regression can't silently re-add them.
Updates #cleanup
Signed-off-by: Kabir Sikand <[email protected]>
This commit is contained in:
1 parent
c3721ba263
commit
3617eb33af
2 files changed
+36
-42
No files matched your search
@@ -29,8 +29,13 @@ type blueprintLockedField struct {
|
||||
|
||||
// blueprintLockedFields enumerates every Prefs field that
|
||||
// `tailscale set` refuses to edit on a blueprint-bound node. The
|
||||
// list is sourced verbatim from the Blueprints v1 spec; if you add
|
||||
// or remove a locked field here, update the spec and BLUEPRINTS.md.
|
||||
// list is sourced from spec §11; if you add or remove a locked field
|
||||
// here, update the spec and BLUEPRINTS.md.
|
||||
//
|
||||
// Spec v2 excludes node-local concerns (hostname, operator) and the
|
||||
// v1.1-era node-level toggles shields-up and webclient. AdvertiseRoutes
|
||||
// also covers advertise-exit-node, since exit-node advertisement is
|
||||
// stored as the v4+v6 default routes in Prefs.AdvertiseRoutes.
|
||||
//
|
||||
// The order matters: the first matching field in this slice is the
|
||||
// one named in the user-visible error message. Ordering follows the
|
||||
@@ -51,16 +56,6 @@ var blueprintLockedFields = []blueprintLockedField{
|
||||
plural: "App connector advertisement",
|
||||
maskField: func(m *ipn.MaskedPrefs) bool { return m.AppConnectorSet },
|
||||
},
|
||||
{
|
||||
flag: "hostname",
|
||||
plural: "Hostname",
|
||||
maskField: func(m *ipn.MaskedPrefs) bool { return m.HostnameSet },
|
||||
},
|
||||
{
|
||||
flag: "operator",
|
||||
plural: "Operator user",
|
||||
maskField: func(m *ipn.MaskedPrefs) bool { return m.OperatorUserSet },
|
||||
},
|
||||
{
|
||||
flag: "ssh",
|
||||
plural: "SSH",
|
||||
@@ -76,16 +71,6 @@ var blueprintLockedFields = []blueprintLockedField{
|
||||
plural: "Route acceptance",
|
||||
maskField: func(m *ipn.MaskedPrefs) bool { return m.RouteAllSet },
|
||||
},
|
||||
{
|
||||
flag: "shields-up",
|
||||
plural: "Shields-up",
|
||||
maskField: func(m *ipn.MaskedPrefs) bool { return m.ShieldsUpSet },
|
||||
},
|
||||
{
|
||||
flag: "webclient",
|
||||
plural: "Web client",
|
||||
maskField: func(m *ipn.MaskedPrefs) bool { return m.RunWebClientSet },
|
||||
},
|
||||
}
|
||||
|
||||
// checkBlueprintSetLocked returns a non-nil error if curPrefs is
|
||||
|
||||
@@ -79,16 +79,6 @@ func TestCheckBlueprintSetLocked_AllLockedFields(t *testing.T) {
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.AppConnectorSet = true },
|
||||
wantField: "App connector advertisement",
|
||||
},
|
||||
{
|
||||
name: "hostname",
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.HostnameSet = true },
|
||||
wantField: "Hostname",
|
||||
},
|
||||
{
|
||||
name: "operator",
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.OperatorUserSet = true },
|
||||
wantField: "Operator user",
|
||||
},
|
||||
{
|
||||
name: "ssh",
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.RunSSHSet = true },
|
||||
@@ -104,16 +94,6 @@ func TestCheckBlueprintSetLocked_AllLockedFields(t *testing.T) {
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.RouteAllSet = true },
|
||||
wantField: "Route acceptance",
|
||||
},
|
||||
{
|
||||
name: "shields-up",
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.ShieldsUpSet = true },
|
||||
wantField: "Shields-up",
|
||||
},
|
||||
{
|
||||
name: "webclient",
|
||||
setMask: func(m *ipn.MaskedPrefs) { m.RunWebClientSet = true },
|
||||
wantField: "Web client",
|
||||
},
|
||||
}
|
||||
cur := &ipn.Prefs{BlueprintID: "bp1"}
|
||||
for _, tt := range tests {
|
||||
@@ -137,6 +117,35 @@ func TestCheckBlueprintSetLocked_AllLockedFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCheckBlueprintSetLocked_NodeLocalFieldsAllowed asserts the spec
|
||||
// v2 narrowing: hostname, operator, shields-up, and webclient are
|
||||
// node-local concerns that a blueprint has no opinion on. Setting any
|
||||
// of them on a blueprint-bound node must NOT be rejected.
|
||||
//
|
||||
// This catches a regression where v1 (and the legacy v1.1 KB doc)
|
||||
// listed these among the locked fields. Spec §11 dropped them.
|
||||
func TestCheckBlueprintSetLocked_NodeLocalFieldsAllowed(t *testing.T) {
|
||||
cur := &ipn.Prefs{BlueprintID: "bp1"}
|
||||
tests := []struct {
|
||||
name string
|
||||
setMask func(*ipn.MaskedPrefs)
|
||||
}{
|
||||
{"hostname", func(m *ipn.MaskedPrefs) { m.HostnameSet = true }},
|
||||
{"operator", func(m *ipn.MaskedPrefs) { m.OperatorUserSet = true }},
|
||||
{"shields-up", func(m *ipn.MaskedPrefs) { m.ShieldsUpSet = true }},
|
||||
{"webclient", func(m *ipn.MaskedPrefs) { m.RunWebClientSet = true }},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mp := &ipn.MaskedPrefs{}
|
||||
tt.setMask(mp)
|
||||
if err := checkBlueprintSetLocked(cur, mp); err != nil {
|
||||
t.Errorf("bound prefs rejected node-local field %q: %v", tt.name, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestCheckBlueprintSetLocked_NilPrefs verifies that a nil curPrefs
|
||||
// pointer (an unlikely but possible state during early daemon
|
||||
// boot) does not panic and is treated as not-bound.
|
||||
|
||||
Reference in new issue
Block a user