Skip to content

Commit a0ea5a1

Browse files
build(deps): Bump aquasecurity/trivy-action from 0.29.0 to 0.30.0 (#1523) (#1527)
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.29.0 to 0.30.0. - [Release notes](https://github.com/aquasecurity/trivy-action/releases) - [Commits](aquasecurity/trivy-action@0.29.0...0.30.0) --- updated-dependencies: - dependency-name: aquasecurity/trivy-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 57d3661 commit a0ea5a1

File tree

11 files changed

+171
-123
lines changed

11 files changed

+171
-123
lines changed

.github/workflows/main.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
tags:
99
- 'v*'
1010
paths:
11+
- ".github/workflows/main.yaml"
1112
- ".github/workflows/build-op-image.yaml"
1213
- "apis/**"
1314
- "cmd/**"
@@ -16,6 +17,7 @@ on:
1617
- "manifests/setup/setup.yaml"
1718
- "tests/**"
1819
- "pkg/**"
20+
- "**/*.sh"
1921
- "Makefile"
2022
- "go.mod"
2123
- "go.sum"
@@ -24,6 +26,7 @@ on:
2426
- 'master'
2527
- 'release-*'
2628
paths:
29+
- ".github/workflows/main.yaml"
2730
- ".github/workflows/build-op-image.yaml"
2831
- "apis/**"
2932
- "cmd/**"
@@ -32,6 +35,7 @@ on:
3235
- "manifests/setup/setup.yaml"
3336
- "tests/**"
3437
- "pkg/**"
38+
- "**/*.sh"
3539
- "Makefile"
3640
- "go.mod"
3741
- "go.sum"
@@ -54,6 +58,9 @@ jobs:
5458
go-version-file: go.mod
5559
cache-dependency-path: go.sum
5660

61+
- name: Check shell scripts
62+
run: make shellcheck
63+
5764
- name: Go mod
5865
run: |
5966
export PATH=$PATH:$(go env GOPATH)/bin

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ help: ## Display this help.
4747

4848
##@ Development
4949

50+
shellcheck:
51+
@find . -type f -name *.sh -exec docker run --rm -v $(shell pwd):/mnt koalaman/shellcheck:stable {} +
52+
5053
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
5154
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases
5255
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=config/crd/bases
@@ -69,7 +72,7 @@ ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
6972

7073
install-setup-envtest: ## Install the setup-envtest tool if it is not already installed
7174
if ! command -v setup-envtest &> /dev/null; then \
72-
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest; \
75+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest; \
7376
fi
7477

7578
setup-envtest: install-setup-envtest ## Download and set up the envtest binary

cmd/fluent-watcher/hooks/post-hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set -e
99

1010
HOST_ARCH=$(uname -m)
1111

12-
if [ x"${HOST_ARCH}" == x"aarch64" ]; then
12+
if [ "${HOST_ARCH}" == "aarch64" ]; then
1313
echo "Building arm64 image natively"
1414
exit
1515
fi

cmd/upgrade/upgrade.sh

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,53 @@ function error_exit {
88
}
99

1010
function migrate(){
11-
## Converting an existing configuration to a new one
12-
local oldKind=$1
13-
local newKind=$2
14-
local list=$(kubectl get $oldKind.logging.kubesphere.io -A -o json) || error_exit "Cannot get resource $oldKind"
15-
local name=($(echo $list | jq -r '.items[].metadata.name | @json'))
16-
local labels=($(echo $list | jq -r '.items[].metadata.labels | @json'))
17-
local spec=($(echo $list | jq -r '.items[].spec | @json'))
18-
local ns=($(echo $list | jq -r '.items[].metadata.namespace | @json'))
19-
local size=${#spec[*]}
20-
echo "Number of original $oldKind configuration files:$size"
21-
for((i=0;i<${size};i++));do
22-
if [[ "${kind}" = "fluentbits" ]]; then
23-
cluster_resource_list[i]="{
24-
\"apiVersion\": \"fluentbit.fluent.io/v1alpha2\",
25-
\"kind\": \"${newKind}\",
26-
\"metadata\": {
27-
\"name\": ${name[i]},
28-
\"labels\": ${labels[i]},
29-
\"namespace\": \"${ns}\"
30-
},
31-
\"spec\": ${spec[i]}
32-
}"
33-
else
34-
cluster_resource_list[i]="{
35-
\"apiVersion\": \"fluentbit.fluent.io/v1alpha2\",
36-
\"kind\": \"${kind}\",
37-
\"metadata\": {
38-
\"name\": ${name[i]},
39-
\"labels\": ${labels[i]}
40-
},
41-
\"spec\": ${spec[i]}
42-
}"
43-
fi
44-
done
11+
## Converting an existing configuration to a new one
12+
local list name labels spec ns size
13+
local oldKind=$1
14+
local newKind=$2
15+
list=$(kubectl get "$oldKind.logging.kubesphere.io" -A -o json) || error_exit "Cannot get resource $oldKind"
16+
mapfile -t name < <(echo "$list" | jq -r '.items[].metadata.name | @json')
17+
mapfile -t labels < <(echo "$list" | jq -r '.items[].metadata.labels | @json')
18+
mapfile -t spec < <(echo "$list" | jq -r '.items[].spec | @json')
19+
mapfile -t ns < <(echo "$list" | jq -r '.items[].metadata.namespace | @json')
20+
size=${#spec[*]}
21+
echo "Number of original $oldKind configuration files:$size"
22+
for ((i=0; i < size; i++)); do
23+
if [[ "$newKind" = "fluentbits" ]]; then
24+
cluster_resource_list[i]="{
25+
\"apiVersion\": \"fluentbit.fluent.io/v1alpha2\",
26+
\"kind\": \"${newKind}\",
27+
\"metadata\": {
28+
\"name\": ${name[i]},
29+
\"labels\": ${labels[i]},
30+
\"namespace\": \"${ns[i]}\"
31+
},
32+
\"spec\": ${spec[i]}
33+
}"
34+
else
35+
cluster_resource_list[i]="{
36+
\"apiVersion\": \"fluentbit.fluent.io/v1alpha2\",
37+
\"kind\": \"${oldKind}\",
38+
\"metadata\": {
39+
\"name\": ${name[i]},
40+
\"labels\": ${labels[i]}
41+
},
42+
\"spec\": ${spec[i]}
43+
}"
44+
fi
45+
done
4546

46-
## Uninstall the fluentbit-operator and the original configuration
47-
for((i=0;i<${size};i++));do
48-
echo "${name[i]}"
49-
temp=$(echo ${name[i]} | sed 's/"//g')
50-
echo "$temp"
51-
kubectl delete $oldKind.logging.kubesphere.io $temp -n ${namespace}
52-
done
47+
## Uninstall the fluentbit-operator and the original configuration
48+
for ((i=0; i < size; i++)); do
49+
echo "${name[i]}"
50+
temp="${name[i]//\"/}"
51+
echo "$temp"
52+
kubectl delete "$oldKind.logging.kubesphere.io" "$temp" -n ${namespace}
53+
done
5354

54-
for((i=0;i<${size};i++));do
55-
echo ${cluster_resource_list[i]} | kubectl apply -f - || error_exit "Cannot apply resource $oldKind"
56-
done
55+
for ((i=0; i<size; i++)); do
56+
kubectl apply -f "${cluster_resource_list[i]}" || error_exit "Cannot apply resource $oldKind"
57+
done
5758
}
5859

5960
migrate "Input" "ClusterInput"
@@ -65,15 +66,15 @@ migrate "FluentBit" "FluentBit"
6566

6667
# Determine if Deployment exists
6768
if kubectl get deployment -n $namespace $FluentbitOperator >/dev/null 2>&1; then
68-
# Delete Deployment if it exists
69-
kubectl delete deployment -n $namespace $FluentbitOperator
70-
kubectl delete clusterrolebinding kubesphere:operator:fluentbit-operator
71-
kubectl delete clusterrole kubesphere:operator:fluentbit-operator
72-
kubectl delete serviceaccount fluentbit-operator -n $namespace
73-
echo "Deployment $FluentbitOperator deleted"
69+
# Delete Deployment if it exists
70+
kubectl delete deployment -n $namespace $FluentbitOperator
71+
kubectl delete clusterrolebinding kubesphere:operator:fluentbit-operator
72+
kubectl delete clusterrole kubesphere:operator:fluentbit-operator
73+
kubectl delete serviceaccount fluentbit-operator -n $namespace
74+
echo "Deployment $FluentbitOperator deleted"
7475
else
75-
# If it does not exist, output the message
76-
echo "Deployment $FluentbitOperator does not exist"
76+
# If it does not exist, output the message
77+
echo "Deployment $FluentbitOperator does not exist"
7778
fi
7879

7980
## Delete the old crd

hack/update-codegen.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,39 @@ SCRIPT_ROOT=$(git rev-parse --show-toplevel)
1010

1111
# Grab code-generator version from go.sum.
1212
CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | head -1 |cut -b 1-7)
13-
CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}")
13+
CODEGEN_PKG="$(go env GOPATH)/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}"
1414

1515
# code-generator does work with go.mod but makes assumptions about
1616
# the project living in `$GOPATH/src`. To work around this and support
1717
# any location; create a temporary directory, use this as an output
1818
# base, and copy everything back once generated.
1919
TEMP_DIR=$(mktemp -d)
2020
cleanup() {
21-
echo ">> Removing ${TEMP_DIR}"
22-
rm -rf ${TEMP_DIR}
21+
echo ">> Removing ${TEMP_DIR}"
22+
rm -rf "$TEMP_DIR"
2323
}
2424
trap "cleanup" EXIT SIGINT
2525

2626
echo ">> Temporary output directory ${TEMP_DIR}"
2727

2828
# Ensure we can execute.
29-
chmod +x ${CODEGEN_PKG}/kube_codegen.sh
29+
chmod +x "${CODEGEN_PKG}/kube_codegen.sh"
3030

3131
PACKAGE_PATH_BASE="github.com/fluent/fluent-operator/v3"
3232

3333
mkdir -p "${TEMP_DIR}/${PACKAGE_PATH_BASE}/apis/fluentbit" \
3434
"${TEMP_DIR}/${PACKAGE_PATH_BASE}/apis/fluentd" \
3535
"${TEMP_DIR}/${PACKAGE_PATH_BASE}/apis/generated"
3636

37-
source ${CODEGEN_PKG}/kube_codegen.sh kube::codegen::gen_client \
38-
--output-dir "${TEMP_DIR}" \
37+
# shellcheck source=/dev/null
38+
source "${CODEGEN_PKG}/kube_codegen.sh" kube::codegen::gen_client \
39+
--output-dir "$TEMP_DIR" \
3940
--with-watch \
4041
--output-pkg "${PACKAGE_PATH_BASE}/apis/generated" \
4142
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
4243
./apis
4344

44-
ls -lha $TEMP_DIR
45+
ls -lha "$TEMP_DIR"
4546

4647
# Copy everything back.
47-
cp -r "${TEMP_DIR}/${PACKAGE_PATH_BASE}/." "${SCRIPT_ROOT}"
48+
cp -r "${TEMP_DIR}/${PACKAGE_PATH_BASE}/." "$SCRIPT_ROOT"

hack/update-helm-package.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
set -o errexit
24
set -o nounset
35
set -o pipefail
@@ -6,4 +8,8 @@ FLUENT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
68
FLUENT_HELM_DIR=${FLUENT_ROOT}/charts/fluent-operator
79
_tmpdir=/tmp/fluent-operator
810

9-
cd $FLUENT_HELM_DIR && helm package . -d ${_tmpdir} > /dev/null && mv ${_tmpdir}/*.tgz $FLUENT_HELM_DIR/../fluent-operator.tgz && rm -rf "${_tmpdir}"
11+
pushd "$FLUENT_HELM_DIR" >/dev/null
12+
helm package . -d ${_tmpdir} > /dev/null
13+
mv ${_tmpdir}/*.tgz "$FLUENT_HELM_DIR/../fluent-operator.tgz"
14+
rm -rf "${_tmpdir}"
15+
popd >/dev/null

hack/verify-codegen.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ set -o pipefail
88

99
SCRIPT_ROOT=$(git rev-parse --show-toplevel)
1010

11-
1211
DIFFROOT="${SCRIPT_ROOT}/apis"
1312
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/apis"
1413

1514
_tmp="${SCRIPT_ROOT}/_tmp"
1615

1716
cleanup() {
1817
echo ">> Removing ${_tmp}"
19-
rm -rf ${_tmp}
18+
rm -rf "${_tmp}"
2019
}
2120
trap "cleanup" EXIT SIGINT
2221

@@ -36,4 +35,4 @@ then
3635
else
3736
echo "${DIFFROOT} is out of date. Please rerun make generate"
3837
exit 1
39-
fi
38+
fi

hack/verify-crds.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7-
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
7+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
88
CRD_OPTIONS="crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true"
99

1010
DIFFROOT="${SCRIPT_ROOT}/config/crd/bases/"
@@ -21,8 +21,8 @@ cleanup
2121
mkdir -p "${TMP_DIFFROOT}"
2222
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
2323

24-
./bin/controller-gen $CRD_OPTIONS rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases/
25-
./bin/controller-gen $CRD_OPTIONS rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=config/crd/bases/
24+
./bin/controller-gen "$CRD_OPTIONS" rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases/
25+
./bin/controller-gen "$CRD_OPTIONS" rbac:roleName=manager-role webhook paths="./apis/fluentd/..." output:crd:artifacts:config=config/crd/bases/
2626
echo "diffing ${DIFFROOT} against freshly generated crds"
2727
ret=0
2828
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?

hack/verify-helm-package.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
set -o errexit
24
set -o nounset
35
set -o pipefail
@@ -8,9 +10,14 @@ _tmpdir=/tmp/fluent-operator
810

911
function verify:package:helm:files {
1012
mkdir -p ${_tmpdir}
11-
cd $FLUENT_HELM_DIR && helm package . -d ${_tmpdir} > /dev/null && mv ${_tmpdir}/*.tgz ${_tmpdir}/fluent-operator.tgz
12-
helm_checksum=$(tar -xOzf ${FLUENT_HELM_DIR}/../fluent-operator.tgz | sort | sha1sum | awk '{ print $1 }')
13-
temp_helm_checksum=$(tar -xOzf ${_tmpdir}/fluent-operator.tgz | sort | sha1sum | awk '{ print $1 }')
13+
14+
pushd "$FLUENT_HELM_DIR" >/dev/null
15+
helm package . -d ${_tmpdir} > /dev/null
16+
mv ${_tmpdir}/*.tgz "${_tmpdir}/fluent-operator.tgz"
17+
helm_checksum=$(tar -xOzf "${FLUENT_HELM_DIR}/../fluent-operator.tgz" | sort | sha1sum | awk '{ print $1 }')
18+
temp_helm_checksum=$(tar -xOzf "${_tmpdir}/fluent-operator.tgz" | sort | sha1sum | awk '{ print $1 }')
19+
popd >/dev/null
20+
1421
if [ "$helm_checksum" != "$temp_helm_checksum" ]; then
1522
echo "Helm package fluent-operator.tgz not updated or the helm chart is not expected."
1623
echo "Please run: make update-helm-package"
@@ -23,7 +30,6 @@ function cleanup {
2330
rm -rf "${_tmpdir}"
2431
}
2532

26-
trap "cleanup" EXIT SIGINT
33+
trap cleanup EXIT SIGINT
2734

2835
verify:package:helm:files
29-
cleanup

0 commit comments

Comments
 (0)