11 Commits

Author SHA1 Message Date
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
6f07cc8d87 fix: Fix linebreak
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 13:41:25 +02:00
a5e3c79d10 feat: Continuous helm polling to update database
Some checks failed
continuous-integration/drone/push Build is failing
2023-07-14 13:39:28 +02:00
dcb3decbd3 feat: Rebase sidecar container image 2023-07-14 13:39:10 +02:00
3c141a2d40 chore(release): 0.7.3 [skip ci]
## [0.7.3](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.2...v0.7.3) (2023-07-14)

### Bug Fixes

* Missing period in chart template ([0999fdf](0999fdf705))
2023-07-14 08:45:47 +00:00
0999fdf705 fix: Missing period in chart template
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:43:47 +02:00
6c71c5f364 chore(release): 0.7.2 [skip ci]
## [0.7.2](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.1...v0.7.2) (2023-07-14)

### Bug Fixes

* Adhere to naming convention in templates ([c551a24](c551a242c7))
2023-07-14 08:42:11 +00:00
c551a242c7 fix: Adhere to naming convention in templates
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:40:08 +02:00
ec36309d8d chore(release): 0.7.1 [skip ci]
## [0.7.1](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.0...v0.7.1) (2023-07-14)

### Bug Fixes

* Adhere to naming convention in values.yaml ([614fda9](614fda9b7d))
2023-07-14 08:39:28 +00:00
93ff24ac73 Merge branch 'main' of https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer into main
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:37:21 +02:00
614fda9b7d fix: Adhere to naming convention in values.yaml 2023-07-14 10:37:10 +02:00
7 changed files with 117 additions and 20 deletions

View File

@ -48,7 +48,7 @@ steps:
pull: always
commands:
- |
export IMAGE_TAG=$(cat .version 2> /dev/null) && [ -n "$IMAGE_TAG" ] || (echo 'No release tag - exiting'; exit 0)
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
- |
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
chmod +x /bin/jq
@ -59,7 +59,7 @@ steps:
--dockerfile=Dockerfile \
--context=dir://. \
--destination=bv11-cr01.bessems.eu/library/json-server:latest \
--destination=bv11-cr01.bessems.eu/library/json-server:$IMAGE_TAG
--destination=bv11-cr01.bessems.eu/library/json-server:$VALID_TAG
environment:
HARBOR_USERNAME:
from_secret: harbor_username
@ -73,7 +73,7 @@ steps:
pull: always
commands:
- |
export IMAGE_TAG=$(cat .version 2> /dev/null) && [ -n "$IMAGE_TAG" ] || (echo 'No release tag - exiting'; exit 0)
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
- |
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
chmod +x /bin/jq
@ -84,7 +84,7 @@ steps:
--dockerfile=Dockerfile \
--context=dir://. \
--destination=docker.io/djpbessems/json-server:latest \
--destination=docker.io/djpbessems/json-server:$IMAGE_TAG
--destination=docker.io/djpbessems/json-server:$VALID_TAG
environment:
DOCKER_USERNAME:
from_secret: docker_username
@ -98,9 +98,9 @@ steps:
pull: always
commands:
- |
export CHART_VERSION=$(cat .version 2> /dev/null) && [ -n "$CHART_VERSION" ] || (echo 'No release tag - exiting'; exit 0)
sed -i 's/{{ chart_version }}/'$CHART_VERSION'/g' charts/json-server/Chart.yaml
sed -i 's/tag: latest/tag: '$CHART_VERSION'/g' charts/json-server/values.yaml
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
sed -i 's/{{ chart_version }}/'$VALID_TAG'/g' charts/json-server/Chart.yaml
sed -i 's/{{ image_tag }}/'$VALID_TAG'/g' charts/json-server/values.yaml
- |
helm package ./charts/json-server
- |

View File

@ -1,3 +1,37 @@
# [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)
### Bug Fixes
* Missing period in chart template ([0999fdf](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/0999fdf7051d6e8a2161333980bd1aedd9f180ef))
## [0.7.2](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.1...v0.7.2) (2023-07-14)
### Bug Fixes
* Adhere to naming convention in templates ([c551a24](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/c551a242c7a49a445da68ba6e1e5966eeb5ce7d7))
## [0.7.1](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.0...v0.7.1) (2023-07-14)
### Bug Fixes
* Adhere to naming convention in values.yaml ([614fda9](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/614fda9b7d284862bd84a1eab62ba8144f798199))
# [0.7.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.6.0...v0.7.0) (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

@ -5,7 +5,7 @@ metadata:
subjects:
- kind: ServiceAccount
name: {{ include "json-server.serviceAccountName" . }}
namespace: {{ Release.Namespace }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Release.Name }}-clusterrole

View File

@ -1,4 +1,4 @@
{{- if not .Values.json-server.seedData.existingConfigMap }}
{{- if not .Values.jsonServer.seedData.existingConfigMap }}
apiVersion: v1
kind: ConfigMap
metadata:
@ -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.json-server.seedData.configInline "context" $) | indent 4 }}
{{ include "common.tplvalues.render" ( dict "value" .Values.jsonServer.seedData.configInline "context" $) | indent 4 }}
{{- end -}}

View File

@ -29,8 +29,8 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.json-server.image.repository }}:{{ .Values.json-server.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.json-server.image.pullPolicy }}
image: "{{ .Values.jsonServer.image.repository }}:{{ .Values.jsonServer.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.jsonServer.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
@ -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

@ -1,6 +1,6 @@
# Default values for json-server.
json-server:
jsonServer:
seedData:
# Not implemented yet
# existingConfigMap: ""
@ -10,13 +10,15 @@ json-server:
repository: bv11-cr01.bessems.eu/library/json-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: latest
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