Skip to content

Commit

Permalink
[FAB-2546]Add yaml tags to structs needed for configtx
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-2546

As part of adding support to generate inut file(s)
for configtx, tags are required to deal with the fact
that the yaml package lowercases all public fields
when marshaling to YAML.

Change-Id: Ia19d89acc10d6ef8f5086de7eb88c3223146bca2
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Mar 2, 2017
1 parent c956be0 commit cd14e2a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions bccsp/factory/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package factory

// DefaultOpts offers a default implementation for Opts
type FactoryOpts struct {
ProviderName string `mapstructure:"default" json:"default"`
SwOpts *SwOpts `mapstructure:"SW,omitempty" json:"SW,omitempty"`
Pkcs11Opts *PKCS11Opts `mapstructure:"PKCS11,omitempty" json:"PKCS11,omitempty"`
ProviderName string `mapstructure:"default" json:"default" yaml:"Default"`
SwOpts *SwOpts `mapstructure:"SW,omitempty" json:"SW,omitempty" yaml:"SwOpts"`
Pkcs11Opts *PKCS11Opts `mapstructure:"PKCS11,omitempty" json:"PKCS11,omitempty" yaml:"PKCS11"`
}

var DefaultOpts = FactoryOpts{
Expand Down
8 changes: 4 additions & 4 deletions bccsp/factory/swfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ func (f *SWFactory) Get(config *FactoryOpts) (bccsp.BCCSP, error) {
// SwOpts contains options for the SWFactory
type SwOpts struct {
// Default algorithms when not specified (Deprecated?)
SecLevel int `mapstructure:"security" json:"security"`
HashFamily string `mapstructure:"hash" json:"hash"`
SecLevel int `mapstructure:"security" json:"security" yaml:"Security"`
HashFamily string `mapstructure:"hash" json:"hash" yaml:"Hash"`

// Keystore Options
Ephemeral bool `mapstructure:"tempkeys,omitempty" json:"tempkeys,omitempty"`
FileKeystore *FileKeystoreOpts `mapstructure:"filekeystore,omitempty" json:"filekeystore,omitempty"`
FileKeystore *FileKeystoreOpts `mapstructure:"filekeystore,omitempty" json:"filekeystore,omitempty" yaml:"FileKeyStore"`
DummyKeystore *DummyKeystoreOpts `mapstructure:"dummykeystore,omitempty" json:"dummykeystore,omitempty"`
}

// Pluggable Keystores, could add JKS, P12, etc..
type FileKeystoreOpts struct {
KeyStorePath string `mapstructure:"keystore"`
KeyStorePath string `mapstructure:"keystore" yaml:"KeyStore"`
}

type DummyKeystoreOpts struct{}
50 changes: 25 additions & 25 deletions common/configtx/tool/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,64 +46,64 @@ const Prefix string = "CONFIGTX"

// TopLevel contains the genesis structures for use by the provisional bootstrapper
type TopLevel struct {
Profiles map[string]*Profile
Organizations []*Organization
Application *Application
Orderer *Orderer
Profiles map[string]*Profile `yaml:"Profiles"`
Organizations []*Organization `yaml:"Organizations"`
Application *Application `yaml:"Application"`
Orderer *Orderer `yaml:"Orderer"`
}

// TopLevel contains the genesis structures for use by the provisional bootstrapper
type Profile struct {
Application *Application
Orderer *Orderer
Application *Application `yaml:"Application"`
Orderer *Orderer `yaml:"Orderer"`
}

// Application encodes the configuration needed for the config transaction
type Application struct {
Organizations []*Organization
Organizations []*Organization `yaml:"Organizations"`
}

type Organization struct {
Name string
ID string
MSPDir string
BCCSP *bccsp.FactoryOpts
Name string `yaml:"Name"`
ID string `yaml:"ID"`
MSPDir string `yaml:"MSPDir"`
BCCSP *bccsp.FactoryOpts `yaml:"BCCSP"`

// Note, the viper deserialization does not seem to care for
// embedding of types, so we use one organization structure for
// both orderers and applications
AnchorPeers []*AnchorPeer
AnchorPeers []*AnchorPeer `yaml:"AnchorPeers"`
}

type AnchorPeer struct {
Host string
Port int
Host string `yaml:"Host"`
Port int `yaml:"Port"`
}

type ApplicationOrganization struct {
Organization
Organization `yaml:"Organization"`
}

// Orderer contains config which is used for orderer genesis by the provisional bootstrapper
type Orderer struct {
OrdererType string
Addresses []string
BatchTimeout time.Duration
BatchSize BatchSize
Kafka Kafka
Organizations []*Organization
OrdererType string `yaml:"OrdererType"`
Addresses []string `yaml:"Addresses"`
BatchTimeout time.Duration `yaml:"BatchTimeout"`
BatchSize BatchSize `yaml:"BatchSize"`
Kafka Kafka `yaml:"Kafka"`
Organizations []*Organization `yaml:"Organizations"`
}

// BatchSize contains configuration affecting the size of batches
type BatchSize struct {
MaxMessageCount uint32
AbsoluteMaxBytes uint32
PreferredMaxBytes uint32
MaxMessageCount uint32 `yaml:"MaxMessageSize"`
AbsoluteMaxBytes uint32 `yaml:"AbsoluteMaxBytes"`
PreferredMaxBytes uint32 `yaml:"PreferredMaxBytes"`
}

// Kafka contains config for the Kafka orderer
type Kafka struct {
Brokers []string
Brokers []string `yaml:"Brokers"`
}

var genesisDefaults = TopLevel{
Expand Down

0 comments on commit cd14e2a

Please sign in to comment.