-
Notifications
You must be signed in to change notification settings - Fork 1
/
StartClusters.go
50 lines (40 loc) · 1.01 KB
/
StartClusters.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
// Copyright 2017 <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a Apache
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"log"
pb "github.com/chai2010/qingcloud-go/pkg/api"
"github.com/chai2010/qingcloud-go/pkg/config"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func main() {
flag.Parse()
conf := config.MustLoadUserConfig()
conf.JSONDisableUnknownFields = false
conf.LogLevel = "debug" // debug/warn
clusterService := pb.NewClusterService(conf, "pek3a")
reply, err := clusterService.StartClusters(&pb.StartClustersInput{
Clusters: []string{"cl-hvyhfuwl"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(jsonpbEncode(reply))
}
func jsonpbEncode(m proto.Message) string {
jsonMarshaler := &jsonpb.Marshaler{
OrigName: true,
Indent: " ",
EnumsAsInts: true,
EmitDefaults: true,
}
s, err := jsonMarshaler.MarshalToString(m)
if err != nil {
log.Fatal(err)
}
return s
}