Skip to content

Commit

Permalink
added entrypoint for flagsets
Browse files Browse the repository at this point in the history
  • Loading branch information
mmelograno committed Jan 26, 2024
1 parent cadd5cc commit a5ecec4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions infra/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ TPL_FILE="${TPL_FILE:-${SCRIPT_DIR}/splitd.yaml.tpl}"
SPLITD_CFG_OUTPUT="${SPLITD_CFG_OUTPUT:-/etc/splitd.yaml}"
SPLITD_EXEC="${SPLITD_EXEC:-/opt/splitd/splitd}"

function prepare_sets() {
local RES="["
local IFS=','
read -ra SETS <<< "${1}"
for SET in "${SETS[@]}"; do
RES="${RES}\"${SET}\","
done
echo "${RES/%,}]"
}

# Validate mandatory arguments and initialize the template with those values
[ -z ${SPLITD_APIKEY+x} ] && echo "SPLITD_APIKEY env var is mandatory." && exit 1
[ -z ${SPLITD_LINK_ADDRESS+x} ] && echo "SPLITD_LINK_ADDRESS env var is mandatory." && exit 1
Expand Down Expand Up @@ -45,6 +55,11 @@ accum=$(yq '.sdk.apikey = env(SPLITD_APIKEY) | .link.address = env(SPLITD_LINK_A
[ ! -z ${SPLITD_EVENTS_REFRESH_SECS+x} ] && accum=$(echo "${accum}" | yq '.sdk.events.refreshRateSeconds = env(SPLITD_EVENTS_REFRESH_SECS)')
[ ! -z ${SPLITD_EVENTS_QUEUE_SIZE+x} ] && accum=$(echo "${accum}" | yq '.sdk.events.queueSize = env(SPLITD_EVENTS_QUEUE_SIZE)')

if [ ! -z ${SPLITD_FLAG_SETS_FILTER+x} ]; then
export PARSED_FLAGSETS=$(prepare_sets "${SPLITD_FLAG_SETS_FILTER}")
accum=$(echo "${accum}" | yq '.sdk.flagSetsFilter += env(PARSED_FLAGSETS)')
fi

# link configs
[ ! -z ${SPLITD_LINK_TYPE+x} ] && accum=$(echo "${accum}" | yq '.link.type = env(SPLITD_LINK_TYPE)')
[ ! -z ${SPLITD_LINK_SERIALIZATION+x} ] && accum=$(echo "${accum}" | yq '.link.serialization = env(SPLITD_LINK_SERIALIZATION)')
Expand Down
4 changes: 2 additions & 2 deletions infra/sidecar.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ----- Builder image
FROM golang:1.20.7-alpine3.18 AS builder
FROM golang:1.21.6-alpine3.19 AS builder

RUN apk add git build-base bash

Expand All @@ -8,7 +8,7 @@ COPY . .
RUN make clean splitd splitd.yaml.tpl

# ----- Runner image
FROM alpine:3.18 AS runner
FROM alpine:3.19.0 AS runner

RUN apk add gettext yq bash
RUN mkdir -p /opt/splitd
Expand Down

0 comments on commit a5ecec4

Please sign in to comment.