*: Add security/auth support to etcdctl and etcd/client

add godep for speakeasy and auth entry parsing
add security_user to client
add role to client
add role commands
add auth support to etcdclient and etcdctl(member/user)
add enable/disable to etcdctl
better error messages, read/write/readwrite
Bump go-etcd to include codec changes, add new dependency
verify the error for revoke/add if nothing changed, remove security-merging prefix
This commit is contained in:
Barak Michener
2015-04-03 17:32:30 -04:00
parent 97709b202d
commit a4d1a5a6e5
62 changed files with 45661 additions and 39 deletions

View File

@ -16,6 +16,7 @@ package command
import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
@ -24,6 +25,7 @@ import (
"strings"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/codegangsta/cli"
"github.com/coreos/etcd/client"
"github.com/coreos/etcd/pkg/transport"
)
@ -112,3 +114,40 @@ func getTransport(c *cli.Context) (*http.Transport, error) {
}
return transport.NewTransport(tls)
}
func mustNewClient(c *cli.Context) client.Client {
eps, err := getEndpoints(c)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
tr, err := getTransport(c)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
cfg := client.Config{
Transport: tr,
Endpoints: eps,
}
uFlag := c.GlobalString("username")
if uFlag != "" {
username, password, err := getUsernamePasswordFromFlag(uFlag)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
cfg.Username = username
cfg.Password = password
}
hc, err := client.New(cfg)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
return hc
}