From 9e2e8c80af7e388870cc4b88a65e06cd97407f49 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Fri, 21 Aug 2020 08:31:19 -0400 Subject: [PATCH] tailcfg: more Clone methods Signed-off-by: David Crawshaw --- tailcfg/tailcfg.go | 2 +- tailcfg/tailcfg_clone.go | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index f7f280e76..fc6ce0b0b 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 -output=tailcfg_clone.go +//go:generate go run tailscale.com/cmd/cloner -type=User,Node,Hostinfo,NetInfo,Group,Role,Capability -output=tailcfg_clone.go import ( "bytes" diff --git a/tailcfg/tailcfg_clone.go b/tailcfg/tailcfg_clone.go index 466871bbd..7ef9fea86 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; DO NOT EDIT. +// Code generated by tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Group,Role,Capability; DO NOT EDIT. package tailcfg @@ -73,3 +73,38 @@ func (src *NetInfo) Clone() *NetInfo { } return dst } + +// Clone makes a deep copy of Group. +// The result aliases no memory with the original. +func (src *Group) Clone() *Group { + if src == nil { + return nil + } + dst := new(Group) + *dst = *src + dst.Members = append(src.Members[:0:0], src.Members...) + return dst +} + +// Clone makes a deep copy of Role. +// The result aliases no memory with the original. +func (src *Role) Clone() *Role { + if src == nil { + return nil + } + dst := new(Role) + *dst = *src + dst.Capabilities = append(src.Capabilities[:0:0], src.Capabilities...) + return dst +} + +// Clone makes a deep copy of Capability. +// The result aliases no memory with the original. +func (src *Capability) Clone() *Capability { + if src == nil { + return nil + } + dst := new(Capability) + *dst = *src + return dst +}