Use corso version with event reporting (#1721)

## Description

Add version of the current binary when reporting.

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [x] 🐹 Trivial/Minor

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* https://github.com/alcionai/corso/issues/1594

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abin Simon 2022-12-08 13:37:52 +05:30 committed by GitHub
parent 95dda0425b
commit 6ee121a70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 6 deletions

View File

@ -492,7 +492,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
CORSO_BUILD_LDFLAGS=-X 'github.com/alcionai/corso/src/internal/events.RudderStackWriteKey=${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}' -X 'github.com/alcionai/corso/src/internal/events.RudderStackDataPlaneURL=${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}' -X 'github.com/alcionai/corso/src/cli.version=${{ needs.SetEnv.outputs.version }}'
CORSO_BUILD_LDFLAGS=-X 'github.com/alcionai/corso/src/internal/events.RudderStackWriteKey=${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}' -X 'github.com/alcionai/corso/src/internal/events.RudderStackDataPlaneURL=${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}' -X 'github.com/alcionai/corso/src/internal/version.Version=${{ needs.SetEnv.outputs.version }}'
# use the github cache
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@ -13,7 +13,7 @@ builds:
- goos: windows
goarch: arm64
ldflags:
- -X 'github.com/alcionai/corso/src/cli.version={{.Env.CORSO_VERSION}}'
- -X 'github.com/alcionai/corso/src/internal/version.Version={{.Env.CORSO_VERSION}}'
- -X 'github.com/alcionai/corso/src/internal/events.RudderStackWriteKey={{.Env.RUDDERSTACK_CORSO_WRITE_KEY}}'
- -X 'github.com/alcionai/corso/src/internal/events.RudderStackDataPlaneURL={{.Env.RUDDERSTACK_CORSO_DATA_PLANE_URL}}'

View File

@ -16,11 +16,10 @@ import (
"github.com/alcionai/corso/src/cli/repo"
"github.com/alcionai/corso/src/cli/restore"
"github.com/alcionai/corso/src/internal/observe"
"github.com/alcionai/corso/src/internal/version"
"github.com/alcionai/corso/src/pkg/logger"
)
var version = "dev"
// ------------------------------------------------------------------------------------------
// Corso Command
// ------------------------------------------------------------------------------------------
@ -40,7 +39,7 @@ var corsoCmd = &cobra.Command{
func handleCorsoCmd(cmd *cobra.Command, args []string) error {
v, _ := cmd.Flags().GetBool("version")
if v {
print.Outf(cmd.Context(), "Corso\nversion: "+version)
print.Outf(cmd.Context(), "Corso\nversion: "+version.Version)
return nil
}

View File

@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
analytics "github.com/rudderlabs/analytics-go"
"github.com/alcionai/corso/src/internal/version"
"github.com/alcionai/corso/src/pkg/control"
"github.com/alcionai/corso/src/pkg/logger"
"github.com/alcionai/corso/src/pkg/storage"
@ -98,7 +99,7 @@ func NewBus(ctx context.Context, s storage.Storage, tenID string, opts control.O
client: client,
repoID: repoHash(s),
tenant: tenantHash(tenID),
version: "vTODO", // TODO: corso versioning implementation
version: version.Version,
}, nil
}

View File

@ -0,0 +1,3 @@
package version
var Version = "dev"