Skip to content

Commit

Permalink
Rewrote entrypoint script. Now that environment variables are nativel…
Browse files Browse the repository at this point in the history
…y supported, there is no need for templating the configuration file.
  • Loading branch information
mrlhansen committed Jul 31, 2024
1 parent 7dac8e9 commit fa0cd16
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Jetbrains IDE local configs
/.idea/
.idea
.vscode
.DS_Store
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ FROM ${ARCH}alpine:3.18 as container
WORKDIR /app
COPY --from=builder /app/src/idrac_exporter /app/bin/
RUN apk add -U bash gettext

This comment has been minimized.

Copy link
@svenfoo

svenfoo Jul 31, 2024

As far as I can see you do not need gettext any longer. It was installed for envsubst, right?

This comment has been minimized.

Copy link
@mrlhansen

mrlhansen Jul 31, 2024

Author Owner

You are right. I am going to make another commit, I also have to make adjustments for the Helm chart.

COPY idrac.yml.template /etc/prometheus/
COPY default-config.yml /etc/prometheus/idrac.yml
COPY entrypoint.sh /app
ENTRYPOINT /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
17 changes: 17 additions & 0 deletions default-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
address: 0.0.0.0
port: 9348
hosts:
default:
username: root
password: calvin
metrics:
system: true
sensors: true
power: true
events: true
storage: true
memory: true
network: true
events:
severity: warning
maxage: 7d
23 changes: 5 additions & 18 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
#!/bin/bash

config=/etc/prometheus/idrac.yml

if [[ ! -z "$IDRAC_USERNAME" ]] && [[ ! -z "$IDRAC_PASSWORD" ]]; then
envsubst <${config}.template > /app/config/idrac.yml
config=/app/config/idrac.yml
elif [ ! -e "$config" ]; then
auth_file=/authconfig/$NODE_NAME

if [ ! -e "$auth_file" ]; then
>&2 echo "$config not found _and_ $auth_file not found."
else
# auth_file contents are in the format: user=password
export IDRAC_USERNAME=$(cut -f1 -d= $auth_file)
export IDRAC_PASSWORD=$(cut -f2- -d= $auth_file)
envsubst <${config}.template > /app/config/idrac.yml
fi

auth_file="/authconfig/$NODE_NAME"
if [ -f "$auth_file" ]; then
export CONFIG_DEFAULT_USERNAME=$(cut -f1 -d= $auth_file)
export CONFIG_DEFAULT_PASSWORD=$(cut -f2- -d= $auth_file)
fi

exec bin/idrac_exporter -config="$config"
exec bin/idrac_exporter "$@"
15 changes: 0 additions & 15 deletions idrac.yml.template

This file was deleted.

0 comments on commit fa0cd16

Please sign in to comment.