44 "context"
55 "crypto/tls"
66 "errors"
7- "fmt"
8- "net/url"
97 "time"
108
119 "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry"
@@ -38,7 +36,7 @@ type Options struct {
3836
3937 // The hostport to use when connecting to the cloud operations API.
4038 // If not provided, the default hostport of `saas-api.tmprl.cloud:443` will be used.
41- HostPort url. URL
39+ HostPort string
4240
4341 // Allow the client to connect to the cloud operations API using an insecure connection.
4442 // This should only be used for testing purposes.
@@ -83,23 +81,18 @@ func (r staticAPIKeyReader) GetAPIKey(ctx context.Context) (string, error) {
8381}
8482
8583func (o * Options ) compute () (
86- hostPort url. URL ,
84+ hostPort string ,
8785 grpcDialOptions []grpc.DialOption ,
8886 err error ,
8987) {
88+ hostPort = o .HostPort
89+ if hostPort == "" {
90+ // set the default host port if not provided
91+ hostPort = defaultCloudOpsAPIHostPort
92+ }
9093
94+ // setup the grpc dial options
9195 grpcDialOptions = make ([]grpc.DialOption , 0 , len (o .GRPCDialOptions )+ 4 )
92- // set the default host port if not provided
93- if o .HostPort .String () == "" {
94- var defaultHostPort * url.URL
95- defaultHostPort , err = url .Parse (defaultCloudOpsAPIHostPort )
96- if err != nil {
97- return url.URL {}, nil , fmt .Errorf ("failed to parse default host port: %w" , err )
98- }
99- hostPort = * defaultHostPort
100- } else {
101- hostPort = o .HostPort
102- }
10396
10497 var transport credentials.TransportCredentials
10598 // setup the transport
@@ -115,7 +108,7 @@ func (o *Options) compute() (
115108 )
116109
117110 if o .APIKey != "" && o .APIKeyReader != nil {
118- return url. URL {} , nil , errors .New ("only one of APIKey and APIKeyReader can be provided" )
111+ return "" , nil , errors .New ("only one of APIKey and APIKeyReader can be provided" )
119112 }
120113 // setup the api key credentials
121114 creds := apikeyCreds {
@@ -127,7 +120,7 @@ func (o *Options) compute() (
127120 creds .reader = o .APIKeyReader
128121 }
129122 if creds .reader == nil {
130- return url. URL {} , nil , errors .New ("either APIKey or APIKeyReader must be provided" )
123+ return "" , nil , errors .New ("either APIKey or APIKeyReader must be provided" )
131124 } else {
132125 grpcDialOptions = append (grpcDialOptions ,
133126 grpc .WithPerRPCCredentials (creds ),
0 commit comments