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
1 change: 0 additions & 1 deletion .github/actions/go_init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ runs:
git status
exit 1
fi
cat cmd/commit.txt
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ gon
go.work

dist/
tracing/commit.txt
cmd/commit.txt
output
.DS_Store
.terraform
Expand Down
12 changes: 5 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
version: 2
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- binary: overmind
id: overmind
Expand All @@ -15,12 +8,17 @@ builds:
goos:
- linux
- windows
# Set the version where the binary will look it up (ServiceVersion) without ruining the flags goreleaser is setting
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser -X github.com/overmindtech/cli/tracing.ServiceVersion={{.Version}}
- binary: overmind
id: overmind-macos
env:
- CGO_ENABLED=0
goos:
- darwin
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser -X github.com/overmindtech/cli/tracing.ServiceVersion={{.Version}}

# For now we are going to disable signing MacOS packages. This works on Dylan's
# person laptop, but we haven't worked out a way to get this set up in a github
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Additionally a community maintained package can be found in the [aur](https://au

### ASDF

Overmind can be instaled using [asdf](https://asdf-vm.com/):
Overmind can be installed using [asdf](https://asdf-vm.com/):

```shell
# Add the plugin
Expand Down
5 changes: 3 additions & 2 deletions cmd/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/google/uuid"
"github.com/overmindtech/aws-source/proc"
"github.com/overmindtech/cli/tfutils"
"github.com/overmindtech/cli/tracing"
"github.com/overmindtech/discovery"
"github.com/overmindtech/pterm"
"github.com/overmindtech/sdp-go"
Expand Down Expand Up @@ -62,7 +63,7 @@ func StartLocalSources(ctx context.Context, oi sdp.OvermindInstance, token *oaut

p.Go(func() (*discovery.Engine, error) {
ec := discovery.EngineConfig{
Version: fmt.Sprintf("cli-%v", cliVersion),
Version: fmt.Sprintf("cli-%v", tracing.ServiceVersion),
EngineType: "cli-stdlib",
SourceName: fmt.Sprintf("stdlib-source-%v", hostname),
SourceUUID: uuid.New(),
Expand Down Expand Up @@ -131,7 +132,7 @@ func StartLocalSources(ctx context.Context, oi sdp.OvermindInstance, token *oaut
}
ec := discovery.EngineConfig{
EngineType: "cli-aws",
Version: fmt.Sprintf("cli-%v", cliVersion),
Version: fmt.Sprintf("cli-%v", tracing.ServiceVersion),
SourceName: fmt.Sprintf("aws-source-%v", hostname),
SourceUUID: uuid.New(),
App: oi.ApiUrl.Host,
Expand Down
6 changes: 1 addition & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ import (
"golang.org/x/oauth2"
)

//go:generate sh -c "echo -n $(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD) > commit.txt"
//go:embed commit.txt
var cliVersion string

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "overmind",
Expand All @@ -49,7 +45,7 @@ confidence.
This CLI will prompt you for authentication using Overmind's OAuth service,
however it can also be configured to use an API key by setting the OVM_API_KEY
environment variable.`,
Version: cliVersion,
Version: tracing.ServiceVersion,
SilenceUsage: true,
PreRun: PreRunSetup,
}
Expand Down
16 changes: 11 additions & 5 deletions tracing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ import (
"go.opentelemetry.io/otel/trace"
)

//go:generate sh -c "echo -n $(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD) > commit.txt"
//go:embed commit.txt
var instrumentationVersion string
// ServiceVersion is the version of the service. This will be overridden by the
// build system, using:
// go build -ldflags "-X github.com/overmindtech/api-server/tracing.ServiceVersion=$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)" -o your-app
//
// This allows our change detection workflow to work correctly. If we were
// embedding the version here each time we would always produce a slightly
// different compiled binary, and therefore it would look like there was a
// change each time
var ServiceVersion = "dev"

const instrumentationName = "github.com/overmindtech/cli"

var tracer = otel.GetTracerProvider().Tracer(
instrumentationName,
trace.WithInstrumentationVersion(instrumentationVersion),
trace.WithInstrumentationVersion(ServiceVersion),
trace.WithSchemaURL(semconv.SchemaURL),
)

Expand All @@ -53,7 +59,7 @@ func tracingResource() *resource.Resource {
// Add your own custom attributes to identify your application
resource.WithAttributes(
semconv.ServiceNameKey.String("overmind-cli"),
semconv.ServiceVersionKey.String(instrumentationVersion),
semconv.ServiceVersionKey.String(ServiceVersion),
),
)
if err != nil {
Expand Down
Loading