add resource loading to yaml
This commit is contained in:
parent
bfcabbdf11
commit
f5d6d6f27b
5 changed files with 40 additions and 31 deletions
|
@ -1,5 +1,6 @@
|
|||
{:source-paths ["src/main/cljc"
|
||||
"src/main/cljs"
|
||||
"src/main/resources"
|
||||
"src/test/cljc"]
|
||||
:dependencies [[aero "1.1.6"]]
|
||||
:builds {:test {:target :node-test
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
(ns dda.k8s-mastodon-bot.yaml
|
||||
(:require
|
||||
["js-yaml" :as yaml]
|
||||
[shadow.resource :as rc]
|
||||
))
|
||||
|
||||
(def config (rc/inline "config.yaml"))
|
||||
|
||||
(defn load-resource [resource-name]
|
||||
config)
|
||||
|
||||
(defn from-string [input]
|
||||
(js->clj (yaml/load input)
|
||||
:keywordize-keys true))
|
||||
|
|
11
src/main/resources/config.yaml
Executable file
11
src/main/resources/config.yaml
Executable file
|
@ -0,0 +1,11 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: mastodon-bot
|
||||
labels:
|
||||
app.kubernetes.io/name: k8s-mastodon-bot
|
||||
data:
|
||||
config.edn: |
|
||||
some-config-value
|
||||
credentials.edn: |
|
||||
some-credentials-value
|
|
@ -5,45 +5,28 @@ metadata:
|
|||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: k8s-mastodon-bot
|
||||
app.kubernetes.io/name: k8s-mastodon-bot
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: k8s-mastodon-bot
|
||||
app.kubernetes.io/name: k8s-mastodon-bot
|
||||
spec:
|
||||
containers:
|
||||
- image: postgres
|
||||
name: k8s-mastodon-bot
|
||||
- image: mastodon-bot
|
||||
name: mastodon-bot
|
||||
env:
|
||||
- name: POSTGRES_USER_FILE
|
||||
value: /var/run/secrets/postgres-secrets/postgres-user
|
||||
- name: POSTGRES_DB_FILE
|
||||
value: /var/run/secrets/postgres-secrets/postgres-db
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: /var/run/secrets/postgres-secrets/postgres-password
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
name: k8s-mastodon-bot
|
||||
- name: MASTODON_BOT_CREDENTIALS
|
||||
value: /app/credentials.edn
|
||||
cmd:
|
||||
volumeMounts:
|
||||
- name: k8s-mastodon-bot
|
||||
mountPath: /var/lib/k8s-mastodon-bot/data
|
||||
- name: postgres-secret-volume
|
||||
mountPath: /var/run/secrets/postgres-secrets
|
||||
- name: mastodon-bot
|
||||
mountPath: /app/config.edn
|
||||
subPath: config.conf
|
||||
readOnly: true
|
||||
- name: postgres-config-volume
|
||||
mountPath: /etc/k8s-mastodon-bot/k8s-mastodon-bot.conf
|
||||
subPath: k8s-mastodon-bot.conf
|
||||
- name: mastodon-bot
|
||||
mountPath: /app/credentials.edn
|
||||
subPath: credentials.conf
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: k8s-mastodon-bot
|
||||
persistentVolumeClaim:
|
||||
claimName: postgres-claim
|
||||
- name: postgres-secret-volume
|
||||
secret:
|
||||
secretName: postgres-secret
|
||||
- name: postgres-config-volume
|
||||
configMap:
|
||||
name: postgres-config
|
||||
|
||||
|
|
|
@ -11,3 +11,11 @@
|
|||
(is (= "hallo: welt
|
||||
"
|
||||
(cut/to-string {:hallo "welt"}))))
|
||||
|
||||
(deftest should-convert-config-yml-to-map
|
||||
(is (= {:apiVersion "v1", :kind "ConfigMap"
|
||||
:metadata {:name "mastodon-bot",
|
||||
:labels {:app.kubernetes.io/name "k8s-mastodon-bot"}},
|
||||
:data {:config.edn "some-config-value\n",
|
||||
:credentials.edn "some-credentials-value\n"}}
|
||||
(cut/from-string (cut/load-resource "config.yml")))))
|
||||
|
|
Loading…
Reference in a new issue