Skip to content

Commit f02ffd9

Browse files
author
Arnaud Porterie
committed
Bump etcd to 2.3.2
Bump etcd to 2.3.2 and `github.com/ugorji/go` accordingly. Signed-off-by: Arnaud Porterie <[email protected]>
1 parent e252871 commit f02ffd9

39 files changed

Lines changed: 25750 additions & 12789 deletions

hack/vendor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ clone git github.com/vishvananda/netlink 631962935bff4f3d20ff32a72e8944f6d2836a2
7979
clone git github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060
8080
clone git github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
8181
clone git github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d
82-
clone git github.com/coreos/etcd v2.2.0
82+
clone git github.com/coreos/etcd v2.3.2
8383
fix_rewritten_imports github.com/coreos/etcd
84-
clone git github.com/ugorji/go 5abd4e96a45c386928ed2ca2a7ef63e2533e18ec
84+
clone git github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065
8585
clone git github.com/hashicorp/consul v0.5.2
8686
clone git github.com/boltdb/bolt v1.2.1
8787
clone git github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7

vendor/src/github.com/coreos/etcd/client/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,25 @@ func main() {
3535
log.Fatal(err)
3636
}
3737
kapi := client.NewKeysAPI(c)
38-
resp, err := kapi.Set(context.Background(), "foo", "bar", nil)
38+
// set "/foo" key with "bar" value
39+
log.Print("Setting '/foo' key with 'bar' value")
40+
resp, err := kapi.Set(context.Background(), "/foo", "bar", nil)
3941
if err != nil {
4042
log.Fatal(err)
43+
} else {
44+
// print common key info
45+
log.Printf("Set is done. Metadata is %q\n", resp)
46+
}
47+
// get "/foo" key's value
48+
log.Print("Getting '/foo' key value")
49+
resp, err = kapi.Get(context.Background(), "/foo", nil)
50+
if err != nil {
51+
log.Fatal(err)
52+
} else {
53+
// print common key info
54+
log.Printf("Get is done. Metadata is %q\n", resp)
55+
// print value
56+
log.Printf("%q key has %q value\n", resp.Node.Key, resp.Node.Value)
4157
}
4258
}
4359
```
@@ -61,7 +77,7 @@ If the response gets from the cluster is invalid, a plain string error will be r
6177
Here is the example code to handle client errors:
6278

6379
```go
64-
cfg := client.Config{Endpoints: []string{"http://etcd1:2379,http://etcd2:2379,http://etcd3:2379"}}
80+
cfg := client.Config{Endpoints: []string{"http://etcd1:2379","http://etcd2:2379","http://etcd3:2379"}}
6581
c, err := client.New(cfg)
6682
if err != nil {
6783
log.Fatal(err)

vendor/src/github.com/coreos/etcd/client/auth_role.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ func NewAuthRoleAPI(c Client) AuthRoleAPI {
5656
}
5757

5858
type AuthRoleAPI interface {
59-
// Add a role.
59+
// AddRole adds a role.
6060
AddRole(ctx context.Context, role string) error
6161

62-
// Remove a role.
62+
// RemoveRole removes a role.
6363
RemoveRole(ctx context.Context, role string) error
6464

65-
// Get role details.
65+
// GetRole retrieves role details.
6666
GetRole(ctx context.Context, role string) (*Role, error)
6767

68-
// Grant a role some permission prefixes for the KV store.
68+
// GrantRoleKV grants a role some permission prefixes for the KV store.
6969
GrantRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error)
7070

71-
// Revoke some some permission prefixes for a role on the KV store.
71+
// RevokeRoleKV revokes some permission prefixes for a role on the KV store.
7272
RevokeRoleKV(ctx context.Context, role string, prefixes []string, permType PermissionType) (*Role, error)
7373

74-
// List roles.
74+
// ListRoles lists roles.
7575
ListRoles(ctx context.Context) ([]string, error)
7676
}
7777

@@ -115,17 +115,20 @@ func (r *httpAuthRoleAPI) ListRoles(ctx context.Context) ([]string, error) {
115115
if err != nil {
116116
return nil, err
117117
}
118-
if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
118+
if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
119119
return nil, err
120120
}
121-
var userList struct {
122-
Roles []string `json:"roles"`
121+
var roleList struct {
122+
Roles []Role `json:"roles"`
123123
}
124-
err = json.Unmarshal(body, &userList)
125-
if err != nil {
124+
if err = json.Unmarshal(body, &roleList); err != nil {
126125
return nil, err
127126
}
128-
return userList.Roles, nil
127+
ret := make([]string, 0, len(roleList.Roles))
128+
for _, r := range roleList.Roles {
129+
ret = append(ret, r.Role)
130+
}
131+
return ret, nil
129132
}
130133

131134
func (r *httpAuthRoleAPI) AddRole(ctx context.Context, rolename string) error {
@@ -218,17 +221,16 @@ func (r *httpAuthRoleAPI) modRole(ctx context.Context, req *authRoleAPIAction) (
218221
if err != nil {
219222
return nil, err
220223
}
221-
if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
224+
if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
222225
var sec authError
223-
err := json.Unmarshal(body, &sec)
226+
err = json.Unmarshal(body, &sec)
224227
if err != nil {
225228
return nil, err
226229
}
227230
return nil, sec
228231
}
229232
var role Role
230-
err = json.Unmarshal(body, &role)
231-
if err != nil {
233+
if err = json.Unmarshal(body, &role); err != nil {
232234
return nil, err
233235
}
234236
return &role, nil

vendor/src/github.com/coreos/etcd/client/auth_user.go

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ type User struct {
3636
Revoke []string `json:"revoke,omitempty"`
3737
}
3838

39+
// userListEntry is the user representation given by the server for ListUsers
40+
type userListEntry struct {
41+
User string `json:"user"`
42+
Roles []Role `json:"roles"`
43+
}
44+
45+
type UserRoles struct {
46+
User string `json:"user"`
47+
Roles []Role `json:"roles"`
48+
}
49+
50+
type userName struct {
51+
User string `json:"user"`
52+
}
53+
3954
func v2AuthURL(ep url.URL, action string, name string) *url.URL {
4055
if name != "" {
4156
ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action, name)
@@ -78,9 +93,9 @@ func (s *httpAuthAPI) enableDisable(ctx context.Context, req httpAction) error {
7893
if err != nil {
7994
return err
8095
}
81-
if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
96+
if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
8297
var sec authError
83-
err := json.Unmarshal(body, &sec)
98+
err = json.Unmarshal(body, &sec)
8499
if err != nil {
85100
return err
86101
}
@@ -117,25 +132,25 @@ func NewAuthUserAPI(c Client) AuthUserAPI {
117132
}
118133

119134
type AuthUserAPI interface {
120-
// Add a user.
135+
// AddUser adds a user.
121136
AddUser(ctx context.Context, username string, password string) error
122137

123-
// Remove a user.
138+
// RemoveUser removes a user.
124139
RemoveUser(ctx context.Context, username string) error
125140

126-
// Get user details.
141+
// GetUser retrieves user details.
127142
GetUser(ctx context.Context, username string) (*User, error)
128143

129-
// Grant a user some permission roles.
144+
// GrantUser grants a user some permission roles.
130145
GrantUser(ctx context.Context, username string, roles []string) (*User, error)
131146

132-
// Revoke some permission roles from a user.
147+
// RevokeUser revokes some permission roles from a user.
133148
RevokeUser(ctx context.Context, username string, roles []string) (*User, error)
134149

135-
// Change the user's password.
150+
// ChangePassword changes the user's password.
136151
ChangePassword(ctx context.Context, username string, password string) (*User, error)
137152

138-
// List users.
153+
// ListUsers lists the users.
139154
ListUsers(ctx context.Context) ([]string, error)
140155
}
141156

@@ -179,22 +194,28 @@ func (u *httpAuthUserAPI) ListUsers(ctx context.Context) ([]string, error) {
179194
if err != nil {
180195
return nil, err
181196
}
182-
if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
197+
if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
183198
var sec authError
184-
err := json.Unmarshal(body, &sec)
199+
err = json.Unmarshal(body, &sec)
185200
if err != nil {
186201
return nil, err
187202
}
188203
return nil, sec
189204
}
205+
190206
var userList struct {
191-
Users []string `json:"users"`
207+
Users []userListEntry `json:"users"`
192208
}
193-
err = json.Unmarshal(body, &userList)
194-
if err != nil {
209+
210+
if err = json.Unmarshal(body, &userList); err != nil {
195211
return nil, err
196212
}
197-
return userList.Users, nil
213+
214+
ret := make([]string, 0, len(userList.Users))
215+
for _, u := range userList.Users {
216+
ret = append(ret, u.User)
217+
}
218+
return ret, nil
198219
}
199220

200221
func (u *httpAuthUserAPI) AddUser(ctx context.Context, username string, password string) error {
@@ -221,9 +242,9 @@ func (u *httpAuthUserAPI) addRemoveUser(ctx context.Context, req *authUserAPIAct
221242
if err != nil {
222243
return err
223244
}
224-
if err := assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
245+
if err = assertStatusCode(resp.StatusCode, http.StatusOK, http.StatusCreated); err != nil {
225246
var sec authError
226-
err := json.Unmarshal(body, &sec)
247+
err = json.Unmarshal(body, &sec)
227248
if err != nil {
228249
return err
229250
}
@@ -280,18 +301,24 @@ func (u *httpAuthUserAPI) modUser(ctx context.Context, req *authUserAPIAction) (
280301
if err != nil {
281302
return nil, err
282303
}
283-
if err := assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
304+
if err = assertStatusCode(resp.StatusCode, http.StatusOK); err != nil {
284305
var sec authError
285-
err := json.Unmarshal(body, &sec)
306+
err = json.Unmarshal(body, &sec)
286307
if err != nil {
287308
return nil, err
288309
}
289310
return nil, sec
290311
}
291312
var user User
292-
err = json.Unmarshal(body, &user)
293-
if err != nil {
294-
return nil, err
313+
if err = json.Unmarshal(body, &user); err != nil {
314+
var userR UserRoles
315+
if urerr := json.Unmarshal(body, &userR); urerr != nil {
316+
return nil, err
317+
}
318+
user.User = userR.User
319+
for _, r := range userR.Roles {
320+
user.Roles = append(user.Roles, r.Role)
321+
}
295322
}
296323
return &user, nil
297324
}

0 commit comments

Comments
 (0)