Skip to content

Commit

Permalink
[FAB-9169] remove unused options in config
Browse files Browse the repository at this point in the history
Change-Id: Ie1f6b76f2f74ca89a63283b5230cc3d2f7a964fa
Signed-off-by: Pavan Kappara <[email protected]>
  • Loading branch information
Pavan Kappara committed Mar 27, 2018
1 parent b02be7a commit d177ebb
Show file tree
Hide file tree
Showing 30 changed files with 553 additions and 602 deletions.
36 changes: 0 additions & 36 deletions pkg/client/msp/testdata/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
# blockchain network that are necessary for the applications to interact with it. These are all
# knowledge that must be acquired from out-of-band sources. This file provides such a source.
#
name: "global-trade-network"

#
# Describe what the target network is/does.
#
description: "The network to be in if you want to stay in the global trade business"

#
# Schema version of the content. Used by the SDK to apply the corresponding parsing rules.
Expand Down Expand Up @@ -79,9 +74,6 @@ client:
# Specific to the underlying KeyValueStore that backs the crypto key store.
path: /tmp/idtestkeystore

# [Optional]. Specific to Composer environment. Not used by SDK Go.
#wallet: wallet-name

# BCCSP config for the client. Used by GO SDK.
BCCSP:
security:
Expand Down Expand Up @@ -139,14 +131,6 @@ channels:
# Default: true
eventSource: true

# [Optional]. what chaincodes are expected to exist on this channel? The application can use
# this information to validate that the target peers are in the expected state by comparing
# this list with the query results of getInstalledChaincodes() and getInstantiatedChaincodes()
chaincodes:
# the format follows the "canonical name" of chaincodes by fabric code
- example02:v1
- marbles:1.0

# multi-org test channel
orgchannel:

Expand Down Expand Up @@ -187,18 +171,6 @@ organizations:
certificateAuthorities:
- ca.org1.example.com

# [Optional]. If the application is going to make requests that are reserved to organization
# administrators, including creating/updating channels, installing/instantiating chaincodes, it
# must have access to the admin identity represented by the private key and signing certificate.
# Both properties can be the PEM string or local path to the PEM file. Note that this is mainly for
# convenience in development mode, production systems should not expose sensitive information
# this way. The SDK should allow applications to set the org admin identity via APIs, and only use
# this route as an alternative when it exists.
adminPrivateKey:
pem: "-----BEGIN PRIVATE KEY----- <etc>"
signedCert:
path: "/tmp/somepath/signed-cert.pem"

# the profile will contain public information about organizations other than the one it belongs to.
# These are necessary information to make transaction lifecycles work, including MSP IDs and
# peers with a public URL to send transaction proposals. The file will not contain private
Expand Down Expand Up @@ -309,10 +281,6 @@ peers:
certificateAuthorities:
ca.org1.example.com:
url: "http://localhost:8050"
# the properties specified under this object are passed to the 'http' client verbatim when
# making the request to the Fabric-CA server
httpOptions:
verify: true
tlsCACerts:
# Comma-Separated list of paths
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/fabricca/tls/certs/ca_root.pem
Expand All @@ -332,10 +300,6 @@ certificateAuthorities:
caName: ca.org1.example.com
ca.org2.example.com:
url: "http://localhost:8050"
# the properties specified under this object are passed to the 'http' client verbatim when
# making the request to the Fabric-CA server
httpOptions:
verify: true
tlsCACerts:
# Comma-Separated list of paths
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/fabricca/tls/certs/ca_root.pem
Expand Down
4 changes: 0 additions & 4 deletions pkg/client/resmgmt/testdata/ccproposal_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
# blockchain network that are necessary for the applications to interact with it. These are all
# knowledge that must be acquired from out-of-band sources. This file provides such a source.
#
name: "global-trade-network"


description: "The network to be in if you want to stay in the global trade business"
version: 1.0.0

client:
Expand Down
4 changes: 0 additions & 4 deletions pkg/client/resmgmt/testdata/event_source_missing_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
# blockchain network that are necessary for the applications to interact with it. These are all
# knowledge that must be acquired from out-of-band sources. This file provides such a source.
#
name: "global-trade-network"


description: "The network to be in if you want to stay in the global trade business"
version: 1.0.0

client:
Expand Down
1 change: 0 additions & 1 deletion pkg/client/resmgmt/testdata/invalidchorderer_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# SPDX-License-Identifier: Apache-2.0
#

name: "global-trade-network"

description: "Test Invalid Channel Orderer Error"
version: 1.0.0
Expand Down
1 change: 0 additions & 1 deletion pkg/client/resmgmt/testdata/invalidorderer_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# SPDX-License-Identifier: Apache-2.0
#

name: "global-trade-network"

description: "Test Invalid Channel Orderer Error"
version: 1.0.0
Expand Down
1 change: 0 additions & 1 deletion pkg/client/resmgmt/testdata/noorderer_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# SPDX-License-Identifier: Apache-2.0
#

name: "global-trade-network"

description: "Test No Orderer Error"
version: 1.0.0
Expand Down
21 changes: 4 additions & 17 deletions pkg/common/providers/core/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
// NetworkConfig provides a static definition of a Hyperledger Fabric network
type NetworkConfig struct {
Name string
Xtype string
Description string
Version string
Client ClientConfig
Expand All @@ -31,7 +30,6 @@ type ClientConfig struct {
Organization string
Logging LoggingType
CryptoConfig CCType
TLS TLSType
TLSCerts MutualTLSConfig
CredentialStore CredentialStoreType
}
Expand All @@ -46,18 +44,12 @@ type CCType struct {
Path string
}

// TLSType defines whether or not TLS is enabled
type TLSType struct {
Enabled bool
}

// CredentialStoreType defines pluggable KV store properties
type CredentialStoreType struct {
Path string
CryptoStore struct {
Path string
}
Wallet string
}

// ChannelConfig provides the definition of channels for the network
Expand All @@ -67,8 +59,6 @@ type ChannelConfig struct {
// Peers a list of peer-channels that are part of this organization
// to get the real Peer config object, use the Name field and fetch NetworkConfig.Peers[Name]
Peers map[string]PeerChannelConfig
// Chaincodes list of services
Chaincodes []string
//Policies list of policies for channel
Policies ChannelPolicies
}
Expand Down Expand Up @@ -113,8 +103,6 @@ type OrganizationConfig struct {
Users map[string]TLSKeyPair
Peers []string
CertificateAuthorities []string
AdminPrivateKey endpoint.TLSConfig
SignedCert endpoint.TLSConfig
}

// OrdererConfig defines an orderer configuration
Expand All @@ -134,11 +122,10 @@ type PeerConfig struct {

// CAConfig defines a CA configuration
type CAConfig struct {
URL string
HTTPOptions map[string]interface{}
TLSCACerts MutualTLSConfig
Registrar EnrollCredentials
CAName string
URL string
TLSCACerts MutualTLSConfig
Registrar EnrollCredentials
CAName string
}

// EnrollCredentials holds credentials used for enrollment
Expand Down
1 change: 1 addition & 0 deletions pkg/common/providers/core/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Config interface {
TLSClientCerts() ([]tls.Certificate, error)
CredentialStorePath() string
EventServiceType() EventServiceType
Lookup(key string) (interface{}, bool)
}

// ConfigProvider enables creation of a Config instance
Expand Down
8 changes: 8 additions & 0 deletions pkg/common/providers/test/mockcore/mockcore.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion pkg/core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,15 @@ func (c *Config) EventServiceType() core.EventServiceType {
}
}

// Lookup gets the Value from config file by Key
func (c *Config) Lookup(key string) (interface{}, bool) {
value := c.configViper.Get(key)
if value != nil {
return value, true
}
return nil, false
}

func (c *Config) getTimeout(tType core.TimeoutType) time.Duration {
var timeout time.Duration
switch tType {
Expand Down Expand Up @@ -621,7 +630,6 @@ func (c *Config) MSPID(org string) (string, error) {
func (c *Config) cacheNetworkConfiguration() error {
networkConfig := core.NetworkConfig{}
networkConfig.Name = c.configViper.GetString("name")
networkConfig.Xtype = c.configViper.GetString("x-type")
networkConfig.Description = c.configViper.GetString("description")
networkConfig.Version = c.configViper.GetString("version")

Expand Down
60 changes: 45 additions & 15 deletions pkg/core/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
org0 = "org0"
org1 = "org1"
configTestFilePath = "testdata/config_test.yaml"
configTestTemplateFilePath = "testdata/config_test_template.yaml"
configEmptyTestFilePath = "testdata/empty.yaml"
configPemTestFilePath = "testdata/config_test_pem.yaml"
configEmbeddedUsersTestFilePath = "testdata/config_test_embedded_pems.yaml"
Expand All @@ -51,21 +52,6 @@ func TestCAConfig(t *testing.T) {
t.Fatalf("Failed to load config file")
}

//Test network name
if vConfig.GetString("name") != "global-trade-network" {
t.Fatalf("Incorrect Network name")
}

//Test client app specific variable x-type
if vConfig.GetString("x-type") != "hlfv1" {
t.Fatalf("Incorrect Netwok x-type")
}

//Test network description
if vConfig.GetString("description") != "The network to be in if you want to stay in the global trade business" {
t.Fatalf("Incorrect Network description")
}

//Test network config version
if vConfig.GetString("version") != "1.0.0" {
t.Fatalf("Incorrect network version")
Expand Down Expand Up @@ -1559,6 +1545,50 @@ func badOpt() Option {
}
}

func TestConfig_Lookup(t *testing.T) {
configImpl, err := FromFile(configTestTemplateFilePath)()
if err != nil {
t.Fatalf("Unexpected error reading config: %v", err)
}

value, ok := configImpl.Lookup("name")
if !ok {
t.Fatal(err)
}
name := value.(string)
if name != "global-trade-network" {
t.Fatal("Expected Name to be global-trade-network")
}

value, ok = configImpl.Lookup("description")
if !ok {
t.Fatal(err)
}
description := value.(string)
if description == "" {
t.Fatal("Expected non empty description")
}

value, ok = configImpl.Lookup("x-type")
if !ok {
t.Fatal(err)
}
xType := value.(string)
if xType != "h1fv1" {
t.Fatal("Expected x-type to be h1fv1")
}

value, ok = configImpl.Lookup("channels.mychannel.chaincodes")
if !ok {
t.Fatal(err)
}
chaincodes := value.([]interface{})
if len(chaincodes) != 2 {
t.Fatal("Expected only 2 chaincodes")
}

}

/*
func TestDefaultConfigFromFile(t *testing.T) {
c, err := FromFile(configEmptyTestFilePath, WithTemplatePath(defaultConfigPath))
Expand Down
Loading

0 comments on commit d177ebb

Please sign in to comment.