From 7616acd1181b8ba25a4abbe2cf4710b4410cbdee Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Tue, 6 Oct 2020 14:02:57 -0400 Subject: [PATCH] tailcfg: add Clone method for RegisterResponse Signed-off-by: David Crawshaw --- tailcfg/tailcfg.go | 2 +- tailcfg/tailcfg_clone.go | 53 +++++++++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 30f5988d1..a1d6a08a2 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -4,7 +4,7 @@ package tailcfg -//go:generate go run tailscale.com/cmd/cloner -type=User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig -output=tailcfg_clone.go +//go:generate go run tailscale.com/cmd/cloner -type=User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse -output=tailcfg_clone.go import ( "bytes" diff --git a/tailcfg/tailcfg_clone.go b/tailcfg/tailcfg_clone.go index c112888ec..8389cab45 100644 --- a/tailcfg/tailcfg_clone.go +++ b/tailcfg/tailcfg_clone.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Code generated by tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig; DO NOT EDIT. +// Code generated by tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse; DO NOT EDIT. package tailcfg @@ -28,7 +28,7 @@ func (src *User) Clone() *User { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _UserNeedsRegeneration = User(struct { ID UserID LoginName string @@ -60,7 +60,7 @@ func (src *Node) Clone() *Node { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _NodeNeedsRegeneration = Node(struct { ID NodeID Name string @@ -96,7 +96,7 @@ func (src *Hostinfo) Clone() *Hostinfo { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _HostinfoNeedsRegeneration = Hostinfo(struct { IPNVersion string FrontendLogID string @@ -130,7 +130,7 @@ func (src *NetInfo) Clone() *NetInfo { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _NetInfoNeedsRegeneration = NetInfo(struct { MappingVariesByDestIP opt.Bool HairPinning opt.Bool @@ -157,7 +157,7 @@ func (src *Group) Clone() *Group { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _GroupNeedsRegeneration = Group(struct { ID GroupID Name string @@ -177,7 +177,7 @@ func (src *Role) Clone() *Role { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _RoleNeedsRegeneration = Role(struct { ID RoleID Name string @@ -196,7 +196,7 @@ func (src *Capability) Clone() *Capability { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _CapabilityNeedsRegeneration = Capability(struct { ID CapabilityID Type CapType @@ -215,7 +215,7 @@ func (src *Login) Clone() *Login { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _LoginNeedsRegeneration = Login(struct { _ structs.Incomparable ID LoginID @@ -240,7 +240,7 @@ func (src *DNSConfig) Clone() *DNSConfig { } // A compilation failure here means this code must be regenerated, with command: -// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse var _DNSConfigNeedsRegeneration = DNSConfig(struct { Nameservers []netaddr.IP Domains []string @@ -248,9 +248,31 @@ func (src *DNSConfig) Clone() *DNSConfig { Proxied bool }{}) +// Clone makes a deep copy of RegisterResponse. +// The result aliases no memory with the original. +func (src *RegisterResponse) Clone() *RegisterResponse { + if src == nil { + return nil + } + dst := new(RegisterResponse) + *dst = *src + dst.User = *src.User.Clone() + return dst +} + +// A compilation failure here means this code must be regenerated, with command: +// tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse +var _RegisterResponseNeedsRegeneration = RegisterResponse(struct { + User User + Login Login + NodeKeyExpired bool + MachineAuthorized bool + AuthURL string +}{}) + // Clone duplicates src into dst and reports whether it succeeded. // To succeed, must be of types <*T, *T> or <*T, **T>, -// where T is one of User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig. +// where T is one of User,Node,Hostinfo,NetInfo,Group,Role,Capability,Login,DNSConfig,RegisterResponse. func Clone(dst, src interface{}) bool { switch src := src.(type) { case *User: @@ -334,6 +356,15 @@ func Clone(dst, src interface{}) bool { *dst = src.Clone() return true } + case *RegisterResponse: + switch dst := dst.(type) { + case *RegisterResponse: + *dst = *src.Clone() + return true + case **RegisterResponse: + *dst = src.Clone() + return true + } } return false }