Skip to content

Commit

Permalink
Allow to show or hide sensitive output (#514)
Browse files Browse the repository at this point in the history
* Allow to show or hide sensitive output

* Mask output directly in build.sh

* Fix

* Fix

* Address review comments
  • Loading branch information
daniele-moro authored Apr 1, 2022
1 parent 126aba9 commit 385bb26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ PIPECONF_OAR_FILE := $(DIR)/target/fabric-tna-1.2.0-SNAPSHOT.oar
# Profiles to build by default (all)
PROFILES ?= fabric fabric-upf fabric-int fabric-upf-int

export SHOW_SENSITIVE_OUTPUT ?= true

deps:
docker pull $(SDE_TM_DOCKER_IMG)
docker pull $(SDE_P4C_DOCKER_IMG)
Expand Down
26 changes: 17 additions & 9 deletions p4src/tna/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ mkdir -p "${P4C_OUT}"
# Where the compiler output should be placed to be included in the pipeconf.
DEST_DIR=${ROOT_DIR}/src/main/resources/p4c-out/${PROFILE}

P4C_CMD="docker run --rm -v ${P4C_OUT}:${P4C_OUT} \
BASE_P4C_CMD="docker run --rm -v ${P4C_OUT}:${P4C_OUT} \
-v ${P4_SRC_DIR}:${P4_SRC_DIR} -v ${DIR}:${DIR} -w ${DIR} --user ${UID} \
${SDE_P4C_DOCKER_IMG} bf-p4c"
SDE_VER=$( ${P4C_CMD} --version | cut -d' ' -f2 )
SDE_VER=$( ${BASE_P4C_CMD} --version | cut -d' ' -f2 )

SHOW_SENSITIVE_OUTPUT=${SHOW_SENSITIVE_OUTPUT:-"false"}

# shellcheck disable=SC2086
function base_build() {
Expand All @@ -36,14 +38,20 @@ function base_build() {
echo "*** Output in ${output_dir}"
p4c_flags=""
mkdir -p ${output_dir}
COMPILE_P4C_CMD="$BASE_P4C_CMD \
--arch tna -g --create-graphs --verbose 2 \
-o ${output_dir} -I ${P4_SRC_DIR} \
${OTHER_PP_FLAGS} \
${p4c_flags} \
--p4runtime-files ${output_dir}/p4info.txt \
--p4runtime-force-std-externs \
${DIR}/fabric_tna.p4"
(
time $P4C_CMD --arch tna -g --create-graphs --verbose 2 \
-o ${output_dir} -I ${P4_SRC_DIR} \
${OTHER_PP_FLAGS} \
${p4c_flags} \
--p4runtime-files ${output_dir}/p4info.txt \
--p4runtime-force-std-externs \
${DIR}/fabric_tna.p4
if [ "${SHOW_SENSITIVE_OUTPUT}" == "true" ]; then
time $COMPILE_P4C_CMD
else
time $COMPILE_P4C_CMD >/dev/null 2>&1
fi
)

# Generate the pipeline config binary
Expand Down

0 comments on commit 385bb26

Please sign in to comment.