Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions ddtrace/v1.go

This file was deleted.

50 changes: 0 additions & 50 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
package version

import (
"runtime/debug"
"strconv"
"strings"
"sync"

"golang.org/x/mod/semver"
)
Expand All @@ -36,56 +34,8 @@ var (
Patch int
// RC is the current release candidate version number
RC int
// once is used to ensure that the v1 version is only found once
once sync.Once
)

func FindV1Version() (string, bool, bool) {
once.Do(func() {
info, ok := debug.ReadBuildInfo()
if !ok {
return
}
v1Tag = findV1Version(info.Deps)
})
if v1Tag == nil {
return "", false, false
}
return v1Tag.Version, v1Tag.Transitional, true
}

func init() {
// Check if we are using a transitional v1.74.x or later version
vt, _, found := FindV1Version()
if found {
Tag = vt
}
v := parseVersion(Tag)
Major, Minor, Patch, RC = v.Major, v.Minor, v.Patch, v.RC
}

func findV1Version(deps []*debug.Module) *v1version {
var version string
for _, dep := range deps {
if dep.Path != "gopkg.in/DataDog/dd-trace-go.v1" {
continue
}
version = dep.Version
break
}
if version == "" {
return nil
}
vt := &v1version{
Version: version,
}
v := parseVersion(vt.Version)
if v.Major == 1 && v.Minor >= 74 {
vt.Transitional = true
}
return vt
}

type version struct {
Major int
Minor int
Expand Down
62 changes: 0 additions & 62 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package version
import (
"bytes"
"os/exec"
"runtime/debug"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -55,67 +54,6 @@ func unixDate(u string) (time.Time, error) {
return time.Unix(sec, 0), nil
}

func TestFindV1Version(t *testing.T) {
tests := []struct {
deps []*debug.Module
expected *v1version
}{
{
deps: []*debug.Module{
{Path: "gopkg.in/DataDog/dd-trace-go.v1", Version: "v1.2.3-rc.12"},
},
expected: &v1version{
Version: "v1.2.3-rc.12",
},
},
{
deps: []*debug.Module{
{Path: "gopkg.in/DataDog/dd-trace-go.v1", Version: "v1.74.0"},
},
expected: &v1version{
Version: "v1.74.0",
Transitional: true,
},
},
{
deps: []*debug.Module{
{Path: "gopkg.in/DataDog/dd-trace-go.v1", Version: "v1.73.1"},
},
expected: &v1version{
Version: "v1.73.1",
},
},
{
deps: []*debug.Module{},
expected: nil,
},
{
deps: []*debug.Module{
{Path: "github.com/DataDog/dd-trace-go/v2", Version: "v2.0.0"},
},
expected: nil,
},
}
for _, c := range tests {
vt := findV1Version(c.deps)
if c.expected == nil {
if vt != nil {
t.Fatalf("got %v, expected nil", vt)
}
continue
}
if vt == nil {
t.Fatalf("got nil, expected *v1version")
}
if vt.Version != c.expected.Version {
t.Fatalf("got %s, expected %s", vt.Version, c.expected.Version)
}
if vt.Transitional != c.expected.Transitional {
t.Fatalf("got %t, expected %t", vt.Transitional, c.expected.Transitional)
}
}
}

func TestParseVersion(t *testing.T) {
tc := []struct {
version string
Expand Down
Loading