Skip to content

Commit

Permalink
Bump getPackageVersion() to v0.5.0, allow : in source tag normali…
Browse files Browse the repository at this point in the history
…zation (#24)

## Problem
We want to release a new patch version of the Go SDK, and we need to
bump the version for the user-agent. We also want to allow source tag
normalization to accept `:`.

## Solution

- Update `getPackageVersion` to `v0.5.0`.
- Update `buildSourceTagField()` to allow `:` as a character.

The new patch includes:
- Fixing context.Context being a pointer instead of value in our
networking functions.
- Adding optional configurations for headers / metadata in REST / gRPC
operations.
- Fixing issues with json marshaling in our structs.
- Adding consistent error handling to control plane operations. 

## Type of Change

- [] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [] None of the above: chore for version bumping)

## Test Plan
user-agent values can be validated through DataDog, unit test to cover
the addition to source tag normalization
  • Loading branch information
austin-denoble authored Jun 8, 2024
1 parent b471e0c commit 257e9f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/useragent/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func getPackageVersion() string {
// update at release time
return "v0.4.2-pre"
return "v0.5.0"
}

func BuildUserAgent(sourceTag string) string {
Expand Down Expand Up @@ -36,7 +36,7 @@ func buildSourceTagField(userAgent string) string {
// Limit charset to [a-z0-9_ ]
var strBldr strings.Builder
for _, char := range userAgent {
if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || char == '_' || char == ' ' {
if (char >= 'a' && char <= 'z') || (char >= '0' && char <= '9') || char == '_' || char == ' ' || char == ':' {
strBldr.WriteRune(char)
}
}
Expand Down
5 changes: 5 additions & 0 deletions internal/useragent/useragent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ func TestBuildUserAgentSourceTagIsNormalized(t *testing.T) {
if !strings.Contains(result, "source_tag=my_source_tag") {
t.Errorf("BuildUserAgent(\"%s\"): expected user-agent to contain 'source_tag=my_source_tag_123', but got %s", sourceTag, result)
}

sourceTag = " My Source Tag 123 : !! "
if !strings.Contains(result, "source_tag=my_source_tag:") {
t.Errorf("BuildUserAgent(\"%s\"): expected user-agent to contain 'source_tag=my_source_tag_123', but got %s", sourceTag, result)
}
}

0 comments on commit 257e9f6

Please sign in to comment.