Skip to content

Commit b479fdc

Browse files
committed
feat: init acrloader
0 parents  commit b479fdc

27 files changed

+2254
-0
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
venv
2+
acrloader.conf
3+
.coverage
4+
__pycache__/

.github/dependabot.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: pip
8+
directory: "/"
9+
schedule:
10+
interval: "daily"
11+
- package-ecosystem: "docker"
12+
directory: "/"
13+
schedule:
14+
interval: "daily"

.github/workflows/release.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
pull_request:
8+
9+
jobs:
10+
python-poetry:
11+
uses: radiorabe/actions/.github/workflows/release-python-poetry.yaml@v0.10.0
12+
secrets:
13+
RABE_PYPI_TOKEN: ${{ secrets.RABE_PYPI_TOKEN }}
14+
release-container:
15+
uses: radiorabe/actions/.github/workflows/release-container.yaml@v0.10.0
16+
needs:
17+
- python-poetry
18+
with:
19+
image: 'ghcr.io/radiorabe/acrloader'
20+
name: 'acrloader'
21+
display-name: 'RaBe ACR Loader'
22+
tags: 'minimal rhel9 rabe s2i python python311 acr owncloud'
23+
helm-chart:
24+
runs-on: ubuntu-latest
25+
if: startsWith(github.ref, 'refs/tags/v')
26+
needs:
27+
- release-container
28+
permissions:
29+
actions: none
30+
checks: none
31+
contents: none
32+
deployments: none
33+
issues: none
34+
packages: write
35+
pull-requests: none
36+
repository-projects: none
37+
security-events: none
38+
statuses: none
39+
id-token: none
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
44+
- name: Prepare Chart Metadata
45+
id: meta
46+
run: echo version=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT
47+
48+
- name: Set up Helm
49+
uses: azure/setup-helm@v3.5
50+
with:
51+
version: v3.12.0
52+
53+
- name: Package Chart
54+
run: helm package --version ${{ steps.meta.outputs.version }} --app-version ${{ steps.meta.outputs.version }} --destination=dist charts/acrloader
55+
56+
- name: Login to GitHub Container Registry
57+
uses: docker/login-action@v2
58+
with:
59+
registry: ghcr.io
60+
username: ${{ github.actor }}
61+
password: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Push Chart
64+
run: helm push dist/*.tgz oci://ghcr.io/radiorabe/helm

.github/workflows/schedule.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Scheduled tasks
2+
3+
on:
4+
schedule:
5+
- cron: '13 12 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
call-workflow:
10+
uses: radiorabe/actions/.github/workflows/schedule-trivy.yaml@v0.10.0
11+
with:
12+
image-ref: 'ghcr.io/radiorabe/acrloader:latest'
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Semantic Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
9+
jobs:
10+
semantic-release:
11+
uses: radiorabe/actions/.github/workflows/semantic-release.yaml@v0.10.0
12+
secrets:
13+
RABE_ITREAKTION_GITHUB_TOKEN: ${{ secrets.RABE_ITREAKTION_GITHUB_TOKEN }}

.github/workflows/test.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pre-commit:
8+
uses: radiorabe/actions/.github/workflows/test-pre-commit.yaml@v0.10.0
9+
python-poetry:
10+
uses: radiorabe/actions/.github/workflows/test-python-poetry.yaml@v0.10.0
11+
with:
12+
version: '3.11'
13+
helm-chart:
14+
name: Test Helm Chart
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Build dev image
22+
run: |
23+
docker build -t ghcr.io/radiorabe/acrloader:latest -f Dockerfile .
24+
docker save -o /tmp/acrloader.tar ghcr.io/radiorabe/acrloader:latest
25+
26+
- name: Set up Helm
27+
uses: azure/setup-helm@v3.5
28+
with:
29+
version: v3.12.0
30+
31+
- uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.x'
34+
35+
- name: Install chart-testing
36+
uses: helm/chart-testing-action@v2.3.1
37+
38+
- name: Run chart-testing (list-changed)
39+
id: list-changed
40+
run: |
41+
changed=$(ct --config=.github/ct.yaml list-changed)
42+
if [[ -n "$changed" ]]; then
43+
echo "changed=true" >> $GITHUB_OUTPUT
44+
fi
45+
46+
- name: Run chart-testing (lint)
47+
run: ct --config=.github/ct.yaml lint
48+
49+
- name: Create kind cluster
50+
uses: helm/kind-action@v1.5.0
51+
if: steps.list-changed.outputs.changed == 'true'
52+
53+
- name: Load dev image
54+
run: |
55+
kind load image-archive /tmp/acrloader.tar --name chart-testing
56+
if: steps.list-changed.outputs.changed == 'true'
57+
58+
- name: Run chart-testing (install)
59+
run: ct --config=.github/ct.yaml install

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
venv
2+
acrloader.conf
3+
.coverage
4+
__pycache__/

.pre-commit-config.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v2.31.1
4+
hooks:
5+
- id: pyupgrade
6+
args:
7+
- --py311-plus
8+
- repo: https://github.com/charliermarsh/ruff-pre-commit
9+
# Ruff version.
10+
rev: "v0.0.269"
11+
hooks:
12+
- id: ruff
13+
args: [--fix, --exit-non-zero-on-fix]
14+
- repo: local
15+
hooks:
16+
- id: black
17+
name: black
18+
language: system
19+
entry: black
20+
types: [python]
21+
- repo: https://github.com/pre-commit/pre-commit-hooks
22+
rev: v4.4.0
23+
hooks:
24+
- id: trailing-whitespace
25+
exclude: ^src/api/client.js$
26+
- id: end-of-file-fixer
27+
exclude: ^src/api/client.js$
28+
- id: check-symlinks
29+
- id: check-merge-conflict
30+
- id: check-case-conflict
31+
- id: detect-aws-credentials
32+
args:
33+
- --allow-missing-credentials
34+
- id: detect-private-key

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ghcr.io/radiorabe/s2i-python:2.0.0-alpha.11 AS build
2+
3+
COPY --chown=1001:0 ./ /opt/app-root/src/
4+
5+
RUN python3.11 -mbuild
6+
7+
8+
FROM ghcr.io/radiorabe/python-minimal:2.0.0-alpha.15 AS app
9+
10+
COPY --from=build /opt/app-root/src/dist/*.whl /tmp/dist/
11+
12+
RUN microdnf install -y \
13+
python3.11-pip \
14+
&& python3.11 -mpip --no-cache-dir install /tmp/dist/*.whl \
15+
&& microdnf remove -y \
16+
python3.11-pip \
17+
python3.11-setuptools \
18+
&& microdnf clean all \
19+
&& rm -rf /tmp/dist/
20+
21+
USER nobody
22+
23+
CMD ["acrloader"]

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ACR Loader
2+
3+
Loads data from ACRCloud's broadcat monitoring service and stores it
4+
in our ownCloud instance. Runs as a cronjob and is scheduled to run
5+
once per day.
6+
7+
## Usage
8+
9+
```
10+
helm install my-acrloader oci://ghcr.io/radiorabe/helm/acrloader \
11+
--version x.y.z \
12+
--set acr.bearerToken=<token>,acr.projectId=<pid>,streamId=<sid> \
13+
--set oc.url=<url>,oc.user=<user>,oc.pass=<pass>,oc.path=<path>
14+
```
15+
16+
## Development
17+
18+
```
19+
python -mvenv venv
20+
. venv/bin/activate
21+
22+
python -mpip install poetry
23+
24+
poetry install
25+
26+
poetry run pytest
27+
28+
pre-commit run
29+
```
30+
31+
## License
32+
This application is free software: you can redistribute it and/or modify it under
33+
the terms of the GNU Affero General Public License as published by the Free
34+
Software Foundation, version 3 of the License.
35+
36+
## Copyright
37+
Copyright (c) 2023 [Radio Bern RaBe](http://www.rabe.ch)

acrloader.conf.example

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ACRCloud Bearer token
2+
acrcloud-bearer-token=
3+
# ACRCloud project id
4+
acr-project-id=
5+
# ACRCloud stream id
6+
acr-stream-id=
7+
# owncloud URL
8+
oc-url=
9+
# ownCloud user
10+
oc-user=
11+
# ownCloud pass
12+
oc-pass=

catalog-info.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
apiVersion: backstage.io/v1alpha1
3+
kind: Component
4+
metadata:
5+
name: acr-loader
6+
description: Loads data from ACRCloud's broadcast monitoring and stores it in ownCloud.
7+
annotations:
8+
backstage.io/techdocs-ref: dir:.
9+
github.com/project-slug: radiorabe/acr-loader
10+
spec:
11+
type: service
12+
lifecycle: experimental
13+
owner: it-reaktion

charts/acrloader/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/acrloader/Chart.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: acrloader
3+
description: RaBe ACR Loader
4+
type: application
5+
version: 0.0.0
6+
appVersion: "0.0.0"

charts/acrloader/templates/NOTES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1. The following CronJob was deployed
2+
* {{ include "acrloader.fullname" . }} (schedule: {{ .Values.schedule | quote }})
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "acrloader.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "acrloader.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "acrloader.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "acrloader.labels" -}}
37+
helm.sh/chart: {{ include "acrloader.chart" . }}
38+
{{ include "acrloader.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "acrloader.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "acrloader.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "acrloader.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "acrloader.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)