-
Notifications
You must be signed in to change notification settings - Fork 111
/
config_request.pb.a2svc.go
127 lines (118 loc) · 2.92 KB
/
config_request.pb.a2svc.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Code generated by protoc-gen-a2config. DO NOT EDIT.
// source: config/elasticsearch/config_request.proto
package es
import (
a2conf "github.com/chef/automate/components/automate-grpc/protoc-gen-a2-config/api/a2conf"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
strconv "strconv"
strings "strings"
)
// ServiceName returns the name of the service this config belongs to
func (m *ConfigRequest) ServiceName() string {
return "automate-elasticsearch"
}
// BindPort sets the port tagged with the given name
func (m *ConfigRequest) BindPort(name string, value uint16) error {
switch name {
case "service":
v0 := &m.V1
if *v0 == nil {
*v0 = &ConfigRequest_V1{}
}
v1 := &(*v0).Sys
if *v1 == nil {
*v1 = &ConfigRequest_V1_System{}
}
v2 := &(*v1).Network
if *v2 == nil {
*v2 = &ConfigRequest_V1_Network{}
}
v3 := &(*v2).Port
*v3 = &wrappers.Int32Value{Value: int32(value)}
case "transport":
v0 := &m.V1
if *v0 == nil {
*v0 = &ConfigRequest_V1{}
}
v1 := &(*v0).Sys
if *v1 == nil {
*v1 = &ConfigRequest_V1_System{}
}
v2 := &(*v1).Transport
if *v2 == nil {
*v2 = &ConfigRequest_V1_Transport{}
}
v3 := &(*v2).Port
valueStr := strconv.Itoa(int(value))
*v3 = &wrappers.StringValue{Value: valueStr}
default:
return a2conf.ErrPortNotFound
}
return nil
}
// ListPorts lists all the ports exposed by the config
func (m *ConfigRequest) ListPorts() []a2conf.PortInfo {
return []a2conf.PortInfo{a2conf.PortInfo{
Default: uint16(int32(10141)),
Name: "service",
Protocol: "http",
}, a2conf.PortInfo{
Default: uint16(int32(10142)),
Name: "transport",
Protocol: "es",
}}
}
// GetPort gets the port tagged with the given name. If the value is not set, it returns 0.
func (m *ConfigRequest) GetPort(name string) (uint16, error) {
switch name {
case "service":
v0 := m.V1
if v0 == nil {
return 0, nil
}
v1 := v0.Sys
if v1 == nil {
return 0, nil
}
v2 := v1.Network
if v2 == nil {
return 0, nil
}
v3 := v2.Port
return uint16(v3.GetValue()), nil
case "transport":
v0 := m.V1
if v0 == nil {
return 0, nil
}
v1 := v0.Sys
if v1 == nil {
return 0, nil
}
v2 := v1.Transport
if v2 == nil {
return 0, nil
}
v3 := v2.Port
parts := strings.Split(v3.Value, "-")
valueInt, err := strconv.ParseUint(parts[0], 10, 16)
if err != nil {
return 0, err
}
return uint16(valueInt), nil
default:
return 0, a2conf.ErrPortNotFound
}
}
// ListSecrets lists all the secrets exposed by the config
func (m *ConfigRequest) ListSecrets() []a2conf.SecretInfo {
return []a2conf.SecretInfo{}
}
// GetSecret gets a secret by name. Returns nil if it is not set
func (m *ConfigRequest) GetSecret(name string) *wrappers.StringValue {
return nil
}
// SetSecret sets a secret by name. Returns ErrSecretNotFound if the secret does not exist
func (m *ConfigRequest) SetSecret(name string, value *wrappers.StringValue) error {
return a2conf.ErrSecretNotFound
}