-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (46 loc) · 1.28 KB
/
main.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"github.com/taonic/my-samples-go/cloud-api/client/api"
"github.com/taonic/my-samples-go/cloud-api/protogen/temporal/api/cloud/cloudservice/v1"
)
const (
temporalCloudAPIAddress = "saas-api.tmprl.cloud:443"
temporalCloudAPIKeyEnvName = "TEMPORAL_CLOUD_API_KEY"
)
var namespace string
func init() {
flag.StringVar(&namespace, "namespace", "", "Temporal namespace")
}
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
apikey := os.Getenv(temporalCloudAPIKeyEnvName)
if apikey == "" {
return fmt.Errorf("apikey not provided, set environment variable '%s' with apikey you want to use", temporalCloudAPIKeyEnvName)
}
flag.Parse()
if namespace == "" {
return fmt.Errorf("--namespace flag is required")
}
conn, err := api.NewConnectionWithAPIKey(temporalCloudAPIAddress, false, apikey)
if err != nil {
return fmt.Errorf("failed to create cloud api connection: %+v", err)
}
input := cloudservice.GetNamespaceRequest{
Namespace: namespace,
}
result, err := cloudservice.NewCloudServiceClient(conn).GetNamespace(context.Background(), &input)
if err != nil {
return err
}
log.Printf("Custom search attributes: %+v", result.Namespace.Spec.CustomSearchAttributes)
return nil
}