File tree Expand file tree Collapse file tree 6 files changed +25
-5
lines changed
github.com/conductorone/conductorone-sdk-go Expand file tree Collapse file tree 6 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ func main() {
2121 // Notify the channel for specified signals
2222 signal .Notify (signalCh , os .Interrupt , syscall .SIGTERM )
2323
24- ctx , cancel := context .WithCancel (context .Background ())
24+ ctx := context .WithValue (context .Background (), client .VersionKey , version )
25+ ctx , cancel := context .WithCancel (ctx )
2526
2627 go func () {
2728 // Block until a signal is received
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ require (
1111
1212require (
1313 github.com/conductorone/baton-sdk v0.2.35
14- github.com/conductorone/conductorone-sdk-go v1.22 .0
14+ github.com/conductorone/conductorone-sdk-go v1.23 .0
1515 github.com/pterm/pterm v0.12.62
1616 github.com/toqueteos/webbrowser v1.2.0
1717 github.com/xhit/go-str2duration/v2 v2.1.0
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
3030github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f /go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc =
3131github.com/conductorone/baton-sdk v0.2.35 h1:aSdNvlM5HMti8WdhotrXTHWs+b+BmSqMxtGwsSUFxjY =
3232github.com/conductorone/baton-sdk v0.2.35 /go.mod h1:hmd/Oz3DPIKD+9QmkusZaA18ZoiinnTDdrxh2skcdUc =
33- github.com/conductorone/conductorone-sdk-go v1.22 .0 h1:sz9nz/85YZ0pJ/U3b63QEzE3WMSz6HuCjRTi/kb3mbU =
34- github.com/conductorone/conductorone-sdk-go v1.22 .0 /go.mod h1:vr3946WqFYEpOuIGy/TqXkarhhCzHSKsmXXsxCmeIj8 =
33+ github.com/conductorone/conductorone-sdk-go v1.23 .0 h1:xRWsFNztcFEx4w+e1RRNbUyKaXzrIXk8htASQMAE39g =
34+ github.com/conductorone/conductorone-sdk-go v1.23 .0 /go.mod h1:vr3946WqFYEpOuIGy/TqXkarhhCzHSKsmXXsxCmeIj8 =
3535github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw =
3636github.com/containerd/console v1.0.3 /go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U =
3737github.com/cpuguy83/go-md2man/v2 v2.0.3 /go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o =
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package client
22
33import (
44 "context"
5+ "fmt"
56 "net/http"
67 "net/url"
78 "strconv"
@@ -16,6 +17,10 @@ import (
1617
1718const ConeClientID = "2RGdOS94VDferT9e80mdgntl36K"
1819
20+ type contextKey string
21+
22+ const VersionKey contextKey = "version"
23+
1924type client struct {
2025 httpClient * http.Client
2126 clientName string
@@ -132,9 +137,16 @@ func New(
132137 }
133138 c .baseURL = & apiURL
134139
140+ var version = "dev"
141+
142+ if v := ctx .Value (VersionKey ).(string ); v != "" {
143+ version = v
144+ }
145+
135146 c .sdk = sdk .New (
136147 sdk .WithClient (uclient ),
137148 sdk .WithServerURL (apiURL .String ()),
149+ sdk .WithExtraUserAgent (fmt .Sprintf ("cone/%s" , version )),
138150 )
139151
140152 return c , nil
Original file line number Diff line number Diff line change 44 "context"
55 "crypto/tls"
66 "errors"
7+ "fmt"
78 "net/http"
89 "net/url"
910 "strings"
@@ -33,6 +34,12 @@ func WithTenant(input string) (SDKOption, error) {
3334 return func (api * ConductoroneAPI ) {}, nil
3435}
3536
37+ func WithExtraUserAgent (userAgent string ) SDKOption {
38+ return func (sdk * ConductoroneAPI ) {
39+ sdk .sdkConfiguration .UserAgent = fmt .Sprintf ("%s %s" , userAgent , sdk .sdkConfiguration .UserAgent )
40+ }
41+ }
42+
3643type CustomSDKOption func (* CustomOptions )
3744
3845func WithTenantCustom (input string ) (CustomSDKOption , error ) {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ github.com/cenkalti/backoff/v4
2828github.com/conductorone/baton-sdk/pb/c1/connector/v2
2929github.com/conductorone/baton-sdk/pkg/crypto/providers
3030github.com/conductorone/baton-sdk/pkg/crypto/providers/jwk
31- # github.com/conductorone/conductorone-sdk-go v1.22 .0
31+ # github.com/conductorone/conductorone-sdk-go v1.23 .0
3232## explicit; go 1.21
3333github.com/conductorone/conductorone-sdk-go
3434github.com/conductorone/conductorone-sdk-go/internal/hooks
You can’t perform that action at this time.
0 commit comments