Skip to content

Commit c6af5bb

Browse files
committed
all: add test for package comments, fix, add comments as needed
Updates #cleanup Change-Id: Ic4304e909d2131a95a38b26911f49e7b1729aaef Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent e92f4c6 commit c6af5bb

File tree

41 files changed

+120
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+120
-80
lines changed

appc/appctest/appctest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package appctest contains code to help test App Connectors.
45
package appctest
56

67
import (

cmd/cloner/clonerex/clonerex.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
//go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type SliceContainer
55

6+
// Package clonerex is an example package for the cloner tool.
67
package clonerex
78

89
type SliceContainer struct {

cmd/k8s-operator/dnsrecords.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
//go:build !plan9
55

6-
// tailscale-operator provides a way to expose services running in a Kubernetes
7-
// cluster to your Tailnet and to make Tailscale nodes available to cluster
8-
// workloads
96
package main
107

118
import (

cmd/k8s-operator/generate/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
//go:build !plan9
55

6+
// The generate command creates tailscale.com CRDs.
67
package main
78

89
import (

cmd/tailscale/cli/ffcomplete/internal/complete.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package internal contains internal code for the ffcomplete package.
45
package internal
56

67
import (

cmd/xdpderper/xdpderper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Command xdpderper runs the XDP STUN server.
45
package main
56

67
import (

derp/xdp/headers/update.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// The update program fetches the libbpf headers from the libbpf GitHub repository
5+
// and writes them to disk.
46
package main
57

68
import (

derp/xdp/xdp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package xdp contains the XDP STUN program.
45
package xdp
56

67
// XDPAttachFlags represents how XDP program will be attached to interface. This

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ require (
2020
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
2121
github.com/creack/pty v1.1.21
2222
github.com/dave/courtney v0.4.0
23-
github.com/dave/jennifer v1.7.0
2423
github.com/dave/patsy v0.0.0-20210517141501-957256f50cba
2524
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa
2625
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e
@@ -44,7 +43,6 @@ require (
4443
github.com/google/uuid v1.6.0
4544
github.com/goreleaser/nfpm/v2 v2.33.1
4645
github.com/hdevalence/ed25519consensus v0.2.0
47-
github.com/iancoleman/strcase v0.3.0
4846
github.com/illarion/gonotify v1.0.1
4947
github.com/inetaf/tcpproxy v0.0.0-20240214030015-3ce58045626c
5048
github.com/insomniacslk/dhcp v0.0.0-20231206064809-8c70d406f6d2

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ github.com/dave/brenda v1.1.0 h1:Sl1LlwXnbw7xMhq3y2x11McFu43AjDcwkllxxgZ3EZw=
242242
github.com/dave/brenda v1.1.0/go.mod h1:4wCUr6gSlu5/1Tk7akE5X7UorwiQ8Rij0SKH3/BGMOM=
243243
github.com/dave/courtney v0.4.0 h1:Vb8hi+k3O0h5++BR96FIcX0x3NovRbnhGd/dRr8inBk=
244244
github.com/dave/courtney v0.4.0/go.mod h1:3WSU3yaloZXYAxRuWt8oRyVb9SaRiMBt5Kz/2J227tM=
245-
github.com/dave/jennifer v1.7.0 h1:uRbSBH9UTS64yXbh4FrMHfgfY762RD+C7bUPKODpSJE=
246-
github.com/dave/jennifer v1.7.0/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc=
247245
github.com/dave/patsy v0.0.0-20210517141501-957256f50cba h1:1o36L4EKbZzazMk8iGC4kXpVnZ6TPxR2mZ9qVKjNNAs=
248246
github.com/dave/patsy v0.0.0-20210517141501-957256f50cba/go.mod h1:qfR88CgEGLoiqDaE+xxDCi5QA5v4vUoW0UCX2Nd5Tlc=
249247
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -548,8 +546,6 @@ github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU
548546
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
549547
github.com/hugelgupf/vmtest v0.0.0-20240102225328-693afabdd27f h1:ov45/OzrJG8EKbGjn7jJZQJTN7Z1t73sFYNIRd64YlI=
550548
github.com/hugelgupf/vmtest v0.0.0-20240102225328-693afabdd27f/go.mod h1:JoDrYMZpDPYo6uH9/f6Peqms3zNNWT2XiGgioMOIGuI=
551-
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
552-
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
553549
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
554550
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
555551
github.com/illarion/gonotify v1.0.1 h1:F1d+0Fgbq/sDWjj/r66ekjDG+IDeecQKUFH4wNwsoio=

internal/tooldeps/tooldeps.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
//go:build for_go_mod_tidy_only
55

6+
// Package tooldeps contains dependencies for tools used in the Tailscale repository,
7+
// so they're not removed by "go mod tidy".
68
package tooldeps
79

810
import (

ipn/ipnlocal/local.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package ipnlocal is the heart of the Tailscale node agent that controls
5+
// all the other misc pieces of the Tailscale node.
46
package ipnlocal
57

68
import (

ipn/ipnserver/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package ipnserver runs the LocalAPI HTTP server that communicates
5+
// with the LocalBackend.
46
package ipnserver
57

68
import (

ipn/store/kubestore/store_kube.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
// Package kubestore contains an ipn.StateStore implementation using Kubernetes Secrets.
5-
65
package kubestore
76

87
import (

k8s-operator/apis/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
//go:build !plan9
55

6+
// Package apis contains a constant to name the Tailscale Kubernetes Operator's schema group.
67
package apis
78

89
const GroupName = "tailscale.com"

k8s-operator/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
//go:build !plan9
55

6+
// Package kube contains types and utilities for the Tailscale Kubernetes Operator.
67
package kube
78

89
import (

kube/fake_client.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package kube provides a client to interact with Kubernetes.
5-
// This package is Tailscale-internal and not meant for external consumption.
6-
// Further, the API should not be considered stable.
74
package kube
85

96
import (

kube/grants.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package kube provides a client to interact with Kubernetes.
5-
// This package is Tailscale-internal and not meant for external consumption.
6-
// Further, the API should not be considered stable.
74
package kube
85

96
import "net/netip"

logtail/example/logadopt/logadopt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Command logadopt is a CLI tool to adopt a machine into a logtail collection.
45
package main
56

67
import (

net/dns/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package dns contains code to configure and manage DNS settings.
45
package dns
56

67
import (

net/netmon/state.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package interfaces contains helpers for looking up system network interfaces.
54
package netmon
65

76
import (

net/netstat/netstat_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package netstat returns the local machine's network connection table.
54
package netstat
65

76
import (

net/netutil/ip_forward.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package netutil contains misc shared networking code & types.
54
package netutil
65

76
import (

net/tstun/wrap.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// Package tstun provides a TUN struct implementing the tun.Device interface
5-
// with additional features as required by wgengine.
64
package tstun
75

86
import (

pkgdoc_test.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
package tailscaleroot
5+
6+
import (
7+
"go/parser"
8+
"go/token"
9+
"os"
10+
"path/filepath"
11+
"runtime"
12+
"strings"
13+
"testing"
14+
)
15+
16+
func TestPackageDocs(t *testing.T) {
17+
switch runtime.GOOS {
18+
case "darwin", "linux":
19+
// Enough coverage for CI+devs.
20+
default:
21+
t.Skipf("skipping on %s", runtime.GOOS)
22+
}
23+
24+
var goFiles []string
25+
err := filepath.Walk(".", func(path string, fi os.FileInfo, err error) error {
26+
if err != nil {
27+
return err
28+
}
29+
if fi.Mode().IsRegular() && strings.HasSuffix(path, ".go") {
30+
if strings.HasSuffix(path, "_test.go") {
31+
return nil
32+
}
33+
goFiles = append(goFiles, path)
34+
}
35+
return nil
36+
})
37+
if err != nil {
38+
t.Fatal(err)
39+
}
40+
41+
byDir := map[string][]string{} // dir => files
42+
for _, fileName := range goFiles {
43+
fset := token.NewFileSet()
44+
f, err := parser.ParseFile(fset, fileName, nil, parser.PackageClauseOnly|parser.ParseComments)
45+
if err != nil {
46+
t.Fatalf("failed to ParseFile %q: %v", fileName, err)
47+
}
48+
dir := filepath.Dir(fileName)
49+
if _, ok := byDir[dir]; !ok {
50+
byDir[dir] = nil
51+
}
52+
if f.Doc != nil {
53+
byDir[dir] = append(byDir[dir], fileName)
54+
txt := f.Doc.Text()
55+
if strings.Contains(txt, "SPDX-License-Identifier") {
56+
t.Errorf("the copyright header for %s became its package doc due to missing blank line", fileName)
57+
}
58+
}
59+
}
60+
for dir, ff := range byDir {
61+
switch dir {
62+
case "tstest/integration/vms":
63+
// This package has a couple go:build ignore commands and this test doesn't
64+
// handle parsing those. Just allowlist that package for now (2024-07-10).
65+
continue
66+
}
67+
if len(ff) > 1 {
68+
t.Logf("multiple files with package doc in %s: %q", dir, ff)
69+
}
70+
if len(ff) == 0 {
71+
t.Errorf("no package doc in %s", dir)
72+
}
73+
}
74+
t.Logf("parsed %d files", len(goFiles))
75+
}

posture/doc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
// Package posture contains functions to query the local system
5+
// state for managed posture checks.
6+
package posture

tailcfg/tailcfg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
// Package tailcfg contains types used by the Tailscale protocol with between
5+
// the node and the coordination server.
46
package tailcfg
57

68
//go:generate go run tailscale.com/cmd/viewer --type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,RegisterResponseAuth,RegisterRequest,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile --clonefunc

tool/gocross/gocross.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// In short, when aliased to `go`, using `go build`, `go test` behave like the
99
// upstream Go tools, but produce correctly configured, correctly linked
1010
// binaries stamped with version information.
11-
1211
package main
1312

1413
import (

tstest/integration/vms/gen/test_codegen.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

tstest/tools/tools.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
// This file exists just so `go mod tidy` won't remove
5-
// tool modules from our go.mod.
6-
74
//go:build tools
85

6+
// This file exists just so `go mod tidy` won't remove
7+
// tool modules from our go.mod.
98
package tools
109

1110
import (

types/key/doc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
// Package key contains types for different types of public and private keys
5+
// used by Tailscale.
6+
package key

0 commit comments

Comments
 (0)