Skip to content

Commit

Permalink
[FAB-11063] entity matchers refactoring
Browse files Browse the repository at this point in the history
- unlike older versions, entity matchers will be taken into
account even if exact match is found in config
- ca entity matcher to take place before exact match


Change-Id: Ibffe2b29d890e94da6b715cf03bc4ea0fd689851
Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed Jul 10, 2018
1 parent b5453c1 commit 02ba89a
Show file tree
Hide file tree
Showing 10 changed files with 621 additions and 263 deletions.
42 changes: 42 additions & 0 deletions pkg/core/config/testdata/matcher-samples/matchers_sample1.yaml
@@ -0,0 +1,42 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# 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.
#

# EntityMatchers enable substitution of network hostnames with static configurations
# so that properties can be mapped. Regex can be used for this purpose
# UrlSubstitutionExp can be empty which means the same network hostname will be used
# UrlSubstitutionExp can be given same as mapped peer url, so that mapped peer url can be used
# UrlSubstitutionExp can have golang regex matchers like $1.local.example.$2:$3 for pattern
# like peer0.org1.example.com:1234 which converts peer0.org1.example.com to peer0.org1.local.example.com:1234
# EventUrlSubstitutionExp and sslTargetOverrideUrlSubstitutionExp follow in the same lines as
# SubstitutionExp for the fields eventUrl and gprcOptions.ssl-target-name-override respectively
# In any case mappedHost's config will be used, so mapped host cannot be empty, if entityMatchers are used
entityMatchers:
peer:
- pattern: (\w+).org1.example.(\w+)
urlSubstitutionExp: peer0.org1.example.com:8888
eventUrlSubstitutionExp: peer0.org1.example.com:9999
sslTargetOverrideUrlSubstitutionExp: peer0.org1.override.com
mappedHost: peer0.org1.example.com

orderer:
- pattern: (\w+).example.(\w+)
urlSubstitutionExp: orderer.example.com:8888
sslTargetOverrideUrlSubstitutionExp: orderer.override.com
mappedHost: orderer.example.com

certificateAuthority:
- pattern: (\w+).org1.example.(\w+)
urlSubstitutionExp: https://ca.org1.example.com:8888
mappedHost: ca.org1.example.com

channel:
- pattern: ^(test)(\w*)(channel)$
mappedName: ch1
31 changes: 31 additions & 0 deletions pkg/core/config/testdata/matcher-samples/matchers_sample2.yaml
@@ -0,0 +1,31 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# 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.
#

# EntityMatchers enable substitution of network hostnames with static configurations
# so that properties can be mapped. Regex can be used for this purpose
# UrlSubstitutionExp can be empty which means the same network hostname will be used
# UrlSubstitutionExp can be given same as mapped peer url, so that mapped peer url can be used
# UrlSubstitutionExp can have golang regex matchers like $1.local.example.$2:$3 for pattern
# like peer0.org1.example.com:1234 which converts peer0.org1.example.com to peer0.org1.local.example.com:1234
# EventUrlSubstitutionExp and sslTargetOverrideUrlSubstitutionExp follow in the same lines as
# SubstitutionExp for the fields eventUrl and gprcOptions.ssl-target-name-override respectively
# In any case mappedHost's config will be used, so mapped host cannot be empty, if entityMatchers are used
entityMatchers:
peer:
- pattern: (\w+).org1.example.(\w+)
urlSubstitutionExp: peer0.org1.example.com:8888
mappedHost: peer0.org1.example.com

orderer:
- pattern: (\w+).example.(\w+)
urlSubstitutionExp: orderer.example.com:8888
mappedHost: orderer.example.com

38 changes: 38 additions & 0 deletions pkg/core/config/testdata/matcher-samples/matchers_sample3.yaml
@@ -0,0 +1,38 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# 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.
#

# EntityMatchers enable substitution of network hostnames with static configurations
# so that properties can be mapped. Regex can be used for this purpose
# UrlSubstitutionExp can be empty which means the same network hostname will be used
# UrlSubstitutionExp can be given same as mapped peer url, so that mapped peer url can be used
# UrlSubstitutionExp can have golang regex matchers like $1.local.example.$2:$3 for pattern
# like peer0.org1.example.com:1234 which converts peer0.org1.example.com to peer0.org1.local.example.com:1234
# EventUrlSubstitutionExp and sslTargetOverrideUrlSubstitutionExp follow in the same lines as
# SubstitutionExp for the fields eventUrl and gprcOptions.ssl-target-name-override respectively
# In any case mappedHost's config will be used, so mapped host cannot be empty, if entityMatchers are used
entityMatchers:
peer:
- pattern: (\w+).exampleX.(\w+):(\d+)
urlSubstitutionExp: peer0.org1.example.com:8888
eventUrlSubstitutionExp: peer0.org1.example.com:9999
sslTargetOverrideUrlSubstitutionExp: peer0.org1.override.com
mappedHost: peer0.org1.example.com

orderer:
- pattern: (\w+).exampleX.(\w+):(\d+)
urlSubstitutionExp: orderer.example.com:8888
sslTargetOverrideUrlSubstitutionExp: orderer.override.com
mappedHost: orderer.example.com

certificateAuthority:
- pattern: (\w+).org1.exampleX.(\w+)
urlSubstitutionExp: https://ca.org1.example.com:8888
mappedHost: ca.org1.example.com
30 changes: 30 additions & 0 deletions pkg/core/config/testdata/matcher-samples/matchers_sample4.yaml
@@ -0,0 +1,30 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# 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.
#

# EntityMatchers enable substitution of network hostnames with static configurations
# so that properties can be mapped. Regex can be used for this purpose
# UrlSubstitutionExp can be empty which means the same network hostname will be used
# UrlSubstitutionExp can be given same as mapped peer url, so that mapped peer url can be used
# UrlSubstitutionExp can have golang regex matchers like $1.local.example.$2:$3 for pattern
# like peer0.org1.example.com:1234 which converts peer0.org1.example.com to peer0.org1.local.example.com:1234
# EventUrlSubstitutionExp and sslTargetOverrideUrlSubstitutionExp follow in the same lines as
# SubstitutionExp for the fields eventUrl and gprcOptions.ssl-target-name-override respectively
# In any case mappedHost's config will be used, so mapped host cannot be empty, if entityMatchers are used
entityMatchers:
peer:
- pattern: (\w+).org1.example.(\w+)
sslTargetOverrideUrlSubstitutionExp: peer0.org1.override.com
mappedHost: peer0.org1.example.com

orderer:
- pattern: (\w+).example.(\w+)
sslTargetOverrideUrlSubstitutionExp: orderer.override.com
mappedHost: orderer.example.com

0 comments on commit 02ba89a

Please sign in to comment.