diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index c8921330..9e3b416d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -42,7 +42,7 @@ jobs: go generate ./... go -C _integration-tests generate -tags=integration ./... env: - GOFLAGS: -cover -covermode=atomic -coverpkg=github.com/datadog/orchestrion/...,./... + GOFLAGS: -cover -covermode=atomic -coverpkg=github.com/DataDog/orchestrion/...,./... GOCOVERDIR: ${{ github.workspace }}/coverage - name: Consolidate coverage report if: github.event_name != 'merge_group' @@ -194,7 +194,7 @@ jobs: mkdir -p coverage test_args=("-shuffle=on" "-race" "-v") if [ "${{ github.event_name }}" != "merge_group" ]; then - test_args+=("-cover" "-covermode=atomic" "-coverpkg=./...,github.com/datadog/orchestrion/..." "-coverprofile=${{ github.workspace }}/coverage/unit.out") + test_args+=("-cover" "-covermode=atomic" "-coverpkg=./...,github.com/DataDog/orchestrion/..." "-coverprofile=${{ github.workspace }}/coverage/unit.out") fi go test "${test_args[@]}" ./... - name: Run integraton suite unit tests @@ -203,7 +203,7 @@ jobs: mkdir -p coverage test_args=("-shuffle=on" "-race" "-v") if [ "${{ github.event_name }}" != "merge_group" ]; then - test_args+=("-cover" "-covermode=atomic" "-coverpkg=./...,github.com/datadog/orchestrion/..." "-coverprofile=${{ github.workspace }}/coverage/integration.out") + test_args+=("-cover" "-covermode=atomic" "-coverpkg=./...,github.com/DataDog/orchestrion/..." "-coverprofile=${{ github.workspace }}/coverage/integration.out") fi go -C _integration-tests test "${test_args[@]}" ./... - name: Determine simple go version @@ -279,7 +279,7 @@ jobs: mkdir -p "${GOCOVERDIR}" test_args=("-shuffle=on" "-v") if [ "${{ github.event_name }}" != "merge_group" ]; then - test_args+=("-coverpkg=./...,github.com/datadog/orchestrion/..." "-covermode=atomic" "-cover" "-coverprofile=${{ github.workspace }}/coverage/integration.run.out") + test_args+=("-coverpkg=./...,github.com/DataDog/orchestrion/..." "-covermode=atomic" "-cover" "-coverprofile=${{ github.workspace }}/coverage/integration.run.out") fi case "${{ matrix.build-mode }}" in diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 87906908..1790a8c9 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -6,13 +6,13 @@ orchestrion,github.com/DataDog/datadog-go/v5/statsd,MIT,"Copyright (c) 2015 Data orchestrion,github.com/DataDog/go-libddwaf/v3,Apache-2.0,"Copyright 2016-present Datadog, Inc." orchestrion,github.com/DataDog/go-sqllexer,MIT,"Copyright (c) 2023 Datadog, Inc." orchestrion,github.com/DataDog/go-tuf,BSD-3-Clause,"Copyright (c) 2014-2020 Prime Directive, Inc. All rights reserved." +orchestrion,github.com/DataDog/orchestrion,Apache-2.0,"Copyright 2023 Datadog, Inc. | Copyright [2023-Present] Datadog, Inc." orchestrion,github.com/Microsoft/go-winio,MIT,Copyright (c) 2015 Microsoft orchestrion,github.com/aymanbagabas/go-osc52/v2,MIT,Copyright (c) 2022 Ayman Bagabas orchestrion,github.com/cespare/xxhash/v2,MIT,Copyright (c) 2016 Caleb Spare orchestrion,github.com/charmbracelet/lipgloss,MIT,"Copyright (c) 2021-2023 Charmbracelet, Inc" orchestrion,github.com/charmbracelet/x/ansi,MIT,"Copyright (c) 2023 Charmbracelet, Inc." orchestrion,github.com/cpuguy83/go-md2man/v2/md2man,MIT,Copyright (c) 2014 Brian Goff -orchestrion,github.com/datadog/orchestrion,Apache-2.0,"Copyright 2023 Datadog, Inc. | Copyright [2023-Present] Datadog, Inc." orchestrion,github.com/dave/dst,MIT,Copyright (c) 2018 David Brophy | Copyright (c) 2009 The Go Authors. All rights reserved. orchestrion,github.com/dave/jennifer/jen,MIT,Copyright (c) 2017 David Brophy orchestrion,github.com/dlclark/regexp2,MIT,unknown diff --git a/README.md b/README.md index c003f9ca..02ff2abc 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ In addition to this, Orchestrion only supports projects using [Go modules][go-mo 1. Install Orchestrion: ```console - $ go install github.com/datadog/orchestrion@latest + $ go install github.com/DataDog/orchestrion@latest ``` 2.
Optional: project go.mod registration @@ -61,9 +61,9 @@ In addition to this, Orchestrion only supports projects using [Go modules][go-mo > > package tools > - > import _ "github.com/datadog/orchestrion" + > import _ "github.com/DataDog/orchestrion" > ``` - > 2. Run `go get github.com/datadog/orchstrion@` to make sure the project version corresponds to the + > 2. Run `go get github.com/DataDog/orchstrion@` to make sure the project version corresponds to the > one currently being used > 3. Run `go mod tidy` to make sure your `go.mod` and `go.sum` files are up-to-date > @@ -82,13 +82,13 @@ In addition to this, Orchestrion only supports projects using [Go modules][go-mo ``` ╭──────────────────────────────────────────────────────────────────────────────╮ │ │ - │ Warning: github.com/datadog/orchestrion is not present in your go.mod │ + │ Warning: github.com/DataDog/orchestrion is not present in your go.mod │ │ file. │ │ In order to ensure build reliability and reproductibility, orchestrion │ │ will now add itself in your go.mod file by: │ │ │ │ 1. creating a new file named orchestrion.tool.go │ - │ 2. running go get github.com/datadog/orchestrion@v0.7.0-dev.2 │ + │ 2. running go get github.com/DataDog/orchestrion@v0.7.0-dev.2 │ │ 3. running go mod tidy │ │ │ │ You should commit the resulting changes into your source control system. │ @@ -110,7 +110,7 @@ In addition to this, Orchestrion only supports projects using [Go modules][go-mo > The version of `orchestrion` used to compile your project is ultimately tracked in the `go.mod` file. You can manage > it in the same way you manage any other dependency, and updating to the latest release is as simple as doing: > ```console -> $ go get github.com/datadog/orchestrion@latest +> $ go get github.com/DataDog/orchestrion@latest > ``` ## Supported libraries diff --git a/_integration-tests/go.mod b/_integration-tests/go.mod index daf6a347..faca8fca 100644 --- a/_integration-tests/go.mod +++ b/_integration-tests/go.mod @@ -2,10 +2,11 @@ module orchestrion/integration go 1.22.6 -replace github.com/datadog/orchestrion => ../ +replace github.com/DataDog/orchestrion => ../ require ( cloud.google.com/go/pubsub v1.42.0 + github.com/DataDog/orchestrion v0.7.4 github.com/IBM/sarama v1.43.3 github.com/Shopify/sarama v1.38.1 github.com/aws/aws-sdk-go v1.55.5 @@ -13,7 +14,6 @@ require ( github.com/aws/aws-sdk-go-v2/config v1.27.30 github.com/aws/aws-sdk-go-v2/credentials v1.17.29 github.com/aws/aws-sdk-go-v2/service/dynamodb v1.34.6 - github.com/datadog/orchestrion v0.7.4 github.com/dave/jennifer v1.7.0 github.com/docker/go-connections v0.5.0 github.com/gin-gonic/gin v1.10.0 @@ -43,7 +43,7 @@ require ( google.golang.org/api v0.194.0 google.golang.org/grpc v1.65.0 google.golang.org/grpc/examples v0.0.0-20240816220358-f8d98a477c22 - gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2 + gopkg.in/DataDog/dd-trace-go.v1 v1.68.0 gorm.io/driver/sqlite v1.5.6 gorm.io/gorm v1.25.11 gotest.tools/v3 v3.5.1 diff --git a/_integration-tests/go.sum b/_integration-tests/go.sum index 3d987f51..65c37544 100644 --- a/_integration-tests/go.sum +++ b/_integration-tests/go.sum @@ -2376,8 +2376,8 @@ google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2 h1:EVPVNIE/pORPQ8i1lS1IzrvA9rWw3ZPoKAATqkLlAqE= -gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2/go.mod h1:mkZpWVLO/ERW5NqlW+w5d8waQKNvMSTUQLJfoI0vlvw= +gopkg.in/DataDog/dd-trace-go.v1 v1.68.0 h1:8WPoOHJcMAtcxTVKM0DYnFweBjxxfNit3Sjo/rf+Hkw= +gopkg.in/DataDog/dd-trace-go.v1 v1.68.0/go.mod h1:mkZpWVLO/ERW5NqlW+w5d8waQKNvMSTUQLJfoI0vlvw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/_integration-tests/tools.go b/_integration-tests/tools.go index a3c10e52..117fe9e8 100644 --- a/_integration-tests/tools.go +++ b/_integration-tests/tools.go @@ -8,5 +8,5 @@ package tools import ( - _ "github.com/datadog/orchestrion" + _ "github.com/DataDog/orchestrion" ) diff --git a/_integration-tests/utils/agent/requirements.txt b/_integration-tests/utils/agent/requirements.txt index c30e42ed..91be3473 100644 --- a/_integration-tests/utils/agent/requirements.txt +++ b/_integration-tests/utils/agent/requirements.txt @@ -11,7 +11,7 @@ frozenlist==1.4.1 idna==3.10 msgpack==1.1.0 multidict==6.1.0 -protobuf==5.28.1 +protobuf==5.28.2 requests==2.32.3 six==1.16.0 typing_extensions==4.12.2 diff --git a/_integration-tests/utils/testcontainers.go b/_integration-tests/utils/testcontainers.go index fdcabdc8..6d5b3c7f 100644 --- a/_integration-tests/utils/testcontainers.go +++ b/_integration-tests/utils/testcontainers.go @@ -26,7 +26,6 @@ func StartDynamoDBTestContainer(t *testing.T) (testcontainers.Container, string, Image: "amazon/dynamodb-local:latest", ExposedPorts: []string{exposedPort}, WaitingFor: wait.ForHTTP("").WithStatusCodeMatcher(func(int) bool { return true }), - Name: "dynamodb-local", WorkingDir: "/home/dynamodblocal", Cmd: []string{ "-jar", "DynamoDBLocal.jar", diff --git a/docs/content/docs/getting-started.md b/docs/content/docs/getting-started.md index b1ee62c3..1695e72d 100644 --- a/docs/content/docs/getting-started.md +++ b/docs/content/docs/getting-started.md @@ -32,7 +32,7 @@ This is achieved using the following steps: ### Step 1 Install Orchestrion in your environment: ```console -$ go install github.com/datadog/orchestrion@latest +$ go install github.com/DataDog/orchestrion@latest ``` If necessary, also add the `GOBIN` directory to your `PATH`: diff --git a/go.mod b/go.mod index c7a9dc95..98850a17 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/datadog/orchestrion +module github.com/DataDog/orchestrion go 1.22.6 @@ -19,10 +19,11 @@ require ( github.com/shirou/gopsutil/v3 v3.24.5 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.27.4 + golang.org/x/mod v0.20.0 golang.org/x/sys v0.24.0 golang.org/x/term v0.23.0 golang.org/x/tools v0.24.0 - gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2 + gopkg.in/DataDog/dd-trace-go.v1 v1.68.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.5.1 k8s.io/client-go v0.31.0 @@ -283,7 +284,6 @@ require ( golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect golang.org/x/image v0.19.0 // indirect - golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sync v0.8.0 // indirect diff --git a/go.sum b/go.sum index 7c183fd9..8fbb00da 100644 --- a/go.sum +++ b/go.sum @@ -1268,8 +1268,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2 h1:EVPVNIE/pORPQ8i1lS1IzrvA9rWw3ZPoKAATqkLlAqE= -gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2/go.mod h1:mkZpWVLO/ERW5NqlW+w5d8waQKNvMSTUQLJfoI0vlvw= +gopkg.in/DataDog/dd-trace-go.v1 v1.68.0 h1:8WPoOHJcMAtcxTVKM0DYnFweBjxxfNit3Sjo/rf+Hkw= +gopkg.in/DataDog/dd-trace-go.v1 v1.68.0/go.mod h1:mkZpWVLO/ERW5NqlW+w5d8waQKNvMSTUQLJfoI0vlvw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/instrument/instrument.go b/instrument/instrument.go index 8f7b1260..e96e8b7f 100644 --- a/instrument/instrument.go +++ b/instrument/instrument.go @@ -9,7 +9,7 @@ import ( "context" "fmt" - "github.com/datadog/orchestrion/instrument/event" + "github.com/DataDog/orchestrion/instrument/event" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) diff --git a/instrument/instrument_test.go b/instrument/instrument_test.go index c3c34d04..a650d1d2 100644 --- a/instrument/instrument_test.go +++ b/instrument/instrument_test.go @@ -9,7 +9,7 @@ import ( "context" "testing" - "github.com/datadog/orchestrion/instrument/event" + "github.com/DataDog/orchestrion/instrument/event" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) diff --git a/internal/cmd/go.go b/internal/cmd/go.go index d3246d79..f64eb839 100644 --- a/internal/cmd/go.go +++ b/internal/cmd/go.go @@ -9,8 +9,8 @@ import ( "errors" "os/exec" - "github.com/datadog/orchestrion/internal/goproxy" - "github.com/datadog/orchestrion/internal/pin" + "github.com/DataDog/orchestrion/internal/goproxy" + "github.com/DataDog/orchestrion/internal/pin" "github.com/urfave/cli/v2" ) diff --git a/internal/cmd/pin.go b/internal/cmd/pin.go index 70d3a94c..d819677c 100644 --- a/internal/cmd/pin.go +++ b/internal/cmd/pin.go @@ -6,7 +6,7 @@ package cmd import ( - "github.com/datadog/orchestrion/internal/pin" + "github.com/DataDog/orchestrion/internal/pin" "github.com/urfave/cli/v2" ) diff --git a/internal/cmd/server.go b/internal/cmd/server.go index ad682da0..78461d82 100644 --- a/internal/cmd/server.go +++ b/internal/cmd/server.go @@ -12,10 +12,10 @@ import ( "os/signal" "time" - "github.com/datadog/orchestrion/internal/filelock" - "github.com/datadog/orchestrion/internal/jobserver" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/filelock" + "github.com/DataDog/orchestrion/internal/jobserver" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/log" "github.com/fsnotify/fsnotify" "github.com/urfave/cli/v2" @@ -49,7 +49,7 @@ var Server = &cli.Command{ Hidden: true, Action: func(c *cli.Context) error { opts := jobserver.Options{ - ServerName: "github.com/datadog/orchestrion server", + ServerName: "github.com/DataDog/orchestrion server", Port: c.Int("port"), InactivityTimeout: c.Duration("inactivity-timeout"), EnableLogging: c.Bool("nats-logging"), diff --git a/internal/cmd/toolexec.go b/internal/cmd/toolexec.go index 574533b4..ed206c7a 100644 --- a/internal/cmd/toolexec.go +++ b/internal/cmd/toolexec.go @@ -9,11 +9,11 @@ import ( "fmt" "os" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/pin" - "github.com/datadog/orchestrion/internal/toolexec" - "github.com/datadog/orchestrion/internal/toolexec/aspect" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/pin" + "github.com/DataDog/orchestrion/internal/toolexec" + "github.com/DataDog/orchestrion/internal/toolexec/aspect" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" "github.com/urfave/cli/v2" ) @@ -63,7 +63,7 @@ var Toolexec = &cli.Command{ return err } - log.Tracef("Toolexec final command: %q/n", proxyCmd.Args()) + log.Tracef("Toolexec final command: %q\n", proxyCmd.Args()) return proxy.RunCommand(proxyCmd) }, } diff --git a/internal/cmd/version.go b/internal/cmd/version.go index 133f6fa5..728a5cda 100644 --- a/internal/cmd/version.go +++ b/internal/cmd/version.go @@ -9,8 +9,8 @@ import ( "fmt" "runtime" - "github.com/datadog/orchestrion/internal/ensure" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/ensure" + "github.com/DataDog/orchestrion/internal/version" "github.com/urfave/cli/v2" ) diff --git a/internal/cmd/version_test.go b/internal/cmd/version_test.go index 0246ba1b..752bc344 100644 --- a/internal/cmd/version_test.go +++ b/internal/cmd/version_test.go @@ -12,8 +12,8 @@ import ( "runtime" "testing" - "github.com/datadog/orchestrion/internal/cmd" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/cmd" + "github.com/DataDog/orchestrion/internal/version" "github.com/stretchr/testify/require" "github.com/urfave/cli/v2" ) diff --git a/internal/ensure/integration/main.go b/internal/ensure/integration/main.go index 424cd589..b14b1478 100644 --- a/internal/ensure/integration/main.go +++ b/internal/ensure/integration/main.go @@ -9,7 +9,7 @@ import ( "fmt" "log" - "github.com/datadog/orchestrion/internal/ensure" + "github.com/DataDog/orchestrion/internal/ensure" ) // main is the entry point of a command that is used by the `ensure` integration diff --git a/internal/ensure/integration_test.go b/internal/ensure/integration_test.go index 74e40905..67d7a79c 100644 --- a/internal/ensure/integration_test.go +++ b/internal/ensure/integration_test.go @@ -15,7 +15,9 @@ import ( "strings" "testing" + "github.com/DataDog/orchestrion/internal/version" "github.com/stretchr/testify/require" + "golang.org/x/mod/semver" ) var ensureDir string @@ -47,11 +49,17 @@ func Test(t *testing.T) { fails bool } for name, test := range map[string]test{ - "v0.6.0": {version: "v0.6.0", output: "v0.6.0"}, - "replaced": {version: "v0.6.0", replaces: true, output: "This command has not respawned!"}, + "v0.9.0": {version: "v0.9.0", output: "v0.9.0"}, + "replaced": {version: "v0.9.0", replaces: true, output: "This command has not respawned!"}, "none": {fails: true}, } { t.Run(name, func(t *testing.T) { + if !test.replaces && semver.Compare(test.version, version.Tag) >= 0 { + // Tests w/o replace can't run if the "happy" version has not been released yet. v0.9.0 includes a module path + // re-capitalization which forces us to skip temporarily at least until that is released. + t.Skipf("Skipping test because version %s is newer than the current version (%s)", test.version, version.Tag) + } + wd := filepath.Join(tmp, name) require.NoError(t, os.Mkdir(wd, 0750), "failed to create test working directory") @@ -63,7 +71,7 @@ func Test(t *testing.T) { } if test.version != "" { - goMod = append(goMod, fmt.Sprintf("require github.com/datadog/orchestrion %s", test.version), "") + goMod = append(goMod, fmt.Sprintf("require github.com/DataDog/orchestrion %s", test.version), "") // So that "go mod tidy" does not remove the requirement... require.NoError(t, @@ -71,13 +79,13 @@ func Test(t *testing.T) { "//go:build tools", "package tools", "", - "import _ \"github.com/datadog/orchestrion\"", + "import _ \"github.com/DataDog/orchestrion\"", }, "\n")), 0o644), "failed to write tools.go", ) } if test.replaces { - goMod = append(goMod, fmt.Sprintf("replace github.com/datadog/orchestrion => %s", filepath.Dir(filepath.Dir(ensureDir))), "") + goMod = append(goMod, fmt.Sprintf("replace github.com/DataDog/orchestrion => %s", filepath.Dir(filepath.Dir(ensureDir))), "") } require.NoError(t, diff --git a/internal/ensure/requiredversion.go b/internal/ensure/requiredversion.go index 61724150..8d07af3b 100644 --- a/internal/ensure/requiredversion.go +++ b/internal/ensure/requiredversion.go @@ -14,13 +14,13 @@ import ( "runtime" "syscall" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/version" "golang.org/x/tools/go/packages" ) const ( - orchestrionPkgPath = "github.com/datadog/orchestrion" + orchestrionPkgPath = "github.com/DataDog/orchestrion" envVarRespawnedFor = "DD_ORCHESTRION_RESPAWNED_FOR" envVarStartupVersion = "DD_ORCHESTRION_STARTUP_VERSION" envValRespawnReplaced = "" @@ -123,7 +123,7 @@ func requiredVersion( return syscallExec(goBin, args, env) } -// goModVersion returns the version and path of the "github.com/datadog/orchestrion" module that is +// goModVersion returns the version and path of the "github.com/DataDog/orchestrion" module that is // required in the specified directory's "go.mod" file. If dir is blank, the process' current // working directory is used. The version may be blank if a replace directive is in effect; in which // case the path value may indicate the location of the source code that is being used instead. diff --git a/internal/ensure/requiredversion_test.go b/internal/ensure/requiredversion_test.go index 8b6b8b2a..53815334 100644 --- a/internal/ensure/requiredversion_test.go +++ b/internal/ensure/requiredversion_test.go @@ -16,9 +16,10 @@ import ( "sync/atomic" "testing" - "github.com/datadog/orchestrion/internal/goenv" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/goenv" + "github.com/DataDog/orchestrion/internal/version" "github.com/stretchr/testify/require" + "golang.org/x/mod/semver" ) func TestGoModVersion(t *testing.T) { @@ -28,11 +29,17 @@ func TestGoModVersion(t *testing.T) { err error } for name, test := range map[string]test{ - "happy": {version: "v0.6.0"}, - "replaced": {version: "v0.6.0", replace: true}, + "happy": {version: "v0.9.0"}, + "replaced": {version: "v0.9.0", replace: true}, "missing": {err: fmt.Errorf("no required module provides package %s", orchestrionPkgPath)}, } { t.Run(name, func(t *testing.T) { + if !test.replace && test.version != "" && semver.Compare(test.version, version.Tag) >= 0 { + // Tests w/o replace can't run if the "happy" version has not been released yet. v0.9.0 includes a module path + // re-capitalization which forces us to skip temporarily at least until that is released. + t.Skipf("Skipping test because version %s is newer than the current version (%s)", test.version, version.Tag) + } + tmp, err := os.MkdirTemp("", "ensure-*") require.NoError(t, err, "failed to create temporary directory") defer os.RemoveAll(tmp) @@ -59,7 +66,7 @@ func TestGoModVersion(t *testing.T) { child := exec.Command("go", "mod", "tidy") child.Dir = tmp child.Stderr = os.Stderr - require.NoError(t, child.Run(), "error while running 'go mod download'") + require.NoError(t, child.Run(), "error while running 'go mod tidy'") rVersion, rDir, err := goModVersion(tmp) if test.err != nil { diff --git a/internal/filelock/filelock_test.go b/internal/filelock/filelock_test.go index 4a08ce3b..dc57ecd8 100644 --- a/internal/filelock/filelock_test.go +++ b/internal/filelock/filelock_test.go @@ -10,7 +10,7 @@ import ( "path/filepath" "testing" - "github.com/datadog/orchestrion/internal/filelock" + "github.com/DataDog/orchestrion/internal/filelock" "github.com/stretchr/testify/require" ) diff --git a/internal/goflags/flags.go b/internal/goflags/flags.go index 7aa33e8a..991d702c 100644 --- a/internal/goflags/flags.go +++ b/internal/goflags/flags.go @@ -15,9 +15,9 @@ import ( "strings" "sync" - "github.com/datadog/orchestrion/internal/goenv" - "github.com/datadog/orchestrion/internal/goflags/quoted" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/goenv" + "github.com/DataDog/orchestrion/internal/goflags/quoted" + "github.com/DataDog/orchestrion/internal/log" "github.com/shirou/gopsutil/v3/process" "golang.org/x/tools/go/packages" ) diff --git a/internal/goflags/flags_test.go b/internal/goflags/flags_test.go index b8c1975f..204d7e7c 100644 --- a/internal/goflags/flags_test.go +++ b/internal/goflags/flags_test.go @@ -93,7 +93,7 @@ func TestParse(t *testing.T) { "cover": { flags: []string{"run", "-cover", "-covermode=atomic"}, expected: CommandFlags{ - Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/datadog/orchestrion/internal/goflags"}, + Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/DataDog/orchestrion/internal/goflags"}, Short: map[string]struct{}{"-cover": {}}, }, }, @@ -109,7 +109,7 @@ func TestParse(t *testing.T) { flags: []string{"-C", "..", "run", "-cover", "-covermode=atomic"}, expected: CommandFlags{ // Note - the "-C" flags has no effect at this stage, so it's expected coverpkg is this package. - Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/datadog/orchestrion/internal/goflags"}, + Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/DataDog/orchestrion/internal/goflags"}, Short: map[string]struct{}{"-cover": {}}, }, }, @@ -117,7 +117,7 @@ func TestParse(t *testing.T) { flags: []string{"-C=..", "run", "-cover", "-covermode=atomic", "."}, expected: CommandFlags{ // Note - the "-C" flags has no effect at this stage, so it's expected coverpkg is this package. - Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/datadog/orchestrion/internal/goflags"}, + Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/DataDog/orchestrion/internal/goflags"}, Short: map[string]struct{}{"-cover": {}}, }, }, @@ -125,7 +125,7 @@ func TestParse(t *testing.T) { flags: []string{"run", "."}, goflags: "-cover -covermode=atomic -tags=integration '-toolexec=foo bar'", expected: CommandFlags{ - Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/datadog/orchestrion/internal/goflags", "-tags": "integration", "-toolexec": "foo bar"}, + Long: map[string]string{"-covermode": "atomic", "-coverpkg": "github.com/DataDog/orchestrion/internal/goflags", "-tags": "integration", "-toolexec": "foo bar"}, Short: map[string]struct{}{"-cover": {}}, }, }, diff --git a/internal/goproxy/dashc.go b/internal/goproxy/dashc.go index 7bed8b87..46d255e1 100644 --- a/internal/goproxy/dashc.go +++ b/internal/goproxy/dashc.go @@ -9,7 +9,7 @@ import ( "os" "strings" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/log" ) // ProcessDashC gets the command line arguments passed to a "go" command (without "go" itself), and processes the "-C" diff --git a/internal/goproxy/proxy.go b/internal/goproxy/proxy.go index c2b2fe63..5f520efa 100644 --- a/internal/goproxy/proxy.go +++ b/internal/goproxy/proxy.go @@ -11,11 +11,11 @@ import ( "os/exec" "strings" - "github.com/datadog/orchestrion/internal/goenv" - "github.com/datadog/orchestrion/internal/goflags" - "github.com/datadog/orchestrion/internal/jobserver" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/goenv" + "github.com/DataDog/orchestrion/internal/goflags" + "github.com/DataDog/orchestrion/internal/jobserver" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/log" ) type config struct { diff --git a/internal/injector/aspect/advice/advice.go b/internal/injector/aspect/advice/advice.go index 0d6cbb15..c2a6694d 100644 --- a/internal/injector/aspect/advice/advice.go +++ b/internal/injector/aspect/advice/advice.go @@ -8,11 +8,11 @@ package advice import ( - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/code" ) -const pkgPath = "github.com/datadog/orchestrion/internal/injector/aspect/advice" +const pkgPath = "github.com/DataDog/orchestrion/internal/injector/aspect/advice" // Advice is the interface abstracting actual AST changes performed by // injections. diff --git a/internal/injector/aspect/advice/assign.go b/internal/injector/aspect/advice/assign.go index 75f8bc09..621a4362 100644 --- a/internal/injector/aspect/advice/assign.go +++ b/internal/injector/aspect/advice/assign.go @@ -8,8 +8,8 @@ package advice import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/advice/block.go b/internal/injector/aspect/advice/block.go index dd6a6cb6..df46f57f 100644 --- a/internal/injector/aspect/advice/block.go +++ b/internal/injector/aspect/advice/block.go @@ -8,8 +8,8 @@ package advice import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/advice/call.go b/internal/injector/aspect/advice/call.go index c54bb3e9..17da525a 100644 --- a/internal/injector/aspect/advice/call.go +++ b/internal/injector/aspect/advice/call.go @@ -10,9 +10,9 @@ import ( "regexp" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/aspect/join" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/join" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/advice/code/dot.go b/internal/injector/aspect/advice/code/dot.go index 686d092b..ede35b9e 100644 --- a/internal/injector/aspect/advice/code/dot.go +++ b/internal/injector/aspect/advice/code/dot.go @@ -8,7 +8,7 @@ package code import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/dst/dstutil" ) diff --git a/internal/injector/aspect/advice/code/dot_ast.proxies.go b/internal/injector/aspect/advice/code/dot_ast.proxies.go index 321dfd98..6a65abfe 100644 --- a/internal/injector/aspect/advice/code/dot_ast.proxies.go +++ b/internal/injector/aspect/advice/code/dot_ast.proxies.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2023-present Datadog, Inc. // -// Code generated by "github.com/datadog/orchestrion/internal/advice/code/generator -o dot_ast.proxies.go"; DO NOT EDIT. +// Code generated by "github.com/DataDog/orchestrion/internal/advice/code/generator -o dot_ast.proxies.go"; DO NOT EDIT. package code diff --git a/internal/injector/aspect/advice/code/dot_directive.go b/internal/injector/aspect/advice/code/dot_directive.go index d8b0b5e9..146eeaf8 100644 --- a/internal/injector/aspect/advice/code/dot_directive.go +++ b/internal/injector/aspect/advice/code/dot_directive.go @@ -10,7 +10,7 @@ import ( "regexp" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" ) // DirectiveArgument represents arguments provided to directives (`// `), where diff --git a/internal/injector/aspect/advice/code/dot_function.go b/internal/injector/aspect/advice/code/dot_function.go index c27b97a5..c0ba1369 100644 --- a/internal/injector/aspect/advice/code/dot_function.go +++ b/internal/injector/aspect/advice/code/dot_function.go @@ -9,8 +9,8 @@ import ( "errors" "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/aspect/join" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/join" "github.com/dave/dst" ) diff --git a/internal/injector/aspect/advice/code/generator/main.go b/internal/injector/aspect/advice/code/generator/main.go index ac1d5ecb..27ce5e81 100644 --- a/internal/injector/aspect/advice/code/generator/main.go +++ b/internal/injector/aspect/advice/code/generator/main.go @@ -36,7 +36,7 @@ func main() { file.HeaderComment("This product includes software developed at Datadog (https://www.datadoghq.com/).") file.HeaderComment("Copyright 2023-present Datadog, Inc.") file.HeaderComment("") - file.HeaderComment(fmt.Sprintf("Code generated by %q; DO NOT EDIT.", "github.com/datadog/orchestrion/internal/advice/code/generator "+strings.Join(os.Args[1:], " "))) + file.HeaderComment(fmt.Sprintf("Code generated by %q; DO NOT EDIT.", "github.com/DataDog/orchestrion/internal/advice/code/generator "+strings.Join(os.Args[1:], " "))) proxyCases := make([]jen.Code, 0, scope.Len()) for _, name := range scope.Names() { diff --git a/internal/injector/aspect/advice/code/template.go b/internal/injector/aspect/advice/code/template.go index 212c6b2c..3c4fcb89 100644 --- a/internal/injector/aspect/advice/code/template.go +++ b/internal/injector/aspect/advice/code/template.go @@ -16,8 +16,8 @@ import ( "strings" "text/template" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/version" "github.com/dave/dst" "github.com/dave/dst/dstutil" "github.com/dave/jennifer/jen" @@ -192,7 +192,7 @@ func (t *Template) processImports(ctx context.AdviceContext, node dst.Decl) dst. } func (t *Template) AsCode() jen.Code { - return jen.Qual("github.com/datadog/orchestrion/internal/injector/aspect/advice/code", "MustTemplate").Call( + return jen.Qual("github.com/DataDog/orchestrion/internal/injector/aspect/advice/code", "MustTemplate").Call( jen.Line().Lit(t.source), jen.Line().Map(jen.String()).String().ValuesFunc(func(g *jen.Group) { // We sort the keys so the generated code order is consistent... diff --git a/internal/injector/aspect/advice/code/template_test.go b/internal/injector/aspect/advice/code/template_test.go index c2fd5080..3fe84b6d 100644 --- a/internal/injector/aspect/advice/code/template_test.go +++ b/internal/injector/aspect/advice/code/template_test.go @@ -9,8 +9,8 @@ import ( "errors" "testing" - "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/dst/decorator" "github.com/stretchr/testify/require" diff --git a/internal/injector/aspect/advice/import.go b/internal/injector/aspect/advice/import.go index f558e558..8ef23b0e 100644 --- a/internal/injector/aspect/advice/import.go +++ b/internal/injector/aspect/advice/import.go @@ -10,7 +10,7 @@ package advice import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/advice/inject.go b/internal/injector/aspect/advice/inject.go index 22665fb4..955d264b 100644 --- a/internal/injector/aspect/advice/inject.go +++ b/internal/injector/aspect/advice/inject.go @@ -10,8 +10,8 @@ import ( "sort" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/advice/struct.go b/internal/injector/aspect/advice/struct.go index ac10d008..ebbd1649 100644 --- a/internal/injector/aspect/advice/struct.go +++ b/internal/injector/aspect/advice/struct.go @@ -8,8 +8,8 @@ package advice import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/aspect/join" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/join" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/advice/unmarshal.go b/internal/injector/aspect/advice/unmarshal.go index 42c40d73..eb7ee6cc 100644 --- a/internal/injector/aspect/advice/unmarshal.go +++ b/internal/injector/aspect/advice/unmarshal.go @@ -8,7 +8,7 @@ package advice import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/singleton" + "github.com/DataDog/orchestrion/internal/injector/singleton" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/advice/wrap.go b/internal/injector/aspect/advice/wrap.go index 2156c9ba..ad075656 100644 --- a/internal/injector/aspect/advice/wrap.go +++ b/internal/injector/aspect/advice/wrap.go @@ -8,8 +8,8 @@ package advice import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/aspect.go b/internal/injector/aspect/aspect.go index 1474fe60..19f138b2 100644 --- a/internal/injector/aspect/aspect.go +++ b/internal/injector/aspect/aspect.go @@ -8,8 +8,8 @@ package aspect import ( "errors" - "github.com/datadog/orchestrion/internal/injector/aspect/advice" - "github.com/datadog/orchestrion/internal/injector/aspect/join" + "github.com/DataDog/orchestrion/internal/injector/aspect/advice" + "github.com/DataDog/orchestrion/internal/injector/aspect/join" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) @@ -27,7 +27,7 @@ type Aspect struct { func (a *Aspect) AsCode() (jp jen.Code, adv jen.Code) { jp = a.JoinPoint.AsCode() - adv = jen.Index().Qual("github.com/datadog/orchestrion/internal/injector/aspect/advice", "Advice").ValuesFunc(func(g *jen.Group) { + adv = jen.Index().Qual("github.com/DataDog/orchestrion/internal/injector/aspect/advice", "Advice").ValuesFunc(func(g *jen.Group) { for _, a := range a.Advice { g.Line().Add(a.AsCode()) } diff --git a/internal/injector/aspect/context/context.go b/internal/injector/aspect/context/context.go index dde1ea70..d43cc128 100644 --- a/internal/injector/aspect/context/context.go +++ b/internal/injector/aspect/context/context.go @@ -6,7 +6,7 @@ package context import ( - "github.com/datadog/orchestrion/internal/injector/typed" + "github.com/DataDog/orchestrion/internal/injector/typed" "github.com/dave/dst" "github.com/dave/dst/dstutil" ) diff --git a/internal/injector/aspect/join/all-of.go b/internal/injector/aspect/join/all-of.go index d930ff2f..9511462a 100644 --- a/internal/injector/aspect/join/all-of.go +++ b/internal/injector/aspect/join/all-of.go @@ -8,7 +8,7 @@ package join import ( "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/join/configuration.go b/internal/injector/aspect/join/configuration.go index 9a217fc2..c8ad268e 100644 --- a/internal/injector/aspect/join/configuration.go +++ b/internal/injector/aspect/join/configuration.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/join/declaration.go b/internal/injector/aspect/join/declaration.go index b6ebb42f..0191c212 100644 --- a/internal/injector/aspect/join/declaration.go +++ b/internal/injector/aspect/join/declaration.go @@ -8,7 +8,7 @@ package join import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/join/directive.go b/internal/injector/aspect/join/directive.go index 0eb8eaa2..a095b23b 100644 --- a/internal/injector/aspect/join/directive.go +++ b/internal/injector/aspect/join/directive.go @@ -11,7 +11,7 @@ import ( "unicode" "unicode/utf8" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/join/expression.go b/internal/injector/aspect/join/expression.go index 70bc4858..80f6d0da 100644 --- a/internal/injector/aspect/join/expression.go +++ b/internal/injector/aspect/join/expression.go @@ -9,7 +9,7 @@ import ( "fmt" "regexp" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/join/function.go b/internal/injector/aspect/join/function.go index a4381932..d27c0af1 100644 --- a/internal/injector/aspect/join/function.go +++ b/internal/injector/aspect/join/function.go @@ -9,8 +9,8 @@ import ( "fmt" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/code" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/join/join.go b/internal/injector/aspect/join/join.go index a8555d0d..c8c1bd94 100644 --- a/internal/injector/aspect/join/join.go +++ b/internal/injector/aspect/join/join.go @@ -12,13 +12,13 @@ import ( "fmt" "regexp" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/code" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/code" "github.com/dave/dst" "github.com/dave/jennifer/jen" ) -const pkgPath = "github.com/datadog/orchestrion/internal/injector/aspect/join" +const pkgPath = "github.com/DataDog/orchestrion/internal/injector/aspect/join" // Point is the interface that abstracts selection of nodes where to inject // code. diff --git a/internal/injector/aspect/join/not.go b/internal/injector/aspect/join/not.go index 8364648e..cb801ec2 100644 --- a/internal/injector/aspect/join/not.go +++ b/internal/injector/aspect/join/not.go @@ -8,7 +8,7 @@ package join import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/join/one-of.go b/internal/injector/aspect/join/one-of.go index 747fd842..2b95eee8 100644 --- a/internal/injector/aspect/join/one-of.go +++ b/internal/injector/aspect/join/one-of.go @@ -9,7 +9,7 @@ import ( "fmt" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/join/package.go b/internal/injector/aspect/join/package.go index 3a8296a1..c71d0663 100644 --- a/internal/injector/aspect/join/package.go +++ b/internal/injector/aspect/join/package.go @@ -8,7 +8,7 @@ package join import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/aspect/join/struct.go b/internal/injector/aspect/join/struct.go index 3fd5a368..118d0d9a 100644 --- a/internal/injector/aspect/join/struct.go +++ b/internal/injector/aspect/join/struct.go @@ -10,7 +10,7 @@ import ( "go/token" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" "github.com/dave/dst" "github.com/dave/jennifer/jen" "gopkg.in/yaml.v3" diff --git a/internal/injector/aspect/join/unmarshal.go b/internal/injector/aspect/join/unmarshal.go index 2c15d4ed..79ed64b1 100644 --- a/internal/injector/aspect/join/unmarshal.go +++ b/internal/injector/aspect/join/unmarshal.go @@ -8,7 +8,7 @@ package join import ( "fmt" - "github.com/datadog/orchestrion/internal/injector/singleton" + "github.com/DataDog/orchestrion/internal/injector/singleton" "gopkg.in/yaml.v3" ) diff --git a/internal/injector/builtin/generated.go b/internal/injector/builtin/generated.go index e2876755..6aca04b2 100644 --- a/internal/injector/builtin/generated.go +++ b/internal/injector/builtin/generated.go @@ -3,15 +3,15 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2023-present Datadog, Inc. // -// Code generated by "github.com/datadog/orchestion/internal/injector/builtin/generator -i=yaml/*.yml -i=yaml/*/*.yml -p=builtin -o=./generated.go -d=./generated_deps.go -C=1 -docs=../../../docs/content/docs/built-in/ -schemadocs=../../../docs/content/contributing/aspects/"; DO NOT EDIT. +// Code generated by "github.com/DataDog/orchestion/internal/injector/builtin/generator -i=yaml/*.yml -i=yaml/*/*.yml -p=builtin -o=./generated.go -d=./generated_deps.go -C=1 -docs=../../../docs/content/docs/built-in/ -schemadocs=../../../docs/content/contributing/aspects/"; DO NOT EDIT. package builtin import ( - aspect "github.com/datadog/orchestrion/internal/injector/aspect" - advice "github.com/datadog/orchestrion/internal/injector/aspect/advice" - code "github.com/datadog/orchestrion/internal/injector/aspect/advice/code" - join "github.com/datadog/orchestrion/internal/injector/aspect/join" + aspect "github.com/DataDog/orchestrion/internal/injector/aspect" + advice "github.com/DataDog/orchestrion/internal/injector/aspect/advice" + code "github.com/DataDog/orchestrion/internal/injector/aspect/advice/code" + join "github.com/DataDog/orchestrion/internal/injector/aspect/join" ) // Aspects is the list of built-in aspects. @@ -691,7 +691,7 @@ var Aspects = [...]aspect.Aspect{ advice.WrapExpression(code.MustTemplate( "{{- $ctx := .Function.ArgumentOfType \"context.Context\" -}}\n{{- $req := .Function.ArgumentOfType \"*net/http.Request\" }}\n{{- if $ctx -}}\n instrument.{{ .AST.Fun.Name }}(\n {{ $ctx }},\n {{ range .AST.Args }}{{ . }},\n {{ end }}\n )\n{{- else if $req -}}\n instrument.{{ .AST.Fun.Name }}(\n {{ $req }}.Context(),\n {{ range .AST.Args }}{{ . }},\n {{ end }}\n )\n{{- else -}}\n {{ . }}\n{{- end -}}", map[string]string{ - "instrument": "github.com/datadog/orchestrion/instrument/net/http", + "instrument": "github.com/DataDog/orchestrion/instrument/net/http", }, )), }, @@ -713,7 +713,7 @@ var Aspects = [...]aspect.Aspect{ advice.WrapExpression(code.MustTemplate( "//dd:startwrap\ninstrument.WrapHandler({{.}})\n//dd:endwrap", map[string]string{ - "instrument": "github.com/datadog/orchestrion/instrument", + "instrument": "github.com/DataDog/orchestrion/instrument", }, )), }, @@ -740,7 +740,7 @@ var Aspects = [...]aspect.Aspect{ advice.WrapExpression(code.MustTemplate( "instrument.WrapHandlerFunc({{.}})", map[string]string{ - "instrument": "github.com/datadog/orchestrion/instrument", + "instrument": "github.com/DataDog/orchestrion/instrument", }, )), }, @@ -766,8 +766,8 @@ var Aspects = [...]aspect.Aspect{ advice.PrependStmts(code.MustTemplate( "{{- $arg := .Function.Argument 1 -}}\n{{- $name := .Function.Name -}}\n{{$arg}} = {{$arg}}.WithContext(instrument.Report(\n {{$arg}}.Context(),\n event.EventStart,\n {{with $name}}\"function-name\", {{printf \"%q\" .}},{{end}}\n \"span.kind\", \"server\",\n \"http.method\", {{$arg}}.Method,\n \"http.url\", {{$arg}}.URL,\n \"http.useragent\", {{$arg}}.Header.Get(\"User-Agent\"),\n {{ range .DirectiveArgs \"dd:span\" -}}{{printf \"%q, %q,\\n\" .Key .Value}}{{ end }}\n))\ndefer instrument.Report(\n {{$arg}}.Context(),\n event.EventEnd,\n {{with $name}}\"function-name\", {{printf \"%q\" .}},{{end}}\n \"span.kind\", \"server\",\n \"http.method\", {{$arg}}.Method,\n \"http.url\", {{$arg}}.URL,\n \"http.useragent\", {{$arg}}.Header.Get(\"User-Agent\"),\n {{ range .DirectiveArgs \"dd:span\" -}}{{printf \"%q, %q,\" .Key .Value}}{{- end }}\n)", map[string]string{ - "event": "github.com/datadog/orchestrion/instrument/event", - "instrument": "github.com/datadog/orchestrion/instrument", + "event": "github.com/DataDog/orchestrion/instrument/event", + "instrument": "github.com/DataDog/orchestrion/instrument", }, )), }, @@ -836,9 +836,9 @@ var Aspects = [...]aspect.Aspect{ var InjectedPaths = [...]string{ "context", "fmt", - "github.com/datadog/orchestrion/instrument", - "github.com/datadog/orchestrion/instrument/event", - "github.com/datadog/orchestrion/instrument/net/http", + "github.com/DataDog/orchestrion/instrument", + "github.com/DataDog/orchestrion/instrument/event", + "github.com/DataDog/orchestrion/instrument/net/http", "gopkg.in/DataDog/dd-trace-go.v1/appsec/events", "gopkg.in/DataDog/dd-trace-go.v1/contrib/IBM/sarama.v1", "gopkg.in/DataDog/dd-trace-go.v1/contrib/Shopify/sarama", @@ -886,4 +886,4 @@ var InjectedPaths = [...]string{ } // Checksum is a checksum of the built-in configuration which can be used to invalidate caches. -const Checksum = "sha512:rTz2XxmdHdvcUq4ZFmyX9nSDslyn25CZ4yM1UuqRAZGt81riAs3FHxO5H9JDRtfN5eq7Cy0BVRokzSmY+dh8yw==" +const Checksum = "sha512:NB8IV3fYeE+6FMXZtx2EFoeSWlhraYLzuBmH4f6iLZCxGjDHc4CZrVByuV1jHjJFyLR8e5qzIabizGeIVQVLnA==" diff --git a/internal/injector/builtin/generated_deps.go b/internal/injector/builtin/generated_deps.go index bb205770..1d0278f7 100644 --- a/internal/injector/builtin/generated_deps.go +++ b/internal/injector/builtin/generated_deps.go @@ -3,7 +3,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2023-present Datadog, Inc. // -// Code generated by "github.com/datadog/orchestion/internal/injector/builtin/generator -i=yaml/*.yml -i=yaml/*/*.yml -p=builtin -o=./generated.go -d=./generated_deps.go -C=1 -docs=../../../docs/content/docs/built-in/ -schemadocs=../../../docs/content/contributing/aspects/"; DO NOT EDIT. +// Code generated by "github.com/DataDog/orchestion/internal/injector/builtin/generator -i=yaml/*.yml -i=yaml/*/*.yml -p=builtin -o=./generated.go -d=./generated_deps.go -C=1 -docs=../../../docs/content/docs/built-in/ -schemadocs=../../../docs/content/contributing/aspects/"; DO NOT EDIT. //go:build tools @@ -12,9 +12,9 @@ package builtin import ( _ "context" _ "fmt" - _ "github.com/datadog/orchestrion/instrument" - _ "github.com/datadog/orchestrion/instrument/event" - _ "github.com/datadog/orchestrion/instrument/net/http" + _ "github.com/DataDog/orchestrion/instrument" + _ "github.com/DataDog/orchestrion/instrument/event" + _ "github.com/DataDog/orchestrion/instrument/net/http" _ "gopkg.in/DataDog/dd-trace-go.v1/appsec/events" _ "gopkg.in/DataDog/dd-trace-go.v1/contrib/IBM/sarama.v1" _ "gopkg.in/DataDog/dd-trace-go.v1/contrib/Shopify/sarama" diff --git a/internal/injector/builtin/generator/main.go b/internal/injector/builtin/generator/main.go index aa1427b4..3e707bed 100644 --- a/internal/injector/builtin/generator/main.go +++ b/internal/injector/builtin/generator/main.go @@ -88,7 +88,7 @@ func main() { depsFile.HeaderComment("This product includes software developed at Datadog (https://www.datadoghq.com/).") depsFile.HeaderComment("Copyright 2023-present Datadog, Inc.") depsFile.HeaderComment("") - depsFile.HeaderComment(fmt.Sprintf("Code generated by %q; DO NOT EDIT.", "github.com/datadog/orchestion/internal/injector/builtin/generator "+strings.Join(os.Args[1:], " "))) + depsFile.HeaderComment(fmt.Sprintf("Code generated by %q; DO NOT EDIT.", "github.com/DataDog/orchestion/internal/injector/builtin/generator "+strings.Join(os.Args[1:], " "))) depsFile.PackageComment("//go:build tools") } @@ -98,11 +98,11 @@ func main() { file.HeaderComment("This product includes software developed at Datadog (https://www.datadoghq.com/).") file.HeaderComment("Copyright 2023-present Datadog, Inc.") file.HeaderComment("") - file.HeaderComment(fmt.Sprintf("Code generated by %q; DO NOT EDIT.", "github.com/datadog/orchestion/internal/injector/builtin/generator "+strings.Join(os.Args[1:], " "))) + file.HeaderComment(fmt.Sprintf("Code generated by %q; DO NOT EDIT.", "github.com/DataDog/orchestion/internal/injector/builtin/generator "+strings.Join(os.Args[1:], " "))) checksum := sha512.New() file.Comment("Aspects is the list of built-in aspects.") - file.Var().Id("Aspects").Op("=").Index(jen.Op("...")).Qual("github.com/datadog/orchestrion/internal/injector/aspect", "Aspect").ValuesFunc(func(g *jen.Group) { + file.Var().Id("Aspects").Op("=").Index(jen.Op("...")).Qual("github.com/DataDog/orchestrion/internal/injector/aspect", "Aspect").ValuesFunc(func(g *jen.Group) { for _, match := range matches { // Checksum header -- SOH STX writeAll(checksum, []byte(fmt.Sprintf("\x01%s\x02", match))) diff --git a/internal/injector/builtin/generator/schema.go b/internal/injector/builtin/generator/schema.go index 161a125f..27153daa 100644 --- a/internal/injector/builtin/generator/schema.go +++ b/internal/injector/builtin/generator/schema.go @@ -14,7 +14,7 @@ import ( "runtime" "strings" - "github.com/datadog/orchestrion/internal/injector/aspect" + "github.com/DataDog/orchestrion/internal/injector/aspect" "github.com/dlclark/regexp2" "github.com/santhosh-tekuri/jsonschema/v6" "gopkg.in/yaml.v3" diff --git a/internal/injector/builtin/integration_test.go b/internal/injector/builtin/integration_test.go index c4337802..3860da31 100644 --- a/internal/injector/builtin/integration_test.go +++ b/internal/injector/builtin/integration_test.go @@ -16,9 +16,9 @@ import ( "runtime" "testing" - "github.com/datadog/orchestrion/internal/injector" - "github.com/datadog/orchestrion/internal/injector/builtin" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/injector" + "github.com/DataDog/orchestrion/internal/injector/builtin" + "github.com/DataDog/orchestrion/internal/version" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/tools/go/packages" @@ -72,7 +72,7 @@ func Test(t *testing.T) { return filepath.Join(tmp, filepath.Base(filename)) }, RootConfig: map[string]string{"httpmode": "wrap"}, - ImportPath: fmt.Sprintf("github.com/datadog/orchestrion/samples/%s", dir), + ImportPath: fmt.Sprintf("github.com/DataDog/orchestrion/samples/%s", dir), Lookup: testLookup, } diff --git a/internal/injector/builtin/testdata/client/http.go.snap b/internal/injector/builtin/testdata/client/http.go.snap index 0840ba6b..5f82c7f8 100644 --- a/internal/injector/builtin/testdata/client/http.go.snap +++ b/internal/injector/builtin/testdata/client/http.go.snap @@ -13,7 +13,7 @@ import ( "net/url" "strings" //line - __orchestrion_instrument "github.com/datadog/orchestrion/instrument/net/http" + __orchestrion_instrument "github.com/DataDog/orchestrion/instrument/net/http" ) //line samples/client/http.go:16 diff --git a/internal/injector/builtin/testdata/server/chiv5.go.snap b/internal/injector/builtin/testdata/server/chiv5.go.snap index 7a806afc..6ea8f358 100644 --- a/internal/injector/builtin/testdata/server/chiv5.go.snap +++ b/internal/injector/builtin/testdata/server/chiv5.go.snap @@ -11,7 +11,7 @@ import ( "github.com/go-chi/chi/v5" //line - __orchestrion_instrument "github.com/datadog/orchestrion/instrument" + __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" __orchestrion_chitrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/go-chi/chi.v5" ) diff --git a/internal/injector/builtin/testdata/server/gorilla.go.snap b/internal/injector/builtin/testdata/server/gorilla.go.snap index 60f2a01e..ee621949 100644 --- a/internal/injector/builtin/testdata/server/gorilla.go.snap +++ b/internal/injector/builtin/testdata/server/gorilla.go.snap @@ -12,7 +12,7 @@ import ( "github.com/gorilla/mux" //line - __orchestrion_instrument "github.com/datadog/orchestrion/instrument" + __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ) //line samples/server/gorilla.go:15 diff --git a/internal/injector/builtin/testdata/server/main.go.snap b/internal/injector/builtin/testdata/server/main.go.snap index c1042840..aedf5e7f 100644 --- a/internal/injector/builtin/testdata/server/main.go.snap +++ b/internal/injector/builtin/testdata/server/main.go.snap @@ -11,7 +11,7 @@ import ( "log" "net/http" //line - __orchestrion_instrument "github.com/datadog/orchestrion/instrument" + __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" __orchestrion_tracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" __orchestrion_profiler "gopkg.in/DataDog/dd-trace-go.v1/profiler" __orchestrion_os "os" diff --git a/internal/injector/builtin/testdata/server/other_handlers.go.snap b/internal/injector/builtin/testdata/server/other_handlers.go.snap index f625ad5e..3e1d5f17 100644 --- a/internal/injector/builtin/testdata/server/other_handlers.go.snap +++ b/internal/injector/builtin/testdata/server/other_handlers.go.snap @@ -15,7 +15,7 @@ import ( "strings" "time" //line - __orchestrion_instrument "github.com/datadog/orchestrion/instrument" + __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" __orchestrion_tracer "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) diff --git a/internal/injector/builtin/yaml/stdlib/net-http.client.yml b/internal/injector/builtin/yaml/stdlib/net-http.client.yml index 62ffba71..7c97a2a8 100644 --- a/internal/injector/builtin/yaml/stdlib/net-http.client.yml +++ b/internal/injector/builtin/yaml/stdlib/net-http.client.yml @@ -175,7 +175,7 @@ aspects: # Wire the context that is found to the handlers... - wrap-expression: imports: - instrument: github.com/datadog/orchestrion/instrument/net/http + instrument: github.com/DataDog/orchestrion/instrument/net/http template: |- {{- $ctx := .Function.ArgumentOfType "context.Context" -}} {{- $req := .Function.ArgumentOfType "*net/http.Request" }} diff --git a/internal/injector/builtin/yaml/stdlib/net-http.server.yml b/internal/injector/builtin/yaml/stdlib/net-http.server.yml index e20c5474..283622d1 100644 --- a/internal/injector/builtin/yaml/stdlib/net-http.server.yml +++ b/internal/injector/builtin/yaml/stdlib/net-http.server.yml @@ -27,7 +27,7 @@ aspects: advice: - wrap-expression: imports: - instrument: github.com/datadog/orchestrion/instrument + instrument: github.com/DataDog/orchestrion/instrument template: |- //dd:startwrap instrument.WrapHandler({{.}}) @@ -51,7 +51,7 @@ aspects: advice: - wrap-expression: imports: - instrument: "github.com/datadog/orchestrion/instrument" + instrument: "github.com/DataDog/orchestrion/instrument" template: |- instrument.WrapHandlerFunc({{.}}) @@ -76,8 +76,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $arg := .Function.Argument 1 -}} {{- $name := .Function.Name -}} diff --git a/internal/injector/injector.go b/internal/injector/injector.go index ce19b698..b0b6dc81 100644 --- a/internal/injector/injector.go +++ b/internal/injector/injector.go @@ -14,9 +14,9 @@ import ( "go/importer" "go/token" - "github.com/datadog/orchestrion/internal/injector/aspect" - "github.com/datadog/orchestrion/internal/injector/aspect/context" - "github.com/datadog/orchestrion/internal/injector/typed" + "github.com/DataDog/orchestrion/internal/injector/aspect" + "github.com/DataDog/orchestrion/internal/injector/aspect/context" + "github.com/DataDog/orchestrion/internal/injector/typed" "github.com/dave/dst" "github.com/dave/dst/decorator" "github.com/dave/dst/decorator/resolver" diff --git a/internal/injector/injector_test.go b/internal/injector/injector_test.go index 073586a8..56b8e36f 100644 --- a/internal/injector/injector_test.go +++ b/internal/injector/injector_test.go @@ -15,9 +15,9 @@ import ( "strings" "testing" - "github.com/datadog/orchestrion/internal/injector" - "github.com/datadog/orchestrion/internal/injector/aspect" - "github.com/datadog/orchestrion/internal/injector/typed" + "github.com/DataDog/orchestrion/internal/injector" + "github.com/DataDog/orchestrion/internal/injector/aspect" + "github.com/DataDog/orchestrion/internal/injector/typed" "github.com/hexops/gotextdiff" "github.com/hexops/gotextdiff/myers" "github.com/hexops/gotextdiff/span" @@ -87,7 +87,7 @@ func Test(t *testing.T) { require.NoError(t, yaml.Unmarshal(data, &config), "failed to parse test configuration") runGo(t, tmp, "mod", "init", testModuleName) - runGo(t, tmp, "mod", "edit", "-replace", fmt.Sprintf("github.com/datadog/orchestrion=%s", rootDir)) + runGo(t, tmp, "mod", "edit", "-replace", fmt.Sprintf("github.com/DataDog/orchestrion=%s", rootDir)) inputFile := filepath.Join(tmp, "input.go") original := strings.TrimSpace(config.Code) + "\n" diff --git a/internal/injector/testdata/injector/directive/config.yml b/internal/injector/testdata/injector/directive/config.yml index 8c2551cf..7dcd2106 100644 --- a/internal/injector/testdata/injector/directive/config.yml +++ b/internal/injector/testdata/injector/directive/config.yml @@ -10,8 +10,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $ctx := .Function.ArgumentOfType "context.Context" -}} {{- $name := .Function.Name -}} @@ -25,8 +25,8 @@ aspects: {{- end -}}) syntheticReferences: - github.com/datadog/orchestrion/instrument: true - github.com/datadog/orchestrion/instrument/event: true + github.com/DataDog/orchestrion/instrument: true + github.com/DataDog/orchestrion/instrument/event: true code: |- package test diff --git a/internal/injector/testdata/injector/directive/expected.diff b/internal/injector/testdata/injector/directive/expected.diff index 91a314a5..a24ec100 100644 --- a/internal/injector/testdata/injector/directive/expected.diff +++ b/internal/injector/testdata/injector/directive/expected.diff @@ -7,8 +7,8 @@ import ( "context" +//line -+ __orchestrion_instrument "github.com/datadog/orchestrion/instrument" -+ __orchestrion_event "github.com/datadog/orchestrion/instrument/event" ++ __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ++ __orchestrion_event "github.com/DataDog/orchestrion/instrument/event" ) //dd:span foo:bar baz:qux diff --git a/internal/injector/testdata/injector/http-anonymous-handler/config.yml b/internal/injector/testdata/injector/http-anonymous-handler/config.yml index 228ebcfc..acac9962 100644 --- a/internal/injector/testdata/injector/http-anonymous-handler/config.yml +++ b/internal/injector/testdata/injector/http-anonymous-handler/config.yml @@ -11,8 +11,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $arg := .Function.Argument 1 -}} {{- $name := .Function.Name -}} @@ -38,8 +38,8 @@ aspects: ) syntheticReferences: - github.com/datadog/orchestrion/instrument/event: true - github.com/datadog/orchestrion/instrument: true + github.com/DataDog/orchestrion/instrument/event: true + github.com/DataDog/orchestrion/instrument: true code: |- package main diff --git a/internal/injector/testdata/injector/http-anonymous-handler/expected.diff b/internal/injector/testdata/injector/http-anonymous-handler/expected.diff index 0c656175..b508da3e 100644 --- a/internal/injector/testdata/injector/http-anonymous-handler/expected.diff +++ b/internal/injector/testdata/injector/http-anonymous-handler/expected.diff @@ -9,8 +9,8 @@ "log" "net/http" +//line -+ __orchestrion_instrument "github.com/datadog/orchestrion/instrument" -+ __orchestrion_event "github.com/datadog/orchestrion/instrument/event" ++ __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ++ __orchestrion_event "github.com/DataDog/orchestrion/instrument/event" ) +//line input.go:9 diff --git a/internal/injector/testdata/injector/http-default/config.yml b/internal/injector/testdata/injector/http-default/config.yml index 55b515ad..e35db0e5 100644 --- a/internal/injector/testdata/injector/http-default/config.yml +++ b/internal/injector/testdata/injector/http-default/config.yml @@ -11,8 +11,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $arg := .Function.Argument 1 -}} {{- $name := .Function.Name -}} @@ -38,8 +38,8 @@ aspects: ) syntheticReferences: - github.com/datadog/orchestrion/instrument/event: true - github.com/datadog/orchestrion/instrument: true + github.com/DataDog/orchestrion/instrument/event: true + github.com/DataDog/orchestrion/instrument: true code: |- package main diff --git a/internal/injector/testdata/injector/http-default/expected.diff b/internal/injector/testdata/injector/http-default/expected.diff index f8ffe9a6..66db0fe5 100644 --- a/internal/injector/testdata/injector/http-default/expected.diff +++ b/internal/injector/testdata/injector/http-default/expected.diff @@ -9,8 +9,8 @@ "log" "net/http" +//line -+ __orchestrion_instrument "github.com/datadog/orchestrion/instrument" -+ __orchestrion_event "github.com/datadog/orchestrion/instrument/event" ++ __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ++ __orchestrion_event "github.com/DataDog/orchestrion/instrument/event" ) +//line input.go:9 diff --git a/internal/injector/testdata/injector/http-ignored/config.yml b/internal/injector/testdata/injector/http-ignored/config.yml index 88d909a6..f07f2a0b 100644 --- a/internal/injector/testdata/injector/http-ignored/config.yml +++ b/internal/injector/testdata/injector/http-ignored/config.yml @@ -11,8 +11,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $arg := .Function.Argument 1 -}} {{- $name := .Function.Name -}} diff --git a/internal/injector/testdata/injector/http-line-info/config.yml b/internal/injector/testdata/injector/http-line-info/config.yml index 55b515ad..e35db0e5 100644 --- a/internal/injector/testdata/injector/http-line-info/config.yml +++ b/internal/injector/testdata/injector/http-line-info/config.yml @@ -11,8 +11,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $arg := .Function.Argument 1 -}} {{- $name := .Function.Name -}} @@ -38,8 +38,8 @@ aspects: ) syntheticReferences: - github.com/datadog/orchestrion/instrument/event: true - github.com/datadog/orchestrion/instrument: true + github.com/DataDog/orchestrion/instrument/event: true + github.com/DataDog/orchestrion/instrument: true code: |- package main diff --git a/internal/injector/testdata/injector/http-line-info/expected.diff b/internal/injector/testdata/injector/http-line-info/expected.diff index f8ffe9a6..66db0fe5 100644 --- a/internal/injector/testdata/injector/http-line-info/expected.diff +++ b/internal/injector/testdata/injector/http-line-info/expected.diff @@ -9,8 +9,8 @@ "log" "net/http" +//line -+ __orchestrion_instrument "github.com/datadog/orchestrion/instrument" -+ __orchestrion_event "github.com/datadog/orchestrion/instrument/event" ++ __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ++ __orchestrion_event "github.com/DataDog/orchestrion/instrument/event" ) +//line input.go:9 diff --git a/internal/injector/testdata/injector/http-no-arg-name/config.yml b/internal/injector/testdata/injector/http-no-arg-name/config.yml index 4d38b00d..491a03b5 100644 --- a/internal/injector/testdata/injector/http-no-arg-name/config.yml +++ b/internal/injector/testdata/injector/http-no-arg-name/config.yml @@ -11,8 +11,8 @@ aspects: advice: - prepend-statements: imports: - event: github.com/datadog/orchestrion/instrument/event - instrument: github.com/datadog/orchestrion/instrument + event: github.com/DataDog/orchestrion/instrument/event + instrument: github.com/DataDog/orchestrion/instrument template: |- {{- $arg := .Function.Argument 1 -}} {{- $name := .Function.Name -}} @@ -38,8 +38,8 @@ aspects: ) syntheticReferences: - github.com/datadog/orchestrion/instrument/event: true - github.com/datadog/orchestrion/instrument: true + github.com/DataDog/orchestrion/instrument/event: true + github.com/DataDog/orchestrion/instrument: true code: |- package main diff --git a/internal/injector/testdata/injector/http-no-arg-name/expected.diff b/internal/injector/testdata/injector/http-no-arg-name/expected.diff index 5c0ad153..82e11c63 100644 --- a/internal/injector/testdata/injector/http-no-arg-name/expected.diff +++ b/internal/injector/testdata/injector/http-no-arg-name/expected.diff @@ -8,8 +8,8 @@ "log" "net/http" +//line -+ __orchestrion_instrument "github.com/datadog/orchestrion/instrument" -+ __orchestrion_event "github.com/datadog/orchestrion/instrument/event" ++ __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ++ __orchestrion_event "github.com/DataDog/orchestrion/instrument/event" ) +//line input.go:8 diff --git a/internal/injector/testdata/injector/http-server/config.yml b/internal/injector/testdata/injector/http-server/config.yml index ae1036bb..136b4359 100644 --- a/internal/injector/testdata/injector/http-server/config.yml +++ b/internal/injector/testdata/injector/http-server/config.yml @@ -8,14 +8,14 @@ aspects: advice: - wrap-expression: imports: - instrument: github.com/datadog/orchestrion/instrument + instrument: github.com/DataDog/orchestrion/instrument template: |- //dd:startwrap instrument.WrapHandler({{ . }}) //dd:endwrap syntheticReferences: - github.com/datadog/orchestrion/instrument: true + github.com/DataDog/orchestrion/instrument: true code: |- package main diff --git a/internal/injector/testdata/injector/http-server/expected.diff b/internal/injector/testdata/injector/http-server/expected.diff index a3b6421c..6f5541e4 100644 --- a/internal/injector/testdata/injector/http-server/expected.diff +++ b/internal/injector/testdata/injector/http-server/expected.diff @@ -9,7 +9,7 @@ "log" "net/http" +//line -+ __orchestrion_instrument "github.com/datadog/orchestrion/instrument" ++ __orchestrion_instrument "github.com/DataDog/orchestrion/instrument" ) +//line input.go:9 diff --git a/internal/injector/typed/refmap.go b/internal/injector/typed/refmap.go index 53e80b9e..99067388 100644 --- a/internal/injector/typed/refmap.go +++ b/internal/injector/typed/refmap.go @@ -11,7 +11,7 @@ import ( "slices" "strings" - "github.com/datadog/orchestrion/internal/injector/basiclit" + "github.com/DataDog/orchestrion/internal/injector/basiclit" "github.com/dave/dst" ) diff --git a/internal/injector/write.go b/internal/injector/write.go index 13291267..8a68522c 100644 --- a/internal/injector/write.go +++ b/internal/injector/write.go @@ -12,7 +12,7 @@ import ( "os" "path/filepath" - "github.com/datadog/orchestrion/internal/injector/lineinfo" + "github.com/DataDog/orchestrion/internal/injector/lineinfo" "github.com/dave/dst" "github.com/dave/dst/decorator" ) diff --git a/internal/jobserver/buildid/buildid.go b/internal/jobserver/buildid/buildid.go index 9c6ce299..b3e0138f 100644 --- a/internal/jobserver/buildid/buildid.go +++ b/internal/jobserver/buildid/buildid.go @@ -8,7 +8,7 @@ package buildid import ( "sync" - "github.com/datadog/orchestrion/internal/jobserver/common" + "github.com/DataDog/orchestrion/internal/jobserver/common" "github.com/nats-io/nats.go" ) diff --git a/internal/jobserver/buildid/version.go b/internal/jobserver/buildid/version.go index 585e755a..9c344a39 100644 --- a/internal/jobserver/buildid/version.go +++ b/internal/jobserver/buildid/version.go @@ -18,9 +18,9 @@ import ( "sort" "strings" - "github.com/datadog/orchestrion/internal/injector/builtin" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/injector/builtin" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/version" "golang.org/x/tools/go/packages" ) diff --git a/internal/jobserver/client/client.go b/internal/jobserver/client/client.go index 9b81089c..5da3bac0 100644 --- a/internal/jobserver/client/client.go +++ b/internal/jobserver/client/client.go @@ -11,7 +11,7 @@ import ( "fmt" "os" - "github.com/datadog/orchestrion/internal/jobserver/common" + "github.com/DataDog/orchestrion/internal/jobserver/common" "github.com/nats-io/nats.go" ) diff --git a/internal/jobserver/client/env.go b/internal/jobserver/client/env.go index fd5833ec..c565135c 100644 --- a/internal/jobserver/client/env.go +++ b/internal/jobserver/client/env.go @@ -14,8 +14,8 @@ import ( "path/filepath" "time" - "github.com/datadog/orchestrion/internal/filelock" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/filelock" + "github.com/DataDog/orchestrion/internal/log" ) const ( diff --git a/internal/jobserver/common/graph_test.go b/internal/jobserver/common/graph_test.go index 1b2b883a..eebd0e94 100644 --- a/internal/jobserver/common/graph_test.go +++ b/internal/jobserver/common/graph_test.go @@ -8,7 +8,7 @@ package common_test import ( "testing" - "github.com/datadog/orchestrion/internal/jobserver/common" + "github.com/DataDog/orchestrion/internal/jobserver/common" "github.com/stretchr/testify/require" ) diff --git a/internal/jobserver/common/handler.go b/internal/jobserver/common/handler.go index 2966fb03..2dcb81c5 100644 --- a/internal/jobserver/common/handler.go +++ b/internal/jobserver/common/handler.go @@ -9,7 +9,7 @@ import ( "encoding/json" "errors" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/log" "github.com/nats-io/nats.go" ) diff --git a/internal/jobserver/pkgs/pkgs.go b/internal/jobserver/pkgs/pkgs.go index 3aef28a3..b82dcde6 100644 --- a/internal/jobserver/pkgs/pkgs.go +++ b/internal/jobserver/pkgs/pkgs.go @@ -6,7 +6,7 @@ package pkgs import ( - "github.com/datadog/orchestrion/internal/jobserver/common" + "github.com/DataDog/orchestrion/internal/jobserver/common" "github.com/nats-io/nats.go" ) diff --git a/internal/jobserver/pkgs/resolve.go b/internal/jobserver/pkgs/resolve.go index 331ba3e8..d17d9580 100644 --- a/internal/jobserver/pkgs/resolve.go +++ b/internal/jobserver/pkgs/resolve.go @@ -14,8 +14,8 @@ import ( "slices" "strings" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/log" "golang.org/x/tools/go/packages" ) diff --git a/internal/jobserver/pkgs/resolve_test.go b/internal/jobserver/pkgs/resolve_test.go index 98c1ad7d..8b597ae4 100644 --- a/internal/jobserver/pkgs/resolve_test.go +++ b/internal/jobserver/pkgs/resolve_test.go @@ -11,9 +11,9 @@ import ( "os" "testing" - "github.com/datadog/orchestrion/internal/jobserver" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/jobserver/pkgs" + "github.com/DataDog/orchestrion/internal/jobserver" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/jobserver/pkgs" "github.com/stretchr/testify/require" ) diff --git a/internal/jobserver/server.go b/internal/jobserver/server.go index 5486d4b3..2b9910fb 100644 --- a/internal/jobserver/server.go +++ b/internal/jobserver/server.go @@ -13,11 +13,11 @@ import ( "sync" "time" - "github.com/datadog/orchestrion/internal/jobserver/buildid" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/jobserver/common" - "github.com/datadog/orchestrion/internal/jobserver/pkgs" - "github.com/datadog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/jobserver/buildid" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/jobserver/common" + "github.com/DataDog/orchestrion/internal/jobserver/pkgs" + "github.com/DataDog/orchestrion/internal/log" "github.com/nats-io/nats-server/v2/server" "github.com/nats-io/nats.go" ) diff --git a/internal/pin/pin.go b/internal/pin/pin.go index 1e08c88e..a7a84154 100644 --- a/internal/pin/pin.go +++ b/internal/pin/pin.go @@ -12,17 +12,17 @@ import ( "path/filepath" "strings" + "github.com/DataDog/orchestrion/internal/ensure" + "github.com/DataDog/orchestrion/internal/goenv" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/version" "github.com/charmbracelet/lipgloss" - "github.com/datadog/orchestrion/internal/ensure" - "github.com/datadog/orchestrion/internal/goenv" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/version" "github.com/dave/jennifer/jen" "golang.org/x/term" ) const ( - orchestrionImportPath = "github.com/datadog/orchestrion" + orchestrionImportPath = "github.com/DataDog/orchestrion" orchestrionToolGo = "orchestrion.tool.go" envVarCheckedGoMod = "DD_ORCHESTRION_IS_GOMOD_VERSION" envValTrue = "true" diff --git a/internal/pin/pin_test.go b/internal/pin/pin_test.go index 9ad4d113..66786f7f 100644 --- a/internal/pin/pin_test.go +++ b/internal/pin/pin_test.go @@ -13,7 +13,7 @@ import ( "runtime" "testing" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/version" "github.com/stretchr/testify/require" ) @@ -34,7 +34,7 @@ func TestPin(t *testing.T) { data, err := os.ReadFile(filepath.Join(tmp, "go.mod")) require.NoError(t, err) - require.Contains(t, string(data), fmt.Sprintf(`github.com/datadog/orchestrion %s`, version.Tag)) + require.Contains(t, string(data), fmt.Sprintf(`github.com/DataDog/orchestrion %s`, version.Tag)) } func scaffold(dir string) error { @@ -47,7 +47,7 @@ func scaffold(dir string) error { } defer goMod.Close() - if _, err := fmt.Fprintln(goMod, "module github.com/datadog/orchestrion/pin-test"); err != nil { + if _, err := fmt.Fprintln(goMod, "module github.com/DataDog/orchestrion/pin-test"); err != nil { return err } if _, err := fmt.Fprintln(goMod); err != nil { @@ -59,7 +59,7 @@ func scaffold(dir string) error { if _, err := fmt.Fprintln(goMod); err != nil { return err } - if _, err := fmt.Fprintf(goMod, "replace github.com/datadog/orchestrion %s => %s\n", version.Tag, rootDir); err != nil { + if _, err := fmt.Fprintf(goMod, "replace github.com/DataDog/orchestrion %s => %s\n", version.Tag, rootDir); err != nil { return err } diff --git a/internal/toolexec/aspect/oncompile-main.go b/internal/toolexec/aspect/oncompile-main.go index c4733cf9..07b1360e 100644 --- a/internal/toolexec/aspect/oncompile-main.go +++ b/internal/toolexec/aspect/oncompile-main.go @@ -11,10 +11,10 @@ import ( "os" "path/filepath" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/toolexec/aspect/linkdeps" - "github.com/datadog/orchestrion/internal/toolexec/importcfg" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/toolexec/aspect/linkdeps" + "github.com/DataDog/orchestrion/internal/toolexec/importcfg" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" "github.com/dave/jennifer/jen" ) diff --git a/internal/toolexec/aspect/oncompile.go b/internal/toolexec/aspect/oncompile.go index 621fc4cd..0bfd2439 100644 --- a/internal/toolexec/aspect/oncompile.go +++ b/internal/toolexec/aspect/oncompile.go @@ -12,14 +12,14 @@ import ( "path/filepath" "regexp" - "github.com/datadog/orchestrion/internal/injector" - "github.com/datadog/orchestrion/internal/injector/aspect" - "github.com/datadog/orchestrion/internal/injector/builtin" - "github.com/datadog/orchestrion/internal/injector/typed" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/toolexec/aspect/linkdeps" - "github.com/datadog/orchestrion/internal/toolexec/importcfg" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/injector" + "github.com/DataDog/orchestrion/internal/injector/aspect" + "github.com/DataDog/orchestrion/internal/injector/builtin" + "github.com/DataDog/orchestrion/internal/injector/typed" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/toolexec/aspect/linkdeps" + "github.com/DataDog/orchestrion/internal/toolexec/importcfg" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" ) type specialCaseBehavior int @@ -31,9 +31,9 @@ const ( var ( weavingSpecialCase = map[*regexp.Regexp]specialCaseBehavior{ - regexp.MustCompile(`^github\.com/datadog/orchestrion(?:/.+)?$`): neverWeave, - regexp.MustCompile(`^gopkg\.in/DataDog/dd-trace-go.v1(?:/.+)?$`): weaveTracerInternal, - regexp.MustCompile(`^github\.com/DataDog/go-tuf/client$`): neverWeave, + regexp.MustCompile(`^github\.com/[Dd]ata[Dd]og/orchestrion(?:/.+)?$`): neverWeave, + regexp.MustCompile(`^gopkg\.in/DataDog/dd-trace-go.v1(?:/.+)?$`): weaveTracerInternal, + regexp.MustCompile(`^github\.com/DataDog/go-tuf/client$`): neverWeave, } ) @@ -71,7 +71,7 @@ func (w Weaver) OnCompile(cmd *proxy.CompileCommand) error { RootConfig: map[string]string{"httpmode": "wrap"}, Lookup: imports.Lookup, ImportPath: w.ImportPath, - GoVersion: cmd.Flags.GoVersion, + GoVersion: cmd.Flags.Lang, ModifiedFile: func(file string) string { return filepath.Join(orchestrionDir, "src", cmd.Flags.Package, filepath.Base(file)) }, diff --git a/internal/toolexec/aspect/onlink.go b/internal/toolexec/aspect/onlink.go index e6558193..279a8c42 100644 --- a/internal/toolexec/aspect/onlink.go +++ b/internal/toolexec/aspect/onlink.go @@ -9,10 +9,10 @@ import ( "fmt" "os" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/toolexec/aspect/linkdeps" - "github.com/datadog/orchestrion/internal/toolexec/importcfg" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/toolexec/aspect/linkdeps" + "github.com/DataDog/orchestrion/internal/toolexec/importcfg" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" ) func (Weaver) OnLink(cmd *proxy.LinkCommand) error { diff --git a/internal/toolexec/aspect/resolve.go b/internal/toolexec/aspect/resolve.go index b9f164bf..2ad76107 100644 --- a/internal/toolexec/aspect/resolve.go +++ b/internal/toolexec/aspect/resolve.go @@ -10,9 +10,9 @@ import ( "fmt" "os" - "github.com/datadog/orchestrion/internal/goflags" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/jobserver/pkgs" + "github.com/DataDog/orchestrion/internal/goflags" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/jobserver/pkgs" ) // resolvePackageFiles attempts to retrieve the archive for the designated import path. It attempts diff --git a/internal/toolexec/proxy/compile.flags.go b/internal/toolexec/proxy/compile.flags.go new file mode 100644 index 00000000..fdf8df7b --- /dev/null +++ b/internal/toolexec/proxy/compile.flags.go @@ -0,0 +1,88 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +// Code generated by 'go generate' DO NOT EDIT. + +package proxy + +import "flag" + +func (f *compileFlagSet) parse(args []string) ([]string, error) { + flagSet := flag.NewFlagSet("compile version go1.23", flag.ContinueOnError) + flagSet.Bool("%", false, "debug non-static initializers") + flagSet.Bool("+", false, "compiling runtime") + flagSet.Bool("B", false, "disable bounds checking") + flagSet.Bool("C", false, "disable printing of columns in error messages") + flagSet.String("D", "", "set relative path for local imports") + flagSet.Bool("E", false, "debug symbol export") + flagSet.String("I", "", "add directory to import search path") + flagSet.Bool("K", false, "debug missing line numbers") + flagSet.Bool("L", false, "also show actual source file names in error messages for positions affected by //line directives") + flagSet.Bool("N", false, "disable optimizations") + flagSet.Bool("S", false, "print assembly listing") + flagSet.BoolFunc("V", "print version and exit", func(string) error { + f.ShowVersion = true + return nil + }) + flagSet.Bool("W", false, "debug parse tree after type checking") + flagSet.Bool("asan", false, "build code compatible with C/C++ address sanitizer") + flagSet.String("asmhdr", "", "write assembly header to file") + flagSet.String("bench", "", "append benchmark times to file") + flagSet.String("blockprofile", "", "write block profile to file") + flagSet.String("buildid", "", "record id as the build id in the export metadata") + flagSet.Int("c", 0, "concurrency during compilation (1 means no concurrency)") + flagSet.Bool("clobberdead", false, "clobber dead stack slots (for debugging)") + flagSet.Bool("clobberdeadreg", false, "clobber dead registers (for debugging)") + flagSet.Bool("complete", false, "compiling complete package (no C or assembly)") + flagSet.String("coveragecfg", "", "read coverage configuration from file") + flagSet.String("cpuprofile", "", "write cpu profile to file") + flagSet.String("d", "", "enable debugging settings; try -d help") + flagSet.Bool("dwarf", false, "generate DWARF symbols") + flagSet.Bool("dwarfbasentries", false, "use base address selection entries in DWARF") + flagSet.Bool("dwarflocationlists", false, "add location lists to DWARF in optimized mode") + flagSet.Bool("dynlink", false, "support references to Go symbols defined in other shared libraries") + flagSet.Bool("e", false, "no limit on number of errors reported") + flagSet.String("embedcfg", "", "read go:embed configuration from file") + flagSet.String("env", "", "add definition of the form key=value to environment") + flagSet.Bool("errorurl", false, "print explanatory URL with error message if applicable") + flagSet.Int("gendwarfinl", 0, "generate DWARF inline info records") + flagSet.String("goversion", "", "required version of the runtime") + flagSet.Bool("h", false, "halt on error") + flagSet.StringVar(&f.ImportCfg, "importcfg", "", "read import configuration from file") + flagSet.String("installsuffix", "", "set pkg directory suffix") + flagSet.Bool("j", false, "debug runtime-initialized variables") + flagSet.String("json", "", "version,file for JSON compiler/optimizer detail output") + flagSet.Bool("l", false, "disable inlining") + flagSet.StringVar(&f.Lang, "lang", "", "Go language version source code expects") + flagSet.String("linkobj", "", "write linker-specific object to file") + flagSet.Bool("linkshared", false, "generate code that will be linked against Go shared libraries") + flagSet.Bool("live", false, "debug liveness analysis") + flagSet.Bool("m", false, "print optimization decisions") + flagSet.String("memprofile", "", "write memory profile to file") + flagSet.String("memprofilerate", "", "set runtime.MemProfileRate to rate") + flagSet.Bool("msan", false, "build code compatible with C/C++ memory sanitizer") + flagSet.String("mutexprofile", "", "write mutex profile to file") + flagSet.Bool("nolocalimports", false, "reject local (relative) imports") + flagSet.StringVar(&f.Output, "o", "", "write output to file") + flagSet.StringVar(&f.Package, "p", "", "set expected package import path") + flagSet.Bool("pack", false, "write to file.a instead of file.o") + flagSet.String("pgoprofile", "", "read profile or pre-process profile from file") + flagSet.Bool("r", false, "debug generated wrappers") + flagSet.Bool("race", false, "enable race detector") + flagSet.Bool("shared", false, "generate code that can be linked into a shared library") + flagSet.Bool("smallframes", false, "reduce the size limit for stack allocated objects") + flagSet.String("spectre", "", "enable spectre mitigations in list (all, index, ret)") + flagSet.Bool("std", false, "compiling standard library") + flagSet.String("symabis", "", "read symbol ABIs from file") + flagSet.Bool("t", false, "enable tracing for debugging the compiler") + flagSet.String("traceprofile", "", "write an execution trace to file") + flagSet.String("trimpath", "", "remove prefix from recorded source file paths") + flagSet.Bool("v", false, "increase debug verbosity") + flagSet.Bool("w", false, "debug type checking") + flagSet.Bool("wb", false, "enable write barrier") + + err := flagSet.Parse(args) + return flagSet.Args(), err +} diff --git a/internal/toolexec/proxy/compile.go b/internal/toolexec/proxy/compile.go index 3a85488e..1860c16d 100644 --- a/internal/toolexec/proxy/compile.go +++ b/internal/toolexec/proxy/compile.go @@ -11,28 +11,35 @@ import ( "strings" ) +//go:generate go run github.com/DataDog/orchestrion/internal/toolexec/proxy/generator -command=compile + type compileFlagSet struct { - Package string `ddflag:"-p"` - ImportCfg string `ddflag:"-importcfg"` - Output string `ddflag:"-o"` - TrimPath string `ddflag:"-trimpath"` - GoVersion string `ddflag:"-goversion"` + Package string `ddflag:"-p"` + ImportCfg string `ddflag:"-importcfg"` + Output string `ddflag:"-o"` + Lang string `ddflag:"-lang"` + ShowVersion bool `ddflag:"-V"` } // CompileCommand represents a go tool `compile` invocation type CompileCommand struct { command Flags compileFlagSet + Files []string // WorkDir is the $WORK directory managed by the go toolchain. WorkDir string } func (*CompileCommand) Type() CommandType { return CommandTypeCompile } +func (c *CompileCommand) ShowVersion() bool { + return c.Flags.ShowVersion +} + // GoFiles returns the list of Go files passed as arguments to cmd func (cmd *CompileCommand) GoFiles() []string { - files := make([]string, 0, len(cmd.args)) - for _, path := range cmd.args { + files := make([]string, 0, len(cmd.Files)) + for _, path := range cmd.Files { if !strings.HasSuffix(path, ".go") { continue } @@ -47,6 +54,7 @@ func (cmd *CompileCommand) GoFiles() []string { func (cmd *CompileCommand) AddFiles(files []string) { paramIdx := len(cmd.args) cmd.args = append(cmd.args, files...) + cmd.Files = append(cmd.Files, files...) for i, f := range files { cmd.paramPos[f] = paramIdx + i } @@ -57,7 +65,11 @@ func parseCompileCommand(args []string) (Command, error) { return nil, errors.New("unexpected number of command arguments") } cmd := CompileCommand{command: NewCommand(args)} - parseFlags(&cmd.Flags, args[1:]) + pos, err := cmd.Flags.parse(args[1:]) + if err != nil { + return nil, err + } + cmd.Files = pos if cmd.Flags.ImportCfg != "" { // The WorkDir is the parent of the stage directory, which is where the importcfg file is located. diff --git a/internal/toolexec/proxy/compile_test.go b/internal/toolexec/proxy/compile_test.go index 5fbd11d9..8665d14c 100644 --- a/internal/toolexec/proxy/compile_test.go +++ b/internal/toolexec/proxy/compile_test.go @@ -6,7 +6,6 @@ package proxy import ( - "reflect" "testing" "github.com/stretchr/testify/require" @@ -15,33 +14,49 @@ import ( func TestParseCompile(t *testing.T) { for name, tc := range map[string]struct { input []string - stage string goFiles []string flags compileFlagSet }{ "version_print": { input: []string{"/path/compile", "-V=full"}, - stage: ".", + flags: compileFlagSet{ + ShowVersion: true, + }, }, "compile": { - input: []string{"/path/compile", "-o", "/buildDir/b002/a.out", "-p", "mypackage", "-goversion", "go1.42.1337", "-importcfg", "/buildDir/b002/importcfg", "/source/dir/main.go", "/source/dir/file1.go"}, - stage: "b002", + input: []string{"/path/compile", "-o", "/buildDir/b002/a.out", "-p", "mypackage", "-lang=go1.42", "-importcfg", "/buildDir/b002/importcfg", "/source/dir/main.go", "/source/dir/file1.go"}, goFiles: []string{"/source/dir/main.go", "/source/dir/file1.go"}, flags: compileFlagSet{ Package: "mypackage", ImportCfg: "/buildDir/b002/importcfg", Output: "/buildDir/b002/a.out", - GoVersion: "go1.42.1337", + Lang: "go1.42", + }, + }, + "nats.go": { + input: []string{"/path/compile", "-o", "/buildDir/b002/a.out", "-p", "github.com/nats-io/nats.go", "-complete", "/path/to/source/file.go"}, + goFiles: []string{"/path/to/source/file.go"}, + flags: compileFlagSet{ + Package: "github.com/nats-io/nats.go", + Output: "/buildDir/b002/a.out", }, }, } { + if tc.goFiles == nil { + // Simplify comparisons, as goFiles always returns non-nil + tc.goFiles = make([]string, 0) + } + + if name != "nats.go" { + continue + } t.Run(name, func(t *testing.T) { cmd, err := parseCompileCommand(tc.input) require.NoError(t, err) require.Equal(t, CommandTypeCompile, cmd.Type()) - require.Equal(t, tc.stage, cmd.Stage()) c := cmd.(*CompileCommand) - require.True(t, reflect.DeepEqual(tc.flags, c.Flags)) + require.Equal(t, tc.flags, c.Flags) + require.EqualValues(t, tc.goFiles, c.GoFiles()) }) } } diff --git a/internal/toolexec/proxy/flags.go b/internal/toolexec/proxy/flags.go deleted file mode 100644 index 8415a8cd..00000000 --- a/internal/toolexec/proxy/flags.go +++ /dev/null @@ -1,95 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2023-present Datadog, Inc. - -package proxy - -import ( - "fmt" - "reflect" - "strings" -) - -const structTagKey = "ddflag" - -// parseFlags walks through the given arguments and sets the flagSet values -// present in the argument list. Unknown options, not present in the flagSet -// are accepted and skipped. The argument list is not modified. -func parseFlags(flagSet any, args []string) { - flagSetValueMap := makeFlagSetValueMap(flagSet) - - i := 0 - for i < len(args)-1 { - _, shift := parseOption(flagSetValueMap, args[i], args[i+1]) - i += shift - } - - if i < len(args) { - _, _ = parseOption(flagSetValueMap, args[i], "") - } -} - -func makeFlagSetValueMap(flagSet any) map[string]reflect.Value { - v := reflect.ValueOf(flagSet).Elem() - if v.Kind() != reflect.Struct { - panic(fmt.Errorf("flagSet type %T is not a struct", flagSet)) - } - typ := v.Type() - flagSetValueMap := make(map[string]reflect.Value, v.NumField()) - for i := 0; i < typ.NumField(); i++ { - field := typ.Field(i) - if tag, ok := field.Tag.Lookup(structTagKey); ok { - flagSetValueMap[tag] = v.Field(i) - } - } - return flagSetValueMap -} - -// parseOption parses the given current argument and following one according to -// the go Flags syntax. -func parseOption(flagSetValueMap map[string]reflect.Value, arg string, nextArg string) (nonOpt bool, shift int) { - if arg[0] != '-' { - // Not an option, return the value and shift by one. - return true, 1 - } - - // Split the argument by its first `=` character if any, and check the - // syntax being used. - option, value, hasValue := strings.Cut(arg, "=") - flag, exists := flagSetValueMap[option] - - if hasValue { - // `-opt=val` syntax - shift = 1 - if exists { - flag.SetString(value) - } - } else if nextArg != "" && !strings.HasPrefix(nextArg, "-") { - // `-opt val` syntax - value := nextArg - shift = 2 - if exists { - switch flag.Kind() { - case reflect.String: - flag.SetString(value) - case reflect.Bool: - flag.SetBool(true) - shift = 1 - default: - panic(fmt.Errorf("unsupported value kind: %s", flag.Kind())) - } - } - } else { - // `-opt` syntax (no value) - shift = 1 - if exists { - if flag.Kind() != reflect.Bool { - panic(fmt.Sprintf("missing value for %s flag", flag.Kind())) - } - flag.SetBool(true) - } - } - - return -} diff --git a/internal/toolexec/proxy/flags_test.go b/internal/toolexec/proxy/flags_test.go deleted file mode 100644 index a4a387f7..00000000 --- a/internal/toolexec/proxy/flags_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2023-present Datadog, Inc. - -package proxy - -import ( - "reflect" - "testing" - - "github.com/stretchr/testify/require" -) - -type testFlagSet struct { - FlagStr string `ddflag:"-flagStr"` - FlagBool bool `ddflag:"-flagBool"` -} - -func TestParseFlags(t *testing.T) { - for name, tc := range map[string]struct { - args []string - expected testFlagSet - panic bool - }{ - "flagStr/plain": { - args: []string{"-flagStr", "test"}, - expected: testFlagSet{ - FlagStr: "test", - }, - }, - "flagStr/assignment": { - args: []string{"-flagStr=test"}, - expected: testFlagSet{ - FlagStr: "test", - }, - }, - "flagStr/assignment-empty": { - args: []string{"-flagStr="}, - }, - "flagBool": { - args: []string{"-flagBool"}, - expected: testFlagSet{ - FlagBool: true, - }, - }, - "combined/1": { - args: []string{"-flagStr", "test", "-flagBool"}, - expected: testFlagSet{ - FlagStr: "test", - FlagBool: true, - }, - }, - "combined/2": { - args: []string{"-flagStr=test", "-flagBool"}, - expected: testFlagSet{ - FlagStr: "test", - FlagBool: true, - }, - }, - "combined/3": { - args: []string{"-flagBool", "-flagStr", "test"}, - expected: testFlagSet{ - FlagStr: "test", - FlagBool: true, - }, - }, - "invalid/flagStr/1": { - args: []string{"-flagStr", "-flagBool"}, - panic: true, - }, - "invalid/flagStr/2": { - args: []string{"-flagStr"}, - panic: true, - }, - } { - t.Run(name, func(t *testing.T) { - defer func() { - r := recover() - require.Equal(t, tc.panic, r != nil) - }() - flags := testFlagSet{} - parseFlags(&flags, tc.args) - require.True(t, reflect.DeepEqual(tc.expected, flags)) - }) - } -} diff --git a/internal/toolexec/proxy/generator/main.go b/internal/toolexec/proxy/generator/main.go new file mode 100644 index 00000000..1db20d9c --- /dev/null +++ b/internal/toolexec/proxy/generator/main.go @@ -0,0 +1,315 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +package main + +import ( + "bufio" + "bytes" + "errors" + "flag" + "fmt" + "go/ast" + "go/parser" + "go/token" + "io" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" + + "github.com/dave/jennifer/jen" +) + +type flagSpec struct { + Flag string + Value string + Descr []string +} + +func main() { + var command string + flag.Func("command", "The command to generate a parser for", func(val string) error { + switch val { + case "compile", "link": + command = val + default: + return fmt.Errorf("unsupported command: %q", val) + } + return nil + }) + flag.Parse() + + if command == "" { + log.Fatalln("Missing value for required -command flag") + } + + var ( + goFile = requireEnv("GOFILE") + goPackage = requireEnv("GOPACKAGE") + ) + + cmd := exec.Command("go", "tool", command, "-V=full") + cmd.Env = append(cmd.Env, "LANG=C") + var fullVersion bytes.Buffer + cmd.Stdout = &fullVersion + if err := cmd.Run(); err != nil { + log.Fatalln(err) + } + + version := strings.TrimSpace(fullVersion.String()) + version = version[:strings.LastIndexByte(version, '.')] + + outFile := filepath.Join(goFile, "..", fmt.Sprintf("%s.flags.go", command)) + if content, err := os.ReadFile(outFile); err == nil { + newMajorS, newMinorS, _ := strings.Cut(strings.Fields(version)[2][2:], ".") + newMajor, _ := strconv.Atoi(newMajorS) + newMinor, _ := strconv.Atoi(newMinorS) + + // versionTagRe matches the " version goX.Y" tag that is expected to be present in generated files. + // Example: https://regex101.com/r/MiYpBy/1 + versionTagRe := regexp.MustCompile(fmt.Sprintf(`(?m)"%s version go(\d+)\.(\d+)"`, command)) + if matches := versionTagRe.FindSubmatch(content); len(matches) > 0 { + curMajor, _ := strconv.Atoi(string(matches[1])) + curMinor, _ := strconv.Atoi(string(matches[2])) + + if curMajor > newMajor || (curMajor == newMajor && curMinor > newMinor) { + if os.Getenv("CI") != "" { + log.Fatalf("Generate must be run with go%d.%d or newer (was run with %d.%d)\n", curMajor, curMinor, newMajor, newMinor) + } + log.Printf("Skipping generation of %q, as it was generated against a more recent version of the go %s tool (%d.%d >= %d.%d)\n", outFile, command, curMajor, curMinor, newMajor, newMinor) + return + } + } + } else if !errors.Is(err, os.ErrNotExist) { + log.Fatalln(err) + } + + cmd = exec.Command("go", "tool", command) + cmd.Env = append(cmd.Env, "LANG=C") + var buffer bytes.Buffer + cmd.Stderr = &buffer + _ = cmd.Run() // The command is expected to fail... + + reader := bufio.NewReader(&buffer) + // Ensure the first line looks like usage instructions... + line, _, err := reader.ReadLine() + if err != nil { + log.Fatalln(err) + } + if !bytes.HasPrefix(line, []byte("usage: ")) { + log.Fatalf("Unexpected output from command:\n%s\n", string(line)) + } + + var ( + flags []flagSpec + knownFlags = make(map[string]struct{}) + // reFlag captures the flag and it's argument name (if present), as well as the documentation string that may + // follow it. Example: https://regex101.com/r/vqsECV/1 + reFlag = regexp.MustCompile(`^ (-[^\s]+)(?: ([^\s]+))?(\t.+)?$`) + ) + for { + line, _, err := reader.ReadLine() + if err == io.EOF { + break + } + if err != nil { + log.Fatalln(err) + } + matches := reFlag.FindSubmatch(line) + if len(matches) == 0 { + text := strings.TrimSpace(string(line)) + if text != "" && len(flags) > 0 { + flags[len(flags)-1].Descr = append(flags[len(flags)-1].Descr, text) + } + continue + } + + spec := flagSpec{ + Flag: string(matches[1]), + Value: string(matches[2]), + } + if descr := strings.TrimSpace(string(matches[3])); descr != "" { + spec.Descr = append(spec.Descr, descr) + } + flags = append(flags, spec) + knownFlags[spec.Flag] = struct{}{} + } + + if len(flags) == 0 { + log.Fatalln("No flags found in command usage, this is unexpected!") + } + + fset := token.NewFileSet() + src, err := os.ReadFile(goFile) + if err != nil { + log.Fatalln(err) + } + parsed, err := parser.ParseFile(fset, goFile, src, 0) + if err != nil { + log.Fatalln(err) + } + + typeName := fmt.Sprintf("%sFlagSet", command) + capturedFlags := make(map[string]string) + for _, decl := range parsed.Decls { + decl, ok := decl.(*ast.GenDecl) + if !ok || decl.Tok != token.TYPE { + continue + } + for _, spec := range decl.Specs { + spec, ok := spec.(*ast.TypeSpec) + if !ok || spec.Name.Name != typeName { + continue + } + strct, ok := spec.Type.(*ast.StructType) + if !ok { + log.Fatalf("Expected a struct, got a %T\n", spec) + } + for _, field := range strct.Fields.List { + tag, err := strconv.Unquote(field.Tag.Value) + if err != nil { + log.Fatalln(err) + } + flag, err := strconv.Unquote(strings.TrimPrefix(tag, "ddflag:")) + if err != nil { + log.Fatalln(err) + } + if _, isKnown := knownFlags[flag]; !isKnown { + log.Fatalf("Unknown captured flag: %q\n", flag) + } + capturedFlags[flag] = field.Names[0].Name + } + } + } + if len(capturedFlags) == 0 { + log.Fatalf("Expected fields annotated with the `ddflag:\"-flag\"` tag in the %s struct\n", typeName) + } + + file := jen.NewFile(goPackage) + file.HeaderComment("// Unless explicitly stated otherwise all files in this repository are licensed") + file.HeaderComment("// under the Apache License Version 2.0.") + file.HeaderComment("// This product includes software developed at Datadog (https://www.datadoghq.com/).") + file.HeaderComment("// Copyright 2023-present Datadog, Inc.\n") + file.HeaderComment("// Code generated by 'go generate' DO NOT EDIT.\n") + + file.Func(). + Params(jen.Id("f").Op("*").Id(typeName)). + Id("parse"). + Params(jen.Id("args").Index().String()). + Params( + jen.Index().String(), + jen.Error(), + ). + BlockFunc(func(g *jen.Group) { + g.Id("flagSet"). + Op(":="). + Qual("flag", "NewFlagSet"). + Call( + jen.Lit(version), + jen.Qual("flag", "ContinueOnError"), + ) + + // reDefault captures default values found in flag descriptions. See: https://regex101.com/r/jDEwWQ/1 + reDefault := regexp.MustCompile(`^(.+?)(?:\s+\(default\s+(.+?)\))?$`) + for _, spec := range flags { + fieldName, captured := capturedFlags[spec.Flag] + + var ( + funcName string + strDefault string + defaultValue *jen.Statement + zeroValue *jen.Statement + ) + + descr := strings.Join(spec.Descr, " ") + if matches := reDefault.FindStringSubmatch(descr); matches[2] != "" { + strDefault = matches[2] + descr = matches[1] + } + + switch spec.Value { + case "": + funcName = "Bool" + zeroValue = jen.False() + if strDefault == "" || strDefault == "false" { + defaultValue = jen.False() + } else { + defaultValue = jen.True() + } + case "int": + funcName = "Int" + zeroValue = jen.Lit(0) + if strDefault != "" { + val, err := strconv.Atoi(strDefault) + if err != nil { + log.Fatalf("Invalid default value for an int flag: %s\n", strDefault) + } + defaultValue = jen.Lit(val) + } else { + defaultValue = jen.Lit(0) + } + default: + funcName = "String" + zeroValue = jen.Lit("") + defaultValue = jen.Lit(strDefault) + } + + flagName := jen.Lit(spec.Flag[1:]) + + if funcName == "Bool" && spec.Flag == "-V" { + var handler *jen.Statement + if captured { + handler = jen.Func().Params(jen.String()).Error().Block( + jen.Id("f").Dot(fieldName).Op("=").True(), + jen.Return(jen.Nil()), + ) + } else { + handler = jen.Func().Params(jen.String()).Error().Block(jen.Return(jen.Nil())) + } + g.Id("flagSet").Dot("BoolFunc").Call(flagName, jen.Lit(descr), handler) + } else if captured { + g.Id("flagSet").Dot(funcName+"Var").Call(jen.Op("&").Id("f").Dot(fieldName), flagName, defaultValue, jen.Lit(descr)) + } else { + g.Id("flagSet").Dot(funcName).Call(flagName, zeroValue, jen.Lit(descr)) + } + } + g.Line() + + g.Id("err").Op(":=").Id("flagSet").Dot("Parse").Call(jen.Id("args")) + g.Return( + jen.Id("flagSet").Dot("Args").Call(), + jen.Id("err"), + ) + }) + + out, err := os.Create(outFile) + if err != nil { + log.Fatalln(err) + } + defer out.Close() + + if err := file.Render(out); err != nil { + log.Fatalln(err) + } +} + +func (f *flagSpec) String() string { + if f.Value != "" { + return fmt.Sprintf("%s %s", f.Flag, f.Value) + } + return f.Flag +} + +func requireEnv(name string) string { + val := os.Getenv(name) + if val == "" { + log.Fatalf("Missing environment variable: $%s\n", name) + } + return val +} diff --git a/internal/toolexec/proxy/link.flags.go b/internal/toolexec/proxy/link.flags.go new file mode 100644 index 00000000..8ae2a2fa --- /dev/null +++ b/internal/toolexec/proxy/link.flags.go @@ -0,0 +1,74 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2023-present Datadog, Inc. + +// Code generated by 'go generate' DO NOT EDIT. + +package proxy + +import "flag" + +func (f *linkFlagSet) parse(args []string) ([]string, error) { + flagSet := flag.NewFlagSet("link version go1.23", flag.ContinueOnError) + flagSet.String("B", "", "add an ELF NT_GNU_BUILD_ID note when using ELF; use \"gobuildid\" to generate it from the Go build ID") + flagSet.String("E", "", "set entry symbol name") + flagSet.String("H", "", "set header type") + flagSet.String("I", "", "use linker as ELF dynamic linker") + flagSet.String("L", "", "add specified directory to library path") + flagSet.String("R", "", "set address rounding quantum") + flagSet.Int("T", 0, "set the start address of text symbols") + flagSet.BoolFunc("V", "print version and exit", func(string) error { + f.ShowVersion = true + return nil + }) + flagSet.String("X", "", "add string value definition of the form importpath.name=value") + flagSet.Bool("a", false, "no-op (deprecated)") + flagSet.Bool("asan", false, "enable ASan interface") + flagSet.Bool("aslr", false, "enable ASLR for buildmode=c-shared on windows") + flagSet.String("benchmark", "", "set to 'mem' or 'cpu' to enable phase benchmarking") + flagSet.String("benchmarkprofile", "", "emit phase profiles to base_phase.{cpu,mem}prof") + flagSet.Bool("bindnow", false, "mark a dynamically linked ELF object for immediate function binding") + flagSet.String("buildid", "", "record id as Go toolchain build id") + flagSet.StringVar(&f.BuildMode, "buildmode", "", "set build mode") + flagSet.Bool("c", false, "dump call graph") + flagSet.String("capturehostobjs", "", "capture host object files loaded during internal linking to specified dir") + flagSet.Bool("checklinkname", false, "check linkname symbol references") + flagSet.Bool("compressdwarf", false, "compress DWARF if possible") + flagSet.String("cpuprofile", "", "write cpu profile to file") + flagSet.Bool("d", false, "disable dynamic executable") + flagSet.Bool("debugnosplit", false, "dump nosplit call graph") + flagSet.Int("debugtextsize", 0, "debug text section max size") + flagSet.Int("debugtramp", 0, "debug trampolines") + flagSet.Bool("dumpdep", false, "dump symbol dependency graph") + flagSet.String("extar", "", "archive program for buildmode=c-archive") + flagSet.String("extld", "", "use linker when linking in external mode") + flagSet.String("extldflags", "", "pass flags to external linker") + flagSet.Bool("f", false, "ignore version mismatch") + flagSet.Bool("g", false, "disable go package data checks") + flagSet.Bool("h", false, "halt on error") + flagSet.StringVar(&f.ImportCfg, "importcfg", "", "read import configuration from file") + flagSet.String("installsuffix", "", "set package directory suffix") + flagSet.String("k", "", "set field tracking symbol") + flagSet.String("libgcc", "", "compiler support lib for internal linking; use \"none\" to disable") + flagSet.String("linkmode", "", "set link mode") + flagSet.Bool("linkshared", false, "link against installed Go shared libraries") + flagSet.String("memprofile", "", "write memory profile to file") + flagSet.String("memprofilerate", "", "set runtime.MemProfileRate to rate") + flagSet.Bool("msan", false, "enable MSan interface") + flagSet.Bool("n", false, "no-op (deprecated)") + flagSet.StringVar(&f.Output, "o", "", "write output to file") + flagSet.String("pluginpath", "", "full path name for plugin") + flagSet.Bool("pruneweakmap", false, "prune weak mapinit refs") + flagSet.String("r", "", "set the ELF dynamic linker search path to dir1:dir2:...") + flagSet.Bool("race", false, "enable race detector") + flagSet.Int("randlayout", 0, "randomize function layout") + flagSet.Bool("s", false, "disable symbol table") + flagSet.Int("strictdups", 0, "sanity check duplicate symbol contents during object file reading (1=warn 2=err).") + flagSet.String("tmpdir", "", "use directory for temporary files") + flagSet.Bool("v", false, "print link trace") + flagSet.Bool("w", false, "disable DWARF generation") + + err := flagSet.Parse(args) + return flagSet.Args(), err +} diff --git a/internal/toolexec/proxy/link.go b/internal/toolexec/proxy/link.go index ecf2094f..0f28d872 100644 --- a/internal/toolexec/proxy/link.go +++ b/internal/toolexec/proxy/link.go @@ -10,10 +10,13 @@ import ( "path/filepath" ) +//go:generate go run github.com/DataDog/orchestrion/internal/toolexec/proxy/generator -command=link + type linkFlagSet struct { - BuildMode string `ddflag:"-buildmode"` - ImportCfg string `ddflag:"-importcfg"` - Output string `ddflag:"-o"` + BuildMode string `ddflag:"-buildmode"` + ImportCfg string `ddflag:"-importcfg"` + Output string `ddflag:"-o"` + ShowVersion bool `ddflag:"-V"` } // LinkCommand represents a go tool `link` invocation @@ -28,6 +31,10 @@ func (*LinkCommand) Type() CommandType { return CommandTypeLink } +func (cmd *LinkCommand) ShowVersion() bool { + return cmd.Flags.ShowVersion +} + func (cmd *LinkCommand) Stage() string { return filepath.Base(filepath.Dir(filepath.Dir(cmd.Flags.Output))) } @@ -37,7 +44,9 @@ func parseLinkCommand(args []string) (Command, error) { return nil, errors.New("unexpected number of command arguments") } flags := &linkFlagSet{} - parseFlags(flags, args[1:]) + if _, err := flags.parse(args[1:]); err != nil { + return nil, err + } // The WorkDir is the parent of the stage dir, and the ImportCfg file is directly in the stage dir. workDir := filepath.Dir(filepath.Dir(flags.ImportCfg)) diff --git a/internal/toolexec/proxy/link_test.go b/internal/toolexec/proxy/link_test.go index faea9017..cea2d89c 100644 --- a/internal/toolexec/proxy/link_test.go +++ b/internal/toolexec/proxy/link_test.go @@ -15,16 +15,16 @@ import ( func TestParseLink(t *testing.T) { for name, tc := range map[string]struct { input []string - stage string flags linkFlagSet }{ "version_print": { input: []string{"/path/link", "-V=full"}, - stage: ".", + flags: linkFlagSet{ + ShowVersion: true, + }, }, "link": { input: []string{"/path/link", "-o", "/buildDir/b001/exe/a.out", "-importcfg", "/buildDir/b001/importcfg.link", "-buildmode=exe", "/buildDir/b001/_pkg_.a"}, - stage: "b001", flags: linkFlagSet{ ImportCfg: "/buildDir/b001/importcfg.link", Output: "/buildDir/b001/exe/a.out", @@ -36,7 +36,6 @@ func TestParseLink(t *testing.T) { cmd, err := parseLinkCommand(tc.input) require.NoError(t, err) require.Equal(t, CommandTypeLink, cmd.Type()) - require.Equal(t, tc.stage, cmd.Stage()) c := cmd.(*LinkCommand) require.True(t, reflect.DeepEqual(tc.flags, c.Flags)) }) diff --git a/internal/toolexec/proxy/proxy.go b/internal/toolexec/proxy/proxy.go index b5c038d2..2f86dfc1 100644 --- a/internal/toolexec/proxy/proxy.go +++ b/internal/toolexec/proxy/proxy.go @@ -10,7 +10,6 @@ import ( "fmt" "os" "os/exec" - "path/filepath" ) type ( @@ -26,10 +25,7 @@ type ( // Args are all the command arguments, starting from the Go tool command Args() []string ReplaceParam(param string, val string) error - // Stage returns the build stage of the command. Each stage usually associated - // to a specific package and is named using the `bXXX` format, where `X` are numbers. - // Stage b001 is the final stage of the go build process - Stage() string + // Type represents the go tool command type (compile, link, asm, etc.) Type() CommandType @@ -44,11 +40,6 @@ type ( // processors will be invoked. CommandProcessor[T Command] func(T) error - commandFlagSet struct { - Output string `ddflag:"-o"` - Version string `ddflag:"-V"` - } - // command is the default unknown command type // Can be used to compose specific Command implementations command struct { @@ -56,7 +47,6 @@ type ( // paramPos is the index in args of the *value* provided for the parameter stored in the key paramPos map[string]int onClose []func() error - flags commandFlagSet } ) @@ -89,8 +79,6 @@ func NewCommand(args []string) command { cmd.paramPos[v] = pos + 1 } - parseFlags(&cmd.flags, args) - return cmd } @@ -109,10 +97,6 @@ func (cmd *command) Close() error { return nil } -func (cmd *command) ShowVersion() bool { - return cmd.flags.Version == "full" -} - // ReplaceParam will replace any parameter of the command provided it is found // A parameter can be a flag, an option, a value, etc func (cmd *command) ReplaceParam(param string, val string) error { @@ -162,10 +146,6 @@ func MustRunCommand(cmd Command, opts ...RunCommandOption) { panic(err) } -func (cmd *command) Stage() string { - return filepath.Base(filepath.Dir(cmd.flags.Output)) -} - func (*command) Type() CommandType { return CommandTypeOther } @@ -173,3 +153,7 @@ func (*command) Type() CommandType { func (cmd *command) Args() []string { return cmd.args } + +func (*command) ShowVersion() bool { + return false +} diff --git a/internal/toolexec/proxy/proxy_test.go b/internal/toolexec/proxy/proxy_test.go index ff2d2fb3..bf50337a 100644 --- a/internal/toolexec/proxy/proxy_test.go +++ b/internal/toolexec/proxy/proxy_test.go @@ -9,7 +9,7 @@ import ( "reflect" "testing" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" "github.com/stretchr/testify/require" ) @@ -56,25 +56,21 @@ func TestParseCommand(t *testing.T) { expectedStage string }{ "unknown": { - input: []string{"unknown", "irrelevant"}, - expectedType: proxy.CommandTypeOther, - expectedStage: ".", + input: []string{"unknown", "irrelevant"}, + expectedType: proxy.CommandTypeOther, }, "compile": { - input: []string{"compile", "-o", "b002/a.out", "main.go"}, - expectedType: proxy.CommandTypeCompile, - expectedStage: "b002", + input: []string{"compile", "-o", "b002/a.out", "main.go"}, + expectedType: proxy.CommandTypeCompile, }, "link": { - input: []string{"link", "-o", "b001/out/a.out", "main.go"}, - expectedType: proxy.CommandTypeLink, - expectedStage: "b001", + input: []string{"link", "-o", "b001/out/a.out", "main.go"}, + expectedType: proxy.CommandTypeLink, }, } { t.Run(name, func(t *testing.T) { cmd := proxy.MustParseCommand(tc.input) require.Equal(t, tc.expectedType, cmd.Type()) - require.Equal(t, tc.expectedStage, cmd.Stage()) require.True(t, reflect.DeepEqual(tc.input, cmd.Args())) }) } diff --git a/internal/toolexec/version.go b/internal/toolexec/version.go index be718a69..30a27e0d 100644 --- a/internal/toolexec/version.go +++ b/internal/toolexec/version.go @@ -12,11 +12,11 @@ import ( "os/exec" "strings" - "github.com/datadog/orchestrion/internal/jobserver" - "github.com/datadog/orchestrion/internal/jobserver/buildid" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/jobserver" + "github.com/DataDog/orchestrion/internal/jobserver/buildid" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" ) // ComputeVersion returns the complete version string to be produced when the toolexec is invoked diff --git a/internal/toolexec/version_test.go b/internal/toolexec/version_test.go index a678ece3..6b5baeb0 100644 --- a/internal/toolexec/version_test.go +++ b/internal/toolexec/version_test.go @@ -15,9 +15,9 @@ import ( "strings" "testing" - "github.com/datadog/orchestrion/internal/injector/builtin" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/toolexec/proxy" + "github.com/DataDog/orchestrion/internal/injector/builtin" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/toolexec/proxy" "github.com/otiai10/copy" "github.com/stretchr/testify/require" ) @@ -34,6 +34,7 @@ func Test(t *testing.T) { tmp := t.TempDir() runGo(t, tmp, "mod", "init", "github.com/DataDog/phony/package") + runGo(t, tmp, "mod", "edit", "-replace", fmt.Sprintf("github.com/DataDog/orchestrion=%s", rootDir)) getArgs := []string{"get"} for _, pkg := range builtin.InjectedPaths { @@ -76,7 +77,7 @@ func Test(t *testing.T) { require.NoError(t, os.WriteFile(beaconFile, []byte("package instrument\nconst BEACON = 42"), 0o644)) // Replace the orchestrion package with the copy we just made... - runGo(t, tmp, "mod", "edit", "-replace", fmt.Sprintf("github.com/datadog/orchestrion=%s", copyDir)) + runGo(t, tmp, "mod", "edit", "-replace", fmt.Sprintf("github.com/DataDog/orchestrion=%s", copyDir)) runGo(t, tmp, "mod", "tidy") // The hash of the dependency has changed... go list would complain... updated := inDir(t, tmp, func() string { v, err := ComputeVersion(cmd) diff --git a/internal/version/version.go b/internal/version/version.go index 19deef61..8c58d3db 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -6,4 +6,4 @@ package version // Tag specifies the current release tag. It needs to be manually updated. -const Tag = "v0.8.1-rc.1" +const Tag = "v0.8.1" diff --git a/main.go b/main.go index 494bd24d..5e9ab306 100644 --- a/main.go +++ b/main.go @@ -17,10 +17,10 @@ import ( "strconv" "strings" - "github.com/datadog/orchestrion/internal/cmd" - "github.com/datadog/orchestrion/internal/jobserver/client" - "github.com/datadog/orchestrion/internal/log" - "github.com/datadog/orchestrion/internal/version" + "github.com/DataDog/orchestrion/internal/cmd" + "github.com/DataDog/orchestrion/internal/jobserver/client" + "github.com/DataDog/orchestrion/internal/log" + "github.com/DataDog/orchestrion/internal/version" "github.com/urfave/cli/v2" ) diff --git a/samples/go.mod b/samples/go.mod index 169e43f3..503d7255 100644 --- a/samples/go.mod +++ b/samples/go.mod @@ -1,16 +1,16 @@ -module github.com/datadog/orchestrion/samples +module github.com/DataDog/orchestrion/samples go 1.22.6 -replace github.com/datadog/orchestrion => ../ +replace github.com/DataDog/orchestrion => ../ require ( + github.com/DataDog/orchestrion v0.0.0-00010101000000-000000000000 github.com/IBM/sarama v1.43.3 github.com/Shopify/sarama v1.38.1 github.com/aws/aws-sdk-go v1.55.5 github.com/aws/aws-sdk-go-v2 v1.30.4 github.com/aws/aws-sdk-go-v2/service/s3 v1.60.1 - github.com/datadog/orchestrion v0.0.0-00010101000000-000000000000 github.com/gin-gonic/gin v1.10.0 github.com/go-chi/chi/v5 v5.1.0 github.com/go-redis/redis/v7 v7.4.1 @@ -306,7 +306,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240823204242-4ba0660f739c // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240823204242-4ba0660f739c // indirect google.golang.org/protobuf v1.34.2 // indirect - gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2 // indirect + gopkg.in/DataDog/dd-trace-go.v1 v1.68.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/samples/go.sum b/samples/go.sum index d53f9bb0..657f99f9 100644 --- a/samples/go.sum +++ b/samples/go.sum @@ -1261,8 +1261,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2 h1:EVPVNIE/pORPQ8i1lS1IzrvA9rWw3ZPoKAATqkLlAqE= -gopkg.in/DataDog/dd-trace-go.v1 v1.68.0-rc.2/go.mod h1:mkZpWVLO/ERW5NqlW+w5d8waQKNvMSTUQLJfoI0vlvw= +gopkg.in/DataDog/dd-trace-go.v1 v1.68.0 h1:8WPoOHJcMAtcxTVKM0DYnFweBjxxfNit3Sjo/rf+Hkw= +gopkg.in/DataDog/dd-trace-go.v1 v1.68.0/go.mod h1:mkZpWVLO/ERW5NqlW+w5d8waQKNvMSTUQLJfoI0vlvw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/samples/orchestrion.tool.go b/samples/orchestrion.tool.go index 5bfeb2bc..e110df6f 100644 --- a/samples/orchestrion.tool.go +++ b/samples/orchestrion.tool.go @@ -13,4 +13,4 @@ package tools -import _ "github.com/datadog/orchestrion" +import _ "github.com/DataDog/orchestrion" diff --git a/tools.go b/tools.go index 2686d8f6..011379ad 100644 --- a/tools.go +++ b/tools.go @@ -13,5 +13,5 @@ import ( _ "github.com/google/go-licenses/v2" // Instrumentation packages - _ "github.com/datadog/orchestrion/internal/injector/builtin" + _ "github.com/DataDog/orchestrion/internal/injector/builtin" )