Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x](backport #5443) mage: check that links are live in the OTel README #5667

Merged
merged 8 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 204 additions & 78 deletions NOTICE.txt

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions dev-tools/mage/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,16 @@ func CheckLicenseHeaders() error {
)

}

// CheckLinksInFileAreLive checks if all links in a file are live.
func CheckLinksInFileAreLive(filename string) func() error {
return func() error {
fmt.Printf(">> check: Checking for invalid links in %q\n", filename)
mg.Deps(InstallGoLinkCheck)

linkcheck := gotool.LinkCheck
return linkcheck(
linkcheck.Path(filename),
)
}
}
21 changes: 21 additions & 0 deletions dev-tools/mage/gotool/linkcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License 2.0;
// you may not use this file except in compliance with the Elastic License 2.0.

package gotool

import (
"github.com/magefile/mage/sh"
)

type goLinkCheck func(opts ...ArgOpt) error

// LinkCheck runs a tool to verify that links in a file are live.
var LinkCheck goLinkCheck = runGoLinkCheck

func runGoLinkCheck(opts ...ArgOpt) error {
args := buildArgs(opts).build()
return sh.RunV("link-patrol", args...)
}

func (goLinkCheck) Path(path string) ArgOpt { return flagArgIf("-f", path) }
10 changes: 10 additions & 0 deletions dev-tools/mage/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
var (
// GoLicenserImportPath controls the import path used to install go-licenser.
GoLicenserImportPath = "github.com/elastic/go-licenser"

// GoLinkCheckImportPath controls the import path used to install the link check tool
GoLinkCheckImportPath = "github.com/rednafi/link-patrol/cmd/link-patrol"
)

// InstallVendored uses go get to install a command from its vendored source
Expand All @@ -28,3 +31,10 @@ func InstallGoLicenser() error {
gotool.Install.Package(GoLicenserImportPath),
)
}

// InstallGoLinkCheck target installs the link check tool
func InstallGoLinkCheck() error {
return gotool.Install(
gotool.Install.Package(GoLinkCheckImportPath),
)
}
42 changes: 25 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ require (
github.com/elastic/go-ucfg v0.8.8
github.com/elastic/mock-es v0.0.0-20240712014503-e5b47ece0015
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.12.0
github.com/fatih/color v1.16.0
github.com/fatih/color v1.17.0
github.com/fsnotify/fsnotify v1.7.0
github.com/go-viper/mapstructure/v2 v2.1.0
github.com/gofrs/flock v0.8.1
github.com/gofrs/flock v0.12.1
github.com/gofrs/uuid/v5 v5.2.0
github.com/google/go-cmp v0.6.0
github.com/google/pprof v0.0.0-20240711041743-f6c9dda6c6da
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8
github.com/gorilla/mux v1.8.1
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
github.com/jaypipes/ghw v0.12.0
Expand All @@ -45,6 +45,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.109.0
github.com/otiai10/copy v1.14.0
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
github.com/rednafi/link-patrol v0.0.0-20240826150821-057643e74d4d
github.com/rs/zerolog v1.27.0
github.com/sajari/regression v1.0.1
github.com/schollz/progressbar/v3 v3.13.1
Expand All @@ -60,14 +61,14 @@ require (
go.elastic.co/go-licence-detector v0.6.1
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.109.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.26.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/crypto v0.27.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
golang.org/x/sync v0.8.0
golang.org/x/sys v0.25.0
golang.org/x/term v0.23.0
golang.org/x/text v0.17.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.23.0
golang.org/x/term v0.24.0
golang.org/x/text v0.18.0
golang.org/x/time v0.6.0
golang.org/x/tools v0.24.0
google.golang.org/grpc v1.66.2
google.golang.org/protobuf v1.34.2
gopkg.in/ini.v1 v1.67.0
Expand Down Expand Up @@ -126,8 +127,8 @@ require (
)

require (
cloud.google.com/go/auth v0.7.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/auth v0.8.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 // indirect
Expand All @@ -137,12 +138,12 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4 v4.3.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
github.com/Code-Hex/go-generics-cache v1.5.1 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.1 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/hcsshim v0.12.5 // indirect
Expand All @@ -164,6 +165,7 @@ require (
github.com/containerd/containerd v1.7.18 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
Expand Down Expand Up @@ -204,6 +206,7 @@ require (
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-resty/resty/v2 v2.13.1 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/go-zookeeper/zk v1.0.3 // indirect
github.com/gobuffalo/here v0.6.7 // indirect
github.com/gobwas/glob v0.2.3 // indirect
Expand All @@ -219,11 +222,11 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gophercloud/gophercloud v1.13.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
Expand Down Expand Up @@ -298,6 +301,8 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.20.0 // indirect
github.com/onsi/gomega v1.34.1 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/ecsutil v0.109.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.109.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.109.0 // indirect
Expand Down Expand Up @@ -348,13 +353,16 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/ua-parser/uap-go v0.0.0-20240611065828-3a4781585db6 // indirect
github.com/urfave/cli/v2 v2.27.4 // indirect
github.com/valyala/fastjson v1.6.4 // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yuin/goldmark v1.7.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.elastic.co/apm/module/apmhttp/v2 v2.6.0 // indirect
go.elastic.co/apm/module/apmzap/v2 v2.6.0 // indirect
Expand Down Expand Up @@ -417,11 +425,11 @@ require (
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/api v0.188.0 // indirect
google.golang.org/api v0.192.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
Expand Down
Loading