Skip to content

Commit b90cbb5

Browse files
authored
lib/common.sh, Licenses 2025-07-31 (#29)
* lib/common.sh, Licenses 2025-07-31 Signed-off-by: Julio Jimenez <julio@clickhouse.com> * licenses Signed-off-by: Julio Jimenez <julio@clickhouse.com> --------- Signed-off-by: Julio Jimenez <julio@clickhouse.com>
1 parent 6e8e112 commit b90cbb5

5 files changed

Lines changed: 73 additions & 40 deletions

File tree

entrypoint.sh

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77

88
# Source all library files
99
source "$SCRIPT_DIR/lib/sanitize.sh"
10-
11-
# Colors for output
12-
RED='\033[0;31m'
13-
GREEN='\033[0;32m'
14-
YELLOW='\033[1;33m'
15-
BLUE='\033[0;34m'
16-
ORANGE='\033[0;33m'
17-
NC='\033[0m' # No Color
18-
19-
# Logging functions
20-
log_debug() {
21-
if [[ "${DEBUG:-false}" == "true" ]]; then
22-
echo -e "${ORANGE}[DEBUG]${NC} $1"
23-
fi
24-
}
25-
26-
log_info() {
27-
echo -e "${BLUE}[INFO]${NC} $1"
28-
}
29-
30-
log_success() {
31-
echo -e "${GREEN}[SUCCESS]${NC} $1"
32-
}
33-
34-
log_warning() {
35-
echo -e "${YELLOW}[WARNING]${NC} $1"
36-
}
37-
38-
log_error() {
39-
echo -e "${RED}[ERROR]${NC} $1"
40-
}
10+
source "$SCRIPT_DIR/lib/common.sh"
4111

4212
# Validate required environment variables
4313
validate_env() {
@@ -1788,14 +1758,6 @@ insert_sbom_data() {
17881758
# Global variable for temp directory (so cleanup can access it)
17891759
temp_dir=""
17901760

1791-
# Cleanup function
1792-
cleanup() {
1793-
if [[ -n "$temp_dir" && -d "$temp_dir" ]]; then
1794-
log_info "Cleaning up temporary files"
1795-
rm -rf "$temp_dir"
1796-
fi
1797-
}
1798-
17991761
# Main function
18001762
main() {
18011763
log_info "Starting ClickBOM GitHub Action for SBOM processing"

lib/common.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Common utilities used across all modules
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
BLUE='\033[0;34m'
9+
ORANGE='\033[0;33m'
10+
NC='\033[0m' # No Color
11+
12+
# Logging functions
13+
log_debug() {
14+
if [[ "${DEBUG:-false}" == "true" ]]; then
15+
echo -e "${ORANGE}[DEBUG]${NC} $1"
16+
fi
17+
}
18+
19+
log_info() {
20+
echo -e "${BLUE}[INFO]${NC} $1"
21+
}
22+
23+
log_success() {
24+
echo -e "${GREEN}[SUCCESS]${NC} $1"
25+
}
26+
27+
log_warning() {
28+
echo -e "${YELLOW}[WARNING]${NC} $1"
29+
}
30+
31+
log_error() {
32+
echo -e "${RED}[ERROR]${NC} $1"
33+
}
34+
35+
# Cleanup function
36+
cleanup() {
37+
if [[ -n "$temp_dir" && -d "$temp_dir" ]]; then
38+
log_info "Cleaning up temporary files"
39+
rm -rf "$temp_dir"
40+
fi
41+
}

license-mappings.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,34 @@
482482
"github.com/grpc-ecosystem/go-grpc-prometheus": "Apache-2.0",
483483
"github.com/grpc-ecosystem/grpc-gateway/v2": "BSD-3-Clause",
484484
"github.com/guptarohit/asciigraph": "BSD-3-Clause",
485+
"github.com/hailocab/go-hostpool": "MIT",
486+
"github.com/hako/durafmt": "MIT",
487+
"github.com/hashicorp/consul/api": "MPL-2.0",
488+
"github.com/hashicorp/errwrap": "MIT",
489+
"github.com/hashicorp/go-cleanhttp": "MPL-2.0",
490+
"github.com/hashicorp/go-hclog": "MIT",
491+
"github.com/hashicorp/go-immutable-radix": "MPL-2.0",
492+
"github.com/hashicorp/go-msgpack/v2": "MIT",
493+
"github.com/hashicorp/go-multierror": "MPL-2.0",
494+
"github.com/hashicorp/go-plugin": "MPL-2.0",
495+
"github.com/hashicorp/go-retryablehttp": "MPL-2.0",
496+
"github.com/hashicorp/go-rootcerts": "MPL-2.0",
497+
"github.com/hashicorp/go-secure-stdlib/parseutil": "MPL-2.0",
498+
"github.com/hashicorp/go-secure-stdlib/strutil": "MPL-2.0",
499+
"github.com/hashicorp/go-sockaddr": "MPL-2.0",
500+
"github.com/hashicorp/go-version": "MPL-2.0",
501+
"github.com/hashicorp/golang-lru": "MPL-2.0",
502+
"github.com/hashicorp/golang-lru/v2": "MPL-2.0",
503+
"github.com/hashicorp/hcl": "MPL-2.0",
504+
"github.com/hashicorp/hcl/v2": "MPL-2.0",
505+
"github.com/hashicorp/memberlist": "MPL-2.0",
506+
"github.com/hashicorp/serf": "MPL-2.0",
507+
"github.com/hashicorp/yamux": "MPL-2.0",
508+
"github.com/hexops/gotextdiff": "BSD-3-Clause",
509+
"github.com/hokaccha/go-prettyjson": "MIT",
510+
"github.com/homeport/dyff": "MIT",
511+
"github.com/huandu/xstrings": "MIT",
512+
"github.com/huaweicloud/huaweicloud-sdk-go-obs": "Apache-2.0",
485513
"github.com/Jeffail/gabs/v2": "MIT",
486514
"github.com/klauspost/compress": "BSD-3-Clause",
487515
"github.com/lufia/plan9stats": "BSD-3-Clause",

test/advanced.bats

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ setup() {
1515
# Extract only the functions from entrypoint.sh (everything before main function call)
1616
sed '/^# Run main function/,$d' "$PROJECT_ROOT/entrypoint.sh" > "$TEST_SCRIPT"
1717

18-
# Fix the lib/sanitize.sh source path in the extracted script
18+
# Replace the source line in the extracted script
1919
sed -i "s|source \"\$SCRIPT_DIR/lib/sanitize.sh\"|source \"$PROJECT_ROOT/lib/sanitize.sh\"|" "$TEST_SCRIPT"
20+
sed -i "s|source \"\$SCRIPT_DIR/lib/common.sh\"|source \"$PROJECT_ROOT/lib/common.sh\"|" "$TEST_SCRIPT"
2021

2122
# Source the functions
2223
source "$TEST_SCRIPT"

test/simple.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ setup() {
1818

1919
# Replace the source line in the extracted script
2020
sed -i "s|source \"\$SCRIPT_DIR/lib/sanitize.sh\"|source \"$PROJECT_ROOT/lib/sanitize.sh\"|" "$TEST_SCRIPT"
21+
sed -i "s|source \"\$SCRIPT_DIR/lib/common.sh\"|source \"$PROJECT_ROOT/lib/common.sh\"|" "$TEST_SCRIPT"
2122

2223
# Source the functions
2324
source "$TEST_SCRIPT"

0 commit comments

Comments
 (0)