Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ifneq ($(CLEAN_BUILD),)
endif

GOLANGCI_LINT_VERSION = v1.61.0
BASH_VERSION = v4.2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpinsonneau - just to confirm, this has to be 4.2 or some other version? I just suggested from vague memory :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Associative array been introduced in bash 4.0 alpha but been polished in 4.1 & 4.2 so it's safer to require 4.2 and more I guess.
If you are able to ensure it works on 4.0.0 I can change the value here.

There are still some fixes in the next versions but I feel less important than the firsts. WDYT ?

https://github.com/bminor/bash/blob/master/CHANGES

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am cool with recommending 4.2 then, thanks!

YQ_VERSION = v4.43.1

# build a single arch target provided as argument
Expand Down Expand Up @@ -151,6 +152,7 @@ commands: ## Generate either oc or kubectl plugins and add them to build folder
PULL_POLICY=$(PULL_POLICY) \
AGENT_IMAGE=$(AGENT_IMAGE) \
VERSION=$(VERSION) \
REQUIRED_BASH_VERSION=$(BASH_VERSION) \
REQUIRED_YQ_VERSION=$(YQ_VERSION) \
SUPPORTED_ARCHS=$(MULTIARCH_TARGETS) \
./scripts/inject.sh
Expand Down
5 changes: 3 additions & 2 deletions commands/netobserv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
source "./scripts/functions.sh"
source "./scripts/dependencies_check.sh"

Expand Down Expand Up @@ -94,7 +94,8 @@ function metrics() {
if [[ ! "$*" =~ ^(.*)help|version(.*) ]]; then
required_yq_version="v0.0.0"
supported_archs=""
check_dependencies "$required_yq_version" "$supported_archs"
required_bash_version="v0.0.0"
check_dependencies "$required_yq_version" "$supported_archs" "$required_bash_version"
fi

case "$1" in
Expand Down
12 changes: 12 additions & 0 deletions scripts/dependencies_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ function check_dependencies() {
else
echo "'yq' is up to date (version $current_yq_version)."
fi

current_bash_version="v${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]}"
required_bash_version="$3"
# Compare versions
compare_versions "${current_bash_version#v}" "${required_bash_version#v}"

if [ "$result" -eq 0 ]; then
echo "Please upgrade bash to $required_bash_version or up. Found version $current_bash_version."
exit 1
else
echo "'bash' is up to date (version $current_bash_version)."
fi
}

function compare_versions() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-doc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
ADOC=./docs/netobserv_cli.adoc

# Header
Expand Down
11 changes: 9 additions & 2 deletions scripts/inject.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -x

cp -a ./commands/. ./tmp
Expand Down Expand Up @@ -33,10 +33,17 @@ else
sed -i.bak "s/^version=.*/version=\"$VERSION\"/" ./tmp/netobserv
fi

if [ -z "$REQUIRED_BASH_VERSION" ]; then
echo "require bash version is not set, keeping the current version"
else
echo "updating dependencies to check for bash $REQUIRED_BASH_VERSION"
sed -i.bak "s/^required_bash_version=.*/required_bash_version=\"$REQUIRED_BASH_VERSION\"/" ./tmp/netobserv
fi

if [ -z "$REQUIRED_YQ_VERSION" ]; then
echo "require yq version is not set, keeping the current version"
else
echo "updating dependencies_check to check for $REQUIRED_YQ_VERSION"
echo "updating dependencies to check for yq $REQUIRED_YQ_VERSION"
sed -i.bak "s/^required_yq_version=.*/required_yq_version=\"$REQUIRED_YQ_VERSION\"/" ./tmp/netobserv
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/krew.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

SHA=$(sha256sum netobserv-cli.tar.gz | awk '{print $1}')

Expand Down
2 changes: 1 addition & 1 deletion scripts/update-config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

echo "Downloading frontend config from operator repo"
curl "https://raw.githubusercontent.com/netobserv/network-observability-operator/refs/heads/main/controllers/consoleplugin/config/static-frontend-config.yaml" -o ./cmd/config.yaml
Loading