summaryrefslogtreecommitdiffhomepage
path: root/cmd/cloner
AgeCommit message (Collapse)AuthorFilesLines
2026-01-23all: remove AUTHORS file and references to itWill Norris4-4/+4
This file was never truly necessary and has never actually been used in the history of Tailscale's open source releases. A Brief History of AUTHORS files --- The AUTHORS file was a pattern developed at Google, originally for Chromium, then adopted by Go and a bunch of other projects. The problem was that Chromium originally had a copyright line only recognizing Google as the copyright holder. Because Google (and most open source projects) do not require copyright assignemnt for contributions, each contributor maintains their copyright. Some large corporate contributors then tried to add their own name to the copyright line in the LICENSE file or in file headers. This quickly becomes unwieldy, and puts a tremendous burden on anyone building on top of Chromium, since the license requires that they keep all copyright lines intact. The compromise was to create an AUTHORS file that would list all of the copyright holders. The LICENSE file and source file headers would then include that list by reference, listing the copyright holder as "The Chromium Authors". This also become cumbersome to simply keep the file up to date with a high rate of new contributors. Plus it's not always obvious who the copyright holder is. Sometimes it is the individual making the contribution, but many times it may be their employer. There is no way for the proejct maintainer to know. Eventually, Google changed their policy to no longer recommend trying to keep the AUTHORS file up to date proactively, and instead to only add to it when requested: https://opensource.google/docs/releasing/authors. They are also clear that: > Adding contributors to the AUTHORS file is entirely within the > project's discretion and has no implications for copyright ownership. It was primarily added to appease a small number of large contributors that insisted that they be recognized as copyright holders (which was entirely their right to do). But it's not truly necessary, and not even the most accurate way of identifying contributors and/or copyright holders. In practice, we've never added anyone to our AUTHORS file. It only lists Tailscale, so it's not really serving any purpose. It also causes confusion because Tailscalars put the "Tailscale Inc & AUTHORS" header in other open source repos which don't actually have an AUTHORS file, so it's ambiguous what that means. Instead, we just acknowledge that the contributors to Tailscale (whoever they are) are copyright holders for their individual contributions. We also have the benefit of using the DCO (developercertificate.org) which provides some additional certification of their right to make the contribution. The source file changes were purely mechanical with: git ls-files | xargs sed -i -e 's/\(Tailscale Inc &\) AUTHORS/\1 contributors/g' Updates #cleanup Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
2025-11-13cmd/cloner: support cloning arbitrarily-nested mapsAndrew Dunham4-32/+354
Fixes #17870 Signed-off-by: Andrew Dunham <andrew@tailscale.com>
2025-11-12cmd/{cloner,viewer}: handle maps of viewsAndrew Dunham1-4/+10
Instead of trying to call View() on something that's already a View type (or trying to Clone the view unnecessarily), we can re-use the existing View values in a map[T]ViewType. Fixes #17866 Signed-off-by: Andrew Dunham <andrew@tailscale.com>
2025-10-10types/persist: add AttestationKey (#17281)Patrick O'Doherty4-3/+108
Extend Persist with AttestationKey to record a hardware-backed attestation key for the node's identity. Add a flag to tailscaled to allow users to control the use of hardware-backed keys to bind node identity to individual machines. Updates tailscale/corp#31269 Change-Id: Idcf40d730a448d85f07f1bebf387f086d4c58be3 Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2025-08-14cmd/viewer, types/views: implement support for json/v2 (#16852)Joe Tsai1-6/+6
This adds support for having every viewer type implement jsonv2.MarshalerTo and jsonv2.UnmarshalerFrom. This provides a significant boost in performance as the json package no longer needs to validate the entirety of the JSON value outputted by MarshalJSON, nor does it need to identify the boundaries of a JSON value in order to call UnmarshalJSON. For deeply nested and recursive MarshalJSON or UnmarshalJSON calls, this can improve runtime from O(N²) to O(N). This still references "github.com/go-json-experiment/json" instead of the experimental "encoding/json/v2" package now available in Go 1.25 under goexperiment.jsonv2 so that code still builds without the experiment tag. Of note, the "github.com/go-json-experiment/json" package aliases the standard library under the right build conditions. Updates tailscale/corp#791 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2025-06-16scripts/check_license_headers.sh: delete, rewrite as a Go testBrad Fitzpatrick1-0/+1
Updates tailscale/corp#29650 Change-Id: Iad4e4ccd9d68ebb1d1a12f335cc5295d0bd05b60 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-08-23cmd/cloner, cmd/viewer, util/codegen: add support for aliases of cloneable typesNick Khyl1-2/+2
We have several checked type assertions to *types.Named in both cmd/cloner and cmd/viewer. As Go 1.23 updates the go/types package to produce Alias type nodes for type aliases, these type assertions no longer work as expected unless the new behavior is disabled with gotypesalias=0. In this PR, we add codegen.NamedTypeOf(t types.Type), which functions like t.(*types.Named) but also unrolls type aliases. We then use it in place of type assertions in the cmd/cloner and cmd/viewer packages where appropriate. We also update type switches to include *types.Alias alongside *types.Named in relevant cases, remove *types.Struct cases when switching on types.Type.Underlying and update the tests with more cases where type aliases can be used. Updates #13224 Updates #12912 Signed-off-by: Nick Khyl <nickk@tailscale.com>
2024-08-23util/codegen, cmd/cloner, cmd/viewer: update codegen.LookupMethod to support ↵Nick Khyl1-1/+1
alias type nodes Go 1.23 updates the go/types package to produce Alias type nodes for type aliases, unless disabled with gotypesalias=0. This new default behavior breaks codegen.LookupMethod, which uses checked type assertions to types.Named and types.Interface, as only named types and interfaces have methods. In this PR, we update codegen.LookupMethod to perform method lookup on the right-hand side of the alias declaration and clearly switch on the supported type nodes types. We also improve support for various edge cases, such as when an alias is used as a type parameter constraint, and add tests for the LookupMethod function. Additionally, we update cmd/viewer/tests to include types with aliases used in type fields and generic type constraints. Updates #13224 Updates #12912 Signed-off-by: Nick Khyl <nickk@tailscale.com>
2024-07-12cmd/cloner, cmd/viewer: add _test prefix for files generated with the test ↵Nick Khyl1-1/+5
build tag Updates #12736 Signed-off-by: Nick Khyl <nickk@tailscale.com>
2024-07-11cmd/cloner, cmd/viewer, util/codegen: add support for generic types and ↵Nick Khyl1-13/+72
interfaces This adds support for generic types and interfaces to our cloner and viewer codegens. It updates these packages to determine whether to make shallow or deep copies based on the type parameter constraints. Additionally, if a template parameter or an interface type has View() and Clone() methods, we'll use them for getters and the cloner of the owning structure. Updates #12736 Signed-off-by: Nick Khyl <nickk@tailscale.com>
2024-07-10all: add test for package comments, fix, add comments as neededBrad Fitzpatrick1-0/+1
Updates #cleanup Change-Id: Ic4304e909d2131a95a38b26911f49e7b1729aaef Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-04-16all: use Go 1.22 range-over-intBrad Fitzpatrick1-1/+1
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-09-30cmd/cloner: fix typo in test type's nameBrad Fitzpatrick3-16/+16
s/SliceContianer/SliceContainer/g Updates #9604 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-09-29cmd/cloner: add regression test for slice nil/empty semanticsJames Tucker4-0/+126
We had a misstep with the semantics when applying an optimization that showed up in the roll into corp. This test ensures that case and related cases must be retained. Updates #9410 Updates #9601 Signed-off-by: James Tucker <james@tailscale.com>
2023-09-29cmd/cloner,*: revert: optimize nillable slice clonerJames Tucker1-1/+3
This reverts commit ee90cd02fdd4e4125ec9d12eef1195ed36ef4b2e. The outcome is not identical for empty slices. Cloner really needs tests! Updates #9601 Signed-off-by: James Tucker <james@tailscale.com>
2023-09-29cmd/cloner,*: optimize nillable slice clonerJames Tucker1-3/+1
A wild @josharian appears with a good suggestion for a refactor, thanks Josh! Updates #9410 Signed-off-by: James Tucker <james@tailscale.com>
2023-09-14cmd/cloner: do not allocate slices when the source is nilJames Tucker1-0/+2
tailcfg.Node zero-value clone equality checks failed when I added a []*foo to the structure, as the zero value and it's clone contained a different slice header. Updates #9377 Updates #9408 Signed-off-by: James Tucker <james@tailscale.com>
2023-08-20cmd/cloner: use maps.Clone and ptr.ToMaisem Ali1-13/+13
Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-07-25tailcfg,ipn/ipnlocal,wgengine: add values to PeerCapabilitiesMaisem Ali1-0/+2
Define PeerCapabilty and PeerCapMap as the new way of sending down inter-peer capability information. Previously, this was unstructured and you could only send down strings which got too limiting for certain usecases. Instead add the ability to send down raw JSON messages that are opaque to Tailscale but provide the applications to define them however they wish. Also update accessors to use the new values. Updates #4217 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-01-27all: update tools that manage copyright headersWill Norris1-1/+1
Update all code generation tools, and those that check for license headers to use the new standard header. Also update copyright statement in LICENSE file. Fixes #6865 Signed-off-by: Will Norris <will@tailscale.com>
2023-01-27all: update copyright and license headersWill Norris1-3/+2
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
2023-01-02util/codegen, all: use latest year, not time.Now, in generated filesBrad Fitzpatrick1-1/+1
Updates #6865 Change-Id: I6b86c646968ebbd4553cf37df5e5612fbf5c5f7d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-08-03cmd/{cloner,viewer}: add support for map values with pointersMaisem Ali1-4/+11
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-06cmd/viewer: add codegen tool for ViewsMaisem Ali1-2/+7
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-06cmd/cloner,util/codegen: refactor cloner internals to allow reuseMaisem Ali1-87/+14
Also run go generate again for Copyright updates. Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-03-17all: use any instead of interface{}Josh Bleecher Snyder1-3/+3
My favorite part of generics. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2022-02-16tailcfg: make Node.Hostinfo a HostinfoViewMaisem Ali1-3/+20
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2021-10-16cmd/cloner: mangle "go:generate" in cloner.goJoe Tsai1-1/+1
The "go generate" command blindly looks for "//go:generate" anywhere in the file regardless of whether it is truly a comment. Prevent this false positive in cloner.go by mangling the string to look less like "//go:generate". Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2021-10-14cmd/cloner: emit go:generate pragmas (#3082)Joe Tsai1-3/+16
Emit a go:generate pragma with the full set of flags passed to cloner. This allows the user to simply run "go generate" at the location of the generate file to reproduce the file. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2021-09-17util/codegen: reorder AssertStructUnchanged argsJosh Bleecher Snyder1-1/+1
The fully qualified name of the type is thisPkg.tname, so write the args like that too. Suggested-by: Joe Tsai <joetsai@digital-static.net> Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17util/codegen: add ContainsPointersJosh Bleecher Snyder1-36/+5
And use it in cmd/cloner. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17cmd/cloner: unify switch casesJosh Bleecher Snyder1-3/+1
And in the process, fix a bug: The fmt formatting was being applied by writef, not fmt.Sprintf, thus emitting a MISSING string. And there's no guarantee that fmt will be imported in the generated code. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17util/codegen: add NamedTypesJosh Bleecher Snyder1-26/+4
And use it in cmd/cloner. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17cmd/cloner: delete some debug codeJosh Bleecher Snyder1-4/+0
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17cmd/cloner: simplify codeJosh Bleecher Snyder1-77/+79
Change from a single-case type switch to a type assertion with an early return. That exposes that the name arg to gen is unneeded. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17cmd/cloner: add Clone context to regen struct assignmentsJosh Bleecher Snyder1-1/+1
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17util/codegen: add AssertStructUnchangedJosh Bleecher Snyder1-18/+1
Refactored out from cmd/cloner. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-17util/codegen: add packageJosh Bleecher Snyder1-8/+2
This is a package for shared utilities used in doing codegen programs. The inaugural API is for writing gofmt'd code to a file. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-09-15cmd/cloner: reduce diff noise when changing commandJosh Bleecher Snyder1-3/+3
Spelling out the command to run for every type means that changing the command makes for a large, repetitive diff. Stop doing that. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-06-22cmd/cloner: support maps with clone ptrsjulianknodt1-1/+3
In order to clone DERPMaps, it was necessary to extend the cloner so that it supports nested pointers inside of maps which are also cloneable. This also adds cloning for DERPRegions and DERPNodes because they are on DERPMap's maps. Signed-off-by: julianknodt <julianknodt@gmail.com>
2021-01-11all: adjust Unix permissions for those without umasksBrad Fitzpatrick1-1/+1
Fixes tailscale/corp#1165 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-10-19ipn: use cmd/cloner for Prefs.CloneBrad Fitzpatrick1-18/+21
Also, make cmd/cloner's top-level "func Clone" generation opt-in. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-09-04cmd/cloner: generate a package-level Clone functionJosh Bleecher Snyder1-0/+23
This Clone function knows how to clone any types for which it has generated Clone methods. This allows callers to efficiently clone an inbound interface{} that might contain one of these types. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-09-04cmd/cloner: fix found type detectionJosh Bleecher Snyder1-1/+1
This was causing any type to be reported as found, as long as there were any type decls at all. Oops. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-09-04cmd/cloner: ensure cloner gets re-run when structs changeJosh Bleecher Snyder1-1/+20
If you change a struct and don't re-run cloner, your Cloner method might be inaccurate, leading to bad things. To prevent this, write out the struct as it is at the moment that cloner is caller, and attempt a conversion from that type. If the struct gets changed in any way, this conversion will fail. This will yield false positives: If you change a non-pointer field, you will be forced to re-run cloner, even though the actual generated code won't change. I think this is an acceptable cost: It is a minor annoyance, which will prevent real bugs. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-07-27cmd/cloner, tailcfg: fix nil vs len 0 issues, add tests, use for HostinfoBrad Fitzpatrick1-3/+3
Also use go:generate and https://golang.org/s/generatedcode header style. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-07-27cmd/cloner: tool to generate Clone methodsDavid Crawshaw1-0/+264
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>