mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
cmd/tailscale/cli: add ability to set short names for profiles
This adds a `--nickname` flag to `tailscale login|set`. Updates #713 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -2109,6 +2109,9 @@ func (b *LocalBackend) checkPrefsLocked(p *ipn.Prefs) error {
|
||||
// Keep this one just for testing.
|
||||
errs = append(errs, errors.New("bad hostname [test]"))
|
||||
}
|
||||
if err := b.checkProfileNameLocked(p); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if err := b.checkSSHPrefsLocked(p); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
@@ -2226,6 +2229,23 @@ func (b *LocalBackend) EditPrefs(mp *ipn.MaskedPrefs) (ipn.PrefsView, error) {
|
||||
return stripKeysFromPrefs(newPrefs), nil
|
||||
}
|
||||
|
||||
func (b *LocalBackend) checkProfileNameLocked(p *ipn.Prefs) error {
|
||||
if p.ProfileName == "" {
|
||||
// It is always okay to clear the profile name.
|
||||
return nil
|
||||
}
|
||||
id := b.pm.ProfileIDForName(p.ProfileName)
|
||||
if id == "" {
|
||||
// No profile with that name exists. That's fine.
|
||||
return nil
|
||||
}
|
||||
if id != b.pm.CurrentProfile().ID {
|
||||
// Name is already in use by another profile.
|
||||
return fmt.Errorf("profile name %q already in use", p.ProfileName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetPrefs saves new user preferences and propagates them throughout
|
||||
// the system. Implements Backend.
|
||||
func (b *LocalBackend) SetPrefs(newp *ipn.Prefs) {
|
||||
|
Reference in New Issue
Block a user