Skip to content

Commit

Permalink
fix: case-based name conflict with DataDog (#288)
Browse files Browse the repository at this point in the history
Case-conflicting import paths cause issues when using `go mod vendor` as
the layout on case-sensitive file systems is different from that on
case-insensitive file system. This is a long-known issue with the Go
toolchain, however fixing this is non-trivial and could have undesirable
consequences.

Since the capitalized form of `DataDog` (sic) is most common today,
renaming the `orchestrion` module is the most pragramtic solution today.

Caused-By golang/go#38342
Fixes #287
  • Loading branch information
RomainMuller authored Sep 23, 2024
1 parent 87351e4 commit c6451d2
Show file tree
Hide file tree
Showing 108 changed files with 281 additions and 265 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <details><summary>Optional: project <tt>go.mod</tt> registration</summary>
Expand All @@ -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@<current-release>` to make sure the project version corresponds to the
> 2. Run `go get github.com/DataDog/orchstrion@<current-release>` 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
>
Expand All @@ -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/[email protected]
│ 2. running go get github.com/DataDog/[email protected]
│ 3. running go mod tidy │
│ │
│ You should commit the resulting changes into your source control system. │
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions _integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ module orchestrion/integration

go 1.22.6

replace github.com/datadog/orchestrion => ../
replace github.com/DataDog/orchestrion => ../

require (
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
github.com/aws/aws-sdk-go-v2 v1.30.4
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
Expand Down
2 changes: 1 addition & 1 deletion _integration-tests/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
package tools

import (
_ "github.com/datadog/orchestrion"
_ "github.com/DataDog/orchestrion"
)
2 changes: 1 addition & 1 deletion docs/content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/datadog/orchestrion
module github.com/DataDog/orchestrion

go 1.22.6

Expand All @@ -19,6 +19,7 @@ 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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion instrument/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion instrument/instrument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package cmd

import (
"github.com/datadog/orchestrion/internal/pin"
"github.com/DataDog/orchestrion/internal/pin"
"github.com/urfave/cli/v2"
)

Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"),
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/toolexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/ensure/integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions internal/ensure/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand All @@ -63,21 +71,21 @@ 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,
os.WriteFile(filepath.Join(wd, "tools.go"), []byte(strings.Join([]string{
"//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,
Expand Down
8 changes: 4 additions & 4 deletions internal/ensure/requiredversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<replaced>"
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 12 additions & 5 deletions internal/ensure/requiredversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/filelock/filelock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Loading

0 comments on commit c6451d2

Please sign in to comment.