Compare commits

...

4 Commits

Author SHA1 Message Date
Danny Bessems 44ac6b484d chore(release): 0.8.0 [skip ci]
# [0.8.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.3...v0.8.0) (2023-07-14)

### Bug Fixes

* Fix linebreak ([6f07cc8](6f07cc8d87))

### Features

* Continuous helm polling to update database ([a5e3c79](a5e3c79d10))
* Rebase sidecar container image ([dcb3dec](dcb3decbd3))
2023-07-14 11:44:02 +00:00
Danny Bessems 6f07cc8d87 fix: Fix linebreak
continuous-integration/drone/push Build is passing Details
2023-07-14 13:41:25 +02:00
Danny Bessems a5e3c79d10 feat: Continuous helm polling to update database
continuous-integration/drone/push Build is failing Details
2023-07-14 13:39:28 +02:00
Danny Bessems dcb3decbd3 feat: Rebase sidecar container image 2023-07-14 13:39:10 +02:00
5 changed files with 82 additions and 6 deletions

View File

@ -1,3 +1,16 @@
# [0.8.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.3...v0.8.0) (2023-07-14)
### Bug Fixes
* Fix linebreak ([6f07cc8](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/6f07cc8d876d49be0a798772b62f93b09efba110))
### Features
* Continuous helm polling to update database ([a5e3c79](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/a5e3c79d10a378336e5a6af267f7d28997cd9a8c))
* Rebase sidecar container image ([dcb3dec](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/dcb3decbd3d4e1507aba351f11cd4a148822b06b))
## [0.7.3](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.2...v0.7.3) (2023-07-14)

View File

@ -1,8 +1,27 @@
FROM node:lts-slim AS build
FROM alpine:latest AS download
RUN npm install -g --omit=optional --omit=dev \
RUN apk --update add --no-cache \
curl \
jq && \
curl -L https://api.github.com/repos/helm/helm/releases/latest | \
jq -r '.tag_name' | \
xargs -I {} curl -L -o /tmp/helm.tar.gz https://get.helm.sh/helm-{}-linux-amd64.tar.gz && \
tar -xzf /tmp/helm.tar.gz --strip-components=1 -C /tmp
FROM node:lts-slim
COPY --from=download /tmp/helm /usr/bin/helm
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
jq && \
npm install -g --omit=optional --omit=dev \
json-server && \
npm cache clean --force
npm cache clean --force && \
rm -rf /var/lib/apt/lists/*
COPY init/entrypoint.sh /opt/entrypoint.sh

View File

@ -54,6 +54,43 @@ data:
<script src="script.js"></script>
</body>
</html>
update.sh: |
#!/bin/sh
while getopts u: flag
do
case "${flag}" in
u) URL=${OPTARG};;
esac
done
[ $(curl -kLs -w "%{http_code}" -o /dev/null https://$URL) != 200 ] && {
echo 'Could not connect to' $URL
exit 1
}
echo '['$(date "+%Y-%m-%d %H:%M:%S")'] Started polling helm releases with 60 second interval'
while sleep 60;
do
echo '['$(date "+%Y-%m-%d %H:%M:%S")']' $(curl -ks https://$URL/components | jq length) 'known releases in database'
echo -n $(helm list --all-namespaces --output json | jq -c '.[]') | while IFS= read -r release;
do
APP_NAME=$(echo $release | jq -r '.name')
APP_ID=$(curl -ks https://$URL/components?name=$APP_NAME | jq -r '.[0].id')
# Release is not yet in database
[ "$APP_ID" == null ] && {
curl -ks -X POST https://$URL/components -H 'Content-Type: application/json' --data "$release"
}
# Release is already in database
[ "$APP_ID" != null ] && {
curl -ks -X PATCH https://$URL/components/$APP_ID -H 'Content-Type: application/json' --data "$release"
}
done
done
db.json: |
{{ include "common.tplvalues.render" ( dict "value" .Values.jsonServer.seedData.configInline "context" $) | indent 4 }}
{{- end -}}

View File

@ -62,7 +62,12 @@ spec:
command:
- /bin/sh
- -c
- sleep infinity
- "/opt/update.sh -u {{ .Values.sidecar.targetUrl }}"
volumeMounts:
- name: {{ .Release.Name }}-configmap
mountPath: /opt/update.sh
subPath: update.sh
defaultMode: 0744
volumes:
- name: {{ .Release.Name }}-configmap
configMap:

View File

@ -13,10 +13,12 @@ jsonServer:
tag: {{ image_tag }}
sidecar:
targetUrl: metadata.example.org
image:
repository: alpine/helm
repository: bv11-cr01.bessems.eu/library/json-server
pullPolicy: IfNotPresent
tag: 3.12.1
# Overrides the image tag whose default is the chart appVersion.
tag: {{ image_tag }}
replicaCount: 1