Skip to content

Commit e074cd4

Browse files
feat(client): add support for reading base URL from environment variable
1 parent f2e2e2e commit e074cd4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

client.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,23 @@ type Client struct {
2929
Users *UserService
3030
}
3131

32-
// DefaultClientOptions read from the environment (GITPOD_API_KEY). This should be
33-
// used to initialize new clients.
32+
// DefaultClientOptions read from the environment (GITPOD_API_KEY,
33+
// GITPOD_BASE_URL). This should be used to initialize new clients.
3434
func DefaultClientOptions() []option.RequestOption {
3535
defaults := []option.RequestOption{option.WithEnvironmentProduction()}
36+
if o, ok := os.LookupEnv("GITPOD_BASE_URL"); ok {
37+
defaults = append(defaults, option.WithBaseURL(o))
38+
}
3639
if o, ok := os.LookupEnv("GITPOD_API_KEY"); ok {
3740
defaults = append(defaults, option.WithBearerToken(o))
3841
}
3942
return defaults
4043
}
4144

4245
// NewClient generates a new client with the default option read from the
43-
// environment (GITPOD_API_KEY). The option passed in as arguments are applied
44-
// after these default arguments, and all option will be passed down to the
45-
// services and requests that this client makes.
46+
// environment (GITPOD_API_KEY, GITPOD_BASE_URL). The option passed in as arguments
47+
// are applied after these default arguments, and all option will be passed down to
48+
// the services and requests that this client makes.
4649
func NewClient(opts ...option.RequestOption) (r *Client) {
4750
opts = append(DefaultClientOptions(), opts...)
4851

0 commit comments

Comments
 (0)