Skip to content

Commit

Permalink
[FAB-3396] Fixed "index out of range" error
Browse files Browse the repository at this point in the history
Invoking register command with '--id.attr foo=bar' will
result in 'index out of range' error. This error will
also happen if the client configuration file either
does not have 'id.attributes' property or no members
are specified in the 'id.attributes' list property.
This problem surfaced after the 'id.attributes' was changed
to 'id.attrs' in the client configuration template in the
FAB-3107

Change-Id: Idd5da7085ebe54420268d77d1d332a3cda9f34d5
Signed-off-by: Anil Ambati <[email protected]>
  • Loading branch information
Anil Ambati committed Apr 25, 2017
1 parent b4ce73f commit d53f934
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/fabric-ca-client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/cloudflare/cfssl/log"
"github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-ca/lib"
"github.com/hyperledger/fabric-ca/util"
"github.com/spf13/viper"
Expand Down Expand Up @@ -123,7 +124,7 @@ id:
name:
type:
affiliation:
attrs:
attributes:
- name:
value:
Expand Down Expand Up @@ -255,6 +256,9 @@ func createDefaultConfigFile() error {
// processAttributes parses attributes from command line
func processAttributes() {
splitAttr := strings.Split(clientCfg.ID.Attr, "=")
if len(clientCfg.ID.Attributes) == 0 {
clientCfg.ID.Attributes = make([]api.Attribute, 1)
}
clientCfg.ID.Attributes[0].Name = splitAttr[0]
clientCfg.ID.Attributes[0].Value = strings.Join(splitAttr[1:], "")
}
Expand Down

0 comments on commit d53f934

Please sign in to comment.