tailcfg: add Clone method for RegisterResponse

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
reviewable/pr792/r1
David Crawshaw 4 years ago committed by David Crawshaw
parent 15297a3a09
commit 7616acd118

@ -4,7 +4,7 @@
package tailcfg 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 ( import (
"bytes" "bytes"

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package tailcfg
@ -28,7 +28,7 @@ func (src *User) Clone() *User {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _UserNeedsRegeneration = User(struct {
ID UserID ID UserID
LoginName string LoginName string
@ -60,7 +60,7 @@ func (src *Node) Clone() *Node {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _NodeNeedsRegeneration = Node(struct {
ID NodeID ID NodeID
Name string Name string
@ -96,7 +96,7 @@ func (src *Hostinfo) Clone() *Hostinfo {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _HostinfoNeedsRegeneration = Hostinfo(struct {
IPNVersion string IPNVersion string
FrontendLogID string FrontendLogID string
@ -130,7 +130,7 @@ func (src *NetInfo) Clone() *NetInfo {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _NetInfoNeedsRegeneration = NetInfo(struct {
MappingVariesByDestIP opt.Bool MappingVariesByDestIP opt.Bool
HairPinning 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: // 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 { var _GroupNeedsRegeneration = Group(struct {
ID GroupID ID GroupID
Name string Name string
@ -177,7 +177,7 @@ func (src *Role) Clone() *Role {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _RoleNeedsRegeneration = Role(struct {
ID RoleID ID RoleID
Name string Name string
@ -196,7 +196,7 @@ func (src *Capability) Clone() *Capability {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _CapabilityNeedsRegeneration = Capability(struct {
ID CapabilityID ID CapabilityID
Type CapType Type CapType
@ -215,7 +215,7 @@ func (src *Login) Clone() *Login {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _LoginNeedsRegeneration = Login(struct {
_ structs.Incomparable _ structs.Incomparable
ID LoginID ID LoginID
@ -240,7 +240,7 @@ func (src *DNSConfig) Clone() *DNSConfig {
} }
// A compilation failure here means this code must be regenerated, with command: // 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 { var _DNSConfigNeedsRegeneration = DNSConfig(struct {
Nameservers []netaddr.IP Nameservers []netaddr.IP
Domains []string Domains []string
@ -248,9 +248,31 @@ var _DNSConfigNeedsRegeneration = DNSConfig(struct {
Proxied bool 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. // Clone duplicates src into dst and reports whether it succeeded.
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>, // To succeed, <src, dst> 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 { func Clone(dst, src interface{}) bool {
switch src := src.(type) { switch src := src.(type) {
case *User: case *User:
@ -334,6 +356,15 @@ func Clone(dst, src interface{}) bool {
*dst = src.Clone() *dst = src.Clone()
return true return true
} }
case *RegisterResponse:
switch dst := dst.(type) {
case *RegisterResponse:
*dst = *src.Clone()
return true
case **RegisterResponse:
*dst = src.Clone()
return true
}
} }
return false return false
} }

Loading…
Cancel
Save