Skip to content

Commit

Permalink
[FAB-6763] Give protos own namespace
Browse files Browse the repository at this point in the history
Change-Id: Id0d96d42a2fec24c97be5af79e3e83917a8a79c3
Signed-off-by: Divyank Katira <Divyank.Katira@securekey.com>
  • Loading branch information
d1vyank committed Oct 25, 2017
1 parent 23ec481 commit 22e666e
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 131 deletions.
16 changes: 8 additions & 8 deletions internal/github.com/hyperledger/fabric/protos/orderer/ab.pb.go

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

34 changes: 34 additions & 0 deletions scripts/third_party_pins/fabric/apply_fabric_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
IMPORT_SUBSTS=($IMPORT_SUBSTS)

GOIMPORTS_CMD=goimports
NAMESPACE_PREFIX="sdk."

declare -a PKGS=(
"protos/common"
Expand Down Expand Up @@ -69,6 +70,39 @@ WORKING_DIR=$TMP_PROJECT_PATH FILES="${FILES[@]}" IMPORT_SUBSTS="${IMPORT_SUBSTS
echo "Inserting modification notice ..."
WORKING_DIR=$TMP_PROJECT_PATH FILES="${FILES[@]}" ALLOW_NONE_LICENSE_ID="true" scripts/third_party_pins/common/apply_header_notice.sh

echo "Changing proto registration paths to be unique"
for i in "${FILES[@]}"
do
if [[ ${i} == "protos/common"* ]]; then
sed -i'' -e "/proto.RegisterType/s/common/${NAMESPACE_PREFIX}common/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/common/${NAMESPACE_PREFIX}common/g" "${TMP_PROJECT_PATH}/${i}"
fi
if [[ ${i} == "protos/ledger/rwset/rwset.pb.go" ]]; then
sed -i'' -e "/proto.RegisterType/s/rwset/${NAMESPACE_PREFIX}rwset/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/rwset/${NAMESPACE_PREFIX}rwset/g" "${TMP_PROJECT_PATH}/${i}"
fi
if [[ ${i} == "protos/ledger/rwset/kvrwset/kv_rwset.pb.go" ]]; then
sed -i'' -e "/proto.RegisterType/s/kvrwset/${NAMESPACE_PREFIX}kvrwset/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/kvrwset/${NAMESPACE_PREFIX}kvrwset/g" "${TMP_PROJECT_PATH}/${i}"
fi
if [[ ${i} == "protos/msp"* ]]; then
sed -i'' -e "/proto.RegisterType/s/msp/${NAMESPACE_PREFIX}msp/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/msp/${NAMESPACE_PREFIX}msp/g" "${TMP_PROJECT_PATH}/${i}"
fi
if [[ ${i} == "protos/msp/msp_principal.pb.go" ]]; then
sed -i'' -e "/proto.RegisterType/s/common/${NAMESPACE_PREFIX}common/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/common/${NAMESPACE_PREFIX}common/g" "${TMP_PROJECT_PATH}/${i}"
fi
if [[ ${i} == "protos/orderer"* ]]; then
sed -i'' -e "/proto.RegisterType/s/orderer/${NAMESPACE_PREFIX}orderer/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/orderer/${NAMESPACE_PREFIX}orderer/g" "${TMP_PROJECT_PATH}/${i}"
fi
if [[ ${i} == "protos/peer"* ]]; then
sed -i'' -e "/proto.RegisterType/s/protos/${NAMESPACE_PREFIX}protos/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/protos/${NAMESPACE_PREFIX}protos/g" "${TMP_PROJECT_PATH}/${i}"
fi
done

# Copy patched project into internal paths
echo "Copying patched upstream project into working directory ..."
for i in "${FILES[@]}"
Expand Down
12 changes: 11 additions & 1 deletion scripts/third_party_pins/fabric/apply_fabric_protos_internal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ IMPORT_SUBSTS=($IMPORT_SUBSTS)

GOIMPORTS_CMD=goimports
GOFILTER_CMD="go run scripts/_go/cmd/gofilter/gofilter.go"
NAMESPACE_PREFIX="sdk."

declare -a PKGS=(
"protos/utils"
Expand Down Expand Up @@ -53,7 +54,7 @@ gofilter() {
$GOFILTER_CMD -filename "${TMP_PROJECT_PATH}/${FILTER_FILENAME}.bak" \
-filters fn -fn "$FILTER_FN" \
> "${TMP_PROJECT_PATH}/${FILTER_FILENAME}"
}
}

echo "Filtering Go sources for allowed functions ..."
FILTER_FILENAME="protos/utils/commonutils.go"
Expand Down Expand Up @@ -82,6 +83,15 @@ echo "Inserting modification notice ..."
WORKING_DIR=$TMP_PROJECT_PATH FILES="${NPBFILES[@]}" scripts/third_party_pins/common/apply_header_notice.sh
WORKING_DIR=$TMP_PROJECT_PATH FILES="${PBFILES[@]}" ALLOW_NONE_LICENSE_ID="true" scripts/third_party_pins/common/apply_header_notice.sh

echo "Changing proto registration paths to be unique"
for i in "${FILES[@]}"
do
if [[ ${i} == "protos/orderer"* ]]; then
sed -i'' -e "/proto.RegisterType/s/orderer/${NAMESPACE_PREFIX}orderer/g" "${TMP_PROJECT_PATH}/${i}"
sed -i'' -e "/proto.RegisterEnum/s/orderer/${NAMESPACE_PREFIX}orderer/g" "${TMP_PROJECT_PATH}/${i}"
fi
done

# Copy patched project into internal paths
echo "Copying patched upstream project into working directory ..."
for i in "${FILES[@]}"
Expand Down

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

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

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

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

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

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

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

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

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

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

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

Loading

0 comments on commit 22e666e

Please sign in to comment.