2. Change if expr syntax to be consist with the rest of Vault code
3. More details on error message
This commit is contained in:
Eyal Lupu 2016-02-19 12:19:01 +00:00
parent 4b709a7a7a
commit 3886d68de3

View File

@ -63,7 +63,7 @@ func newZookeeperBackend(conf map[string]string) (Backend, error) {
schema = "world"
} else {
parsedSchemaAndOwner := strings.SplitN(schemaAndOwner, ":", 2)
if !(len(parsedSchemaAndOwner)==2) {
if len(parsedSchemaAndOwner) != 2 {
return nil, fmt.Errorf("znode_owner expected format is 'schema:owner'")
} else {
schema = parsedSchemaAndOwner[0]
@ -73,7 +73,6 @@ func newZookeeperBackend(conf map[string]string) (Backend, error) {
acl := []zk.ACL{{zk.PermAll, schema, owner}}
// Authnetication info
var schemaAndUser string
schemaAndUser, ok = conf["auth_info"]
@ -82,7 +81,7 @@ func newZookeeperBackend(conf map[string]string) (Backend, error) {
schema = ""
} else {
parsedSchemaAndUser := strings.SplitN(schemaAndUser, ":", 2)
if !(len(parsedSchemaAndUser)==2) {
if len(parsedSchemaAndUser) != 2 {
return nil, fmt.Errorf("auth_info expected format is 'schema:auth'")
} else {
schema = parsedSchemaAndUser[0]
@ -90,7 +89,6 @@ func newZookeeperBackend(conf map[string]string) (Backend, error) {
}
}
// Attempt to create the ZK client
client, _, err := zk.Connect(strings.Split(machines, ","), time.Second)
if err != nil {
@ -101,7 +99,7 @@ func newZookeeperBackend(conf map[string]string) (Backend, error) {
if owner != "" {
err = client.AddAuth(schema, []byte(owner))
if err != nil {
return nil, fmt.Errorf("Zookeeper rejected authentication information provided at auth_info")
return nil, fmt.Errorf("Zookeeper rejected authentication information provided at auth_info: %v", err)
}
}