tailcfg: add VIPServiceView

Not currently used in the OSS tree, a View for tailcfg.VIPService will
make implementing some server side changes easier.

Updates tailscale/corp#26272

Change-Id: If1ed0bea4eff8c4425d3845b433a1c562d99eb9e
Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
This commit is contained in:
Adrian Dewhurst
2025-04-01 19:05:45 -04:00
committed by Adrian Dewhurst
parent 13f6981694
commit e2f7750125
3 changed files with 87 additions and 3 deletions

View File

@@ -626,9 +626,28 @@ var _UserProfileCloneNeedsRegeneration = UserProfile(struct {
ProfilePicURL string
}{})
// Clone makes a deep copy of VIPService.
// The result aliases no memory with the original.
func (src *VIPService) Clone() *VIPService {
if src == nil {
return nil
}
dst := new(VIPService)
*dst = *src
dst.Ports = append(src.Ports[:0:0], src.Ports...)
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _VIPServiceCloneNeedsRegeneration = VIPService(struct {
Name ServiceName
Ports []ProtoPortRange
Active bool
}{})
// Clone duplicates src into dst and reports whether it succeeded.
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
// where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,RegisterResponseAuth,RegisterRequest,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile.
// where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,RegisterResponseAuth,RegisterRequest,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile,VIPService.
func Clone(dst, src any) bool {
switch src := src.(type) {
case *User:
@@ -802,6 +821,15 @@ func Clone(dst, src any) bool {
*dst = src.Clone()
return true
}
case *VIPService:
switch dst := dst.(type) {
case *VIPService:
*dst = *src.Clone()
return true
case **VIPService:
*dst = src.Clone()
return true
}
}
return false
}