blob: d7a2eac62b2e609b2226e28b811e6ed77a06a7c5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package tvmtool
import (
"fmt"
"os"
)
const (
DeployEndpointEnvKey = "DEPLOY_TVM_TOOL_URL"
DeployTokenEnvKey = "TVMTOOL_LOCAL_AUTHTOKEN"
)
// NewDeployClient method creates a new tvmtool client for Deploy environment.
// You must reuse it to prevent connection/goroutines leakage.
func NewDeployClient(opts ...Option) (*Client, error) {
baseURI := os.Getenv(DeployEndpointEnvKey)
if baseURI == "" {
return nil, fmt.Errorf("empty tvmtool url (looked at ENV[%s])", DeployEndpointEnvKey)
}
authToken := os.Getenv(DeployTokenEnvKey)
if authToken == "" {
return nil, fmt.Errorf("empty auth token (looked at ENV[%s])", DeployTokenEnvKey)
}
opts = append([]Option{WithAuthToken(authToken)}, opts...)
return NewClient(
baseURI,
opts...,
)
}
|