Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
kube-prometheus
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
prometheus-operator
kube-prometheus
Commits
ec4fabad
Commit
ec4fabad
authored
7 years ago
by
Eduardo Gonzalez
Browse files
Options
Downloads
Patches
Plain Diff
set options added to main script
parent
e517658b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hack/grafana-dashboards-configmap-generator/bin/grafana_dashboards_generate.sh
+15
-7
15 additions, 7 deletions
...ds-configmap-generator/bin/grafana_dashboards_generate.sh
with
15 additions
and
7 deletions
hack/grafana-dashboards-configmap-generator/bin/grafana_dashboards_generate.sh
+
15
−
7
View file @
ec4fabad
#!/bin/bash
# exit immediately when a command fails
set
-e
# only exit with zero if all commands of the pipeline exit successfully
set
-o
pipefail
# error on unset variables
set
-u
# Author: eedugon
# Description: Tool to maintain grafana dashboards configmap for a grafana deployed
...
...
@@ -124,7 +132,7 @@ addConfigMapHeader() {
# If a parameter is provided it will be used as the configmap index.
# If no parameter is provided, the name will be kept
test
"$#"
-le
1
||
{
echo
"# INTERNAL ERROR: Wrong call to function addConfigMapHeader"
;
return
1
;
}
local id
=
"
$1
"
test
"$#"
-eq
1
&&
local id
=
"
$1
"
||
local id
=
""
if
[
"
$id
"
]
;
then
cat
"
$CONFIGMAP_HEADER
"
|
sed
"s/name: grafana-dashboards/name: grafana-dashboards-
$id
/"
...
...
@@ -197,20 +205,20 @@ bin-pack-files() {
test
-f
"
$file
"
||
{
echo
"# INTERNAL ERROR: File not found:
$file
"
;
continue
;
}
# echo "debug: Processing file $(basename $file)"
file_size_bytes
=
"
$(
stat
-c
%s
"
$file
"
)
"
file_size_bytes
=
"
$(
stat
-c
%s
"
$file
"
)
"
||
true
# If the file is bigger than the configured limit we skip it file
if
[
"
$file_size_bytes
"
-gt
"
$DATA_SIZE_LIMIT
"
]
;
then
echo
"ERROR: File
$(
basename
$file
)
bigger than size limit:
$DATA_SIZE_LIMIT
(
$file_size_bytes
). Skipping"
continue
fi
((
total_files_processed++
))
((
total_files_processed++
))
||
true
if
test
"
$(
expr
"
$bytes_to_process
"
+
"
$file_size_bytes
"
)
"
-le
"
$DATA_SIZE_LIMIT
"
;
then
# We have room to include the file in the configmap
# test "$to_process" && to_process="$to_process $file" || to_process="$file"
to_process+
=(
"
$file
"
)
((
bytes_to_process
=
bytes_to_process + file_size_bytes
))
((
bytes_to_process
=
bytes_to_process + file_size_bytes
))
||
true
echo
"# File
$(
basename
$file
)
: added to queue"
else
# There's no room to add this file to the queue. so we process what we have and add the file to the queue
...
...
@@ -222,8 +230,8 @@ bin-pack-files() {
addConfigMapHeader
$n
>>
$OUTPUT_FILE
||
{
echo
"ERROR in call to addConfigMapHeader function"
;
exit
1
;
}
addArrayToConfigMap
>>
$OUTPUT_FILE
||
{
echo
"ERROR in call to addArrayToConfigMap function"
;
exit
1
;
}
# Initialize variables with info about file not processed
((
total_configmaps_created++
))
((
n++
))
((
total_configmaps_created++
))
||
true
((
n++
))
||
true
# to_process="$file"
to_process
=()
to_process+
=(
"
$file
"
)
...
...
@@ -286,7 +294,7 @@ if [ "$to_process" ]; then
addConfigMapHeader
$n
>>
$OUTPUT_FILE
||
{
echo
"ERROR in call to addConfigMapHeader function"
;
exit
1
;
}
fi
addArrayToConfigMap
>>
$OUTPUT_FILE
||
{
echo
"ERROR in call to addArrayToConfigMap function"
;
exit
1
;
}
((
total_configmaps_created++
))
((
total_configmaps_created++
))
||
true
to_process
=()
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment