aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/yandex/tvm/tvmtool/qloud.go
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
committerqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
commit22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch)
treebffa27765faf54126ad44bcafa89fadecb7a73d7 /library/go/yandex/tvm/tvmtool/qloud.go
parent332b99e2173f0425444abb759eebcb2fafaa9209 (diff)
downloadydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz
validate canons without yatest_common
Diffstat (limited to 'library/go/yandex/tvm/tvmtool/qloud.go')
-rw-r--r--library/go/yandex/tvm/tvmtool/qloud.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/library/go/yandex/tvm/tvmtool/qloud.go b/library/go/yandex/tvm/tvmtool/qloud.go
new file mode 100644
index 0000000000..4dcf0648db
--- /dev/null
+++ b/library/go/yandex/tvm/tvmtool/qloud.go
@@ -0,0 +1,32 @@
+package tvmtool
+
+import (
+ "fmt"
+ "os"
+)
+
+const (
+ QloudEndpointEnvKey = "QLOUD_TVM_INTERFACE_ORIGIN"
+ QloudTokenEnvKey = "QLOUD_TVM_TOKEN"
+ QloudDefaultEndpoint = "http://localhost:1"
+)
+
+// NewQloudClient method creates a new tvmtool client for Qloud environment.
+// You must reuse it to prevent connection/goroutines leakage.
+func NewQloudClient(opts ...Option) (*Client, error) {
+ baseURI := os.Getenv(QloudEndpointEnvKey)
+ if baseURI == "" {
+ baseURI = QloudDefaultEndpoint
+ }
+
+ authToken := os.Getenv(QloudTokenEnvKey)
+ if authToken == "" {
+ return nil, fmt.Errorf("empty auth token (looked at ENV[%s])", QloudTokenEnvKey)
+ }
+
+ opts = append([]Option{WithAuthToken(authToken)}, opts...)
+ return NewClient(
+ baseURI,
+ opts...,
+ )
+}