Skip to content

Commit

Permalink
Tidy up release_download_test.sh (#3522)
Browse files Browse the repository at this point in the history
* Tidy up release_download_test.sh, add support to run in on any machine, color output, additional options for easy testing.

* Address linter errors.

* Further address linter errors.

* Address review comments.

* Simplify getting tag from remaining arguments.

* Fix TODO.

* Address review comments, group functionality into functions.

* Fix linter errors.

* Fix print_verbose function if verbose is disabled.

* Fix path for validateSBOMcontent.sh script; fix shellcheck comment.

* Move print_verbose back to release_download_test, it should not belong in a common script as it is too specific for the validation script.

* Improve usage output.

* Address linter warning.

* Address linter warning.

* Add flag to explicitly enable ansi output.

* Make accessing $0 consistent.

* Support passing in the TAG as variable rather than as parameter like before.

* Improve usage.

* Update tooling/release_download_test.sh

Co-authored-by: Stewart X Addison <[email protected]>

---------

Co-authored-by: Stewart X Addison <[email protected]>
  • Loading branch information
netomi and sxa authored Nov 9, 2023
1 parent ff9bcd1 commit 88779a3
Show file tree
Hide file tree
Showing 2 changed files with 496 additions and 124 deletions.
46 changes: 46 additions & 0 deletions tooling/common_logging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
#
# Utility functions for logging.
#

set -eu

NORMAL=""
BOLD=""
RED=""
YELLOW=""


########################################################################################################################
#
# Initializes logging with ansi coloring.
#
########################################################################################################################
init_ansi_logging() {
# check if stdout is a terminal...
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)

if test -n "$ncolors" && test "$ncolors" -ge 8; then
NORMAL="$(tput sgr0)"
BOLD="$(tput bold)"
RED="$(tput setaf 1)"
YELLOW="$(tput setaf 3)"
fi
fi

export NORMAL
export BOLD
export RED
export YELLOW
}


print_error() {
echo "${RED}ERROR:${NORMAL} $*" 1>&2;
}

print_warning() {
echo "${YELLOW}WARN:${NORMAL} $*" 1>&2;
}
Loading

0 comments on commit 88779a3

Please sign in to comment.