Merge branch 'main' of ssh://repo.prod.meissa.de:2222/meissa/c4k-forgejo

This commit is contained in:
Mirco 2023-12-21 22:26:45 +01:00
commit 8e261a7a7b
10 changed files with 96 additions and 82 deletions

View file

@ -6,7 +6,7 @@ from ddadevops import *
name = "c4k-forgejo" name = "c4k-forgejo"
MODULE = "backup" MODULE = "backup"
PROJECT_ROOT_PATH = "../.." PROJECT_ROOT_PATH = "../.."
version = "3.0.6-SNAPSHOT" version = "3.0.7-SNAPSHOT"
@init @init

View file

@ -12,13 +12,12 @@ function main() {
file_env POSTGRES_USER file_env POSTGRES_USER
# Restore latest snapshot into /var/backups/restore # Restore latest snapshot into /var/backups/restore
rm -rf /var/backups/restore
restore-directory '/var/backups/restore' restore-directory '/var/backups/restore'
rm -rf /var/backups/gitea/* rm -rf /var/backups/gitea/*
rm -rf /var/backups/git/repositories/* rm -rf /var/backups/git/repositories/*
cp -r /var/backups/restore/gitea /var/backups/ cp -r /var/backups/restore/gitea /var/backups/ #ToDo: mv instead of cp or rm -rf after
cp -r /var/backups/restore/git/repositories /var/backups/git/ cp -r /var/backups/restore/git/repositories /var/backups/git/ #ToDo: mv instead of cp or rm -rf after
# adjust file permissions for the git user # adjust file permissions for the git user
chown -R 1000:1000 /var/backups chown -R 1000:1000 /var/backups

View file

@ -6,7 +6,7 @@ from ddadevops import *
name = 'c4k-forgejo' name = 'c4k-forgejo'
MODULE = 'federated' MODULE = 'federated'
PROJECT_ROOT_PATH = '../..' PROJECT_ROOT_PATH = '../..'
version = "3.0.6-SNAPSHOT" version = "3.0.7-SNAPSHOT"
@init @init
def initialize(project): def initialize(project):

View file

@ -2,7 +2,7 @@
"name": "c4k-forgejo", "name": "c4k-forgejo",
"description": "Generate c4k yaml for a forgejo deployment.", "description": "Generate c4k yaml for a forgejo deployment.",
"author": "meissa GmbH", "author": "meissa GmbH",
"version": "3.0.6-SNAPSHOT", "version": "3.0.7-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-forgejo#readme", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-forgejo#readme",
"repository": "https://www.npmjs.com/package/c4k-forgejo", "repository": "https://www.npmjs.com/package/c4k-forgejo",
"license": "APACHE2", "license": "APACHE2",

View file

@ -1,4 +1,4 @@
(defproject org.domaindrivenarchitecture/c4k-forgejo "3.0.6-SNAPSHOT" (defproject org.domaindrivenarchitecture/c4k-forgejo "3.0.7-SNAPSHOT"
:description "forgejo c4k-installation package" :description "forgejo c4k-installation package"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"

View file

@ -4,7 +4,7 @@
"src/test/cljc" "src/test/cljc"
"src/test/cljs" "src/test/cljs"
"src/test/resources"] "src/test/resources"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.0.1"] :dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.1.0"]
[hickory "0.7.1"]] [hickory "0.7.1"]]
:builds {:frontend {:target :browser :builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-forgejo.browser/init}} :modules {:main {:init-fn dda.c4k-forgejo.browser/init}}

View file

@ -1,10 +1,10 @@
(ns dda.c4k-forgejo.backup (ns dda.c4k-forgejo.backup
(:require (:require
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
#?(:cljs [shadow.resource :as rc])
[dda.c4k-common.yaml :as yaml] [dda.c4k-common.yaml :as yaml]
[dda.c4k-common.base64 :as b64] [dda.c4k-common.base64 :as b64]
[dda.c4k-common.common :as cm])) [dda.c4k-common.common :as cm]
#?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]])))
(s/def ::aws-access-key-id cm/bash-env-string?) (s/def ::aws-access-key-id cm/bash-env-string?)
(s/def ::aws-secret-access-key cm/bash-env-string?) (s/def ::aws-secret-access-key cm/bash-env-string?)
@ -13,12 +13,7 @@
#?(:cljs #?(:cljs
(defmethod yaml/load-resource :backup [resource-name] (defmethod yaml/load-resource :backup [resource-name]
(case resource-name (get (inline-resources "backup") resource-name)))
"backup/config.yaml" (rc/inline "backup/config.yaml")
"backup/cron.yaml" (rc/inline "backup/cron.yaml")
"backup/secret.yaml" (rc/inline "backup/secret.yaml")
"backup/backup-restore-deployment.yaml" (rc/inline "backup/backup-restore-deployment.yaml")
(throw (js/Error. "Undefined Resource!")))))
(defn generate-config [my-conf] (defn generate-config [my-conf]
(let [{:keys [restic-repository]} my-conf] (let [{:keys [restic-repository]} my-conf]

View file

@ -2,17 +2,15 @@
(:require (:require
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[clojure.string :as st] [clojure.string :as st]
#?(:cljs [shadow.resource :as rc])
#?(:clj [orchestra.core :refer [defn-spec]] #?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]]) :cljs [orchestra.core :refer-macros [defn-spec]])
#?(:clj [clojure.edn :as edn]
:cljs [cljs.reader :as edn])
[dda.c4k-common.yaml :as yaml] [dda.c4k-common.yaml :as yaml]
[dda.c4k-common.common :as cm] [dda.c4k-common.common :as cm]
[dda.c4k-common.ingress :as ing] [dda.c4k-common.ingress :as ing]
[dda.c4k-common.base64 :as b64] [dda.c4k-common.base64 :as b64]
[dda.c4k-common.predicate :as pred] [dda.c4k-common.predicate :as pred]
[dda.c4k-common.postgres :as postgres])) [dda.c4k-common.postgres :as postgres]
#?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]])))
(defn domain-list? (defn domain-list?
[input] [input]
@ -68,14 +66,7 @@
#?(:cljs #?(:cljs
(defmethod yaml/load-resource :forgejo [resource-name] (defmethod yaml/load-resource :forgejo [resource-name]
(case resource-name (get (inline-resources "forgejo") resource-name)))
"forgejo/appini-env-configmap.yaml" (rc/inline "forgejo/appini-env-configmap.yaml")
"forgejo/deployment.yaml" (rc/inline "forgejo/deployment.yaml")
"forgejo/secrets.yaml" (rc/inline "forgejo/secrets.yaml")
"forgejo/service.yaml" (rc/inline "forgejo/service.yaml")
"forgejo/service-ssh.yaml" (rc/inline "forgejo/service-ssh.yaml")
"forgejo/datavolume.yaml" (rc/inline "forgejo/datavolume.yaml")
(throw (js/Error. "Undefined Resource!")))))
(defn generate-appini-env (defn generate-appini-env
[config] [config]

View file

@ -0,0 +1,30 @@
(ns dda.c4k-forgejo.backup-test
(:require
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
[clojure.spec.test.alpha :as st]
[dda.c4k-forgejo.backup :as cut]))
(st/instrument `cut/generate-config)
(deftest should-generate-backup-config
(testing "federated"
(is (= {:apiVersion "v1",
:kind "ConfigMap",
:metadata
{:name "backup-config",
:labels
#:app.kubernetes.io{:name "backup", :part-of "forgejo"}},
:data {:restic-repository "s3:s3.amazonaws.com/backup/federated-repo"}}
(cut/generate-config
{:restic-repository "s3:s3.amazonaws.com/backup/federated-repo"}))))
(testing "non-federated"
(is (= {:apiVersion "v1",
:kind "ConfigMap",
:metadata
{:name "backup-config",
:labels
#:app.kubernetes.io{:name "backup", :part-of "forgejo"}},
:data {:restic-repository "s3:s3.amazonaws.com/backup/repo"}}
(cut/generate-config
{:restic-repository "s3:s3.amazonaws.com/backup/repo"})))))

View file

@ -51,7 +51,8 @@
:service-domain-whitelist "test.com,test.net" :service-domain-whitelist "test.com,test.net"
:service-noreply-address "noreply@test.com"}))))) :service-noreply-address "noreply@test.com"})))))
(deftest should-generate-non-federated-deployment (deftest should-generate-deployment
(testing "non-federated"
(is (= {:apiVersion "apps/v1", (is (= {:apiVersion "apps/v1",
:kind "Deployment", :kind "Deployment",
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}}, :metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
@ -77,10 +78,8 @@
:mailer-host "m.t.de" :mailer-host "m.t.de"
:mailer-port "123" :mailer-port "123"
:service-domain-whitelist "adb.de" :service-domain-whitelist "adb.de"
:service-noreply-address ""} :service-noreply-address ""}))))
)))) (testing "federated-deployment"
(deftest should-generate-federated-deployment
(is (= {:apiVersion "apps/v1", (is (= {:apiVersion "apps/v1",
:kind "Deployment", :kind "Deployment",
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}}, :metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
@ -106,7 +105,7 @@
:mailer-host "m.t.de" :mailer-host "m.t.de"
:mailer-port "123" :mailer-port "123"
:service-domain-whitelist "adb.de" :service-domain-whitelist "adb.de"
:service-noreply-address ""})))) :service-noreply-address ""})))))
(deftest should-generate-secret (deftest should-generate-secret
(is (= {:FORGEJO__database__USER-c1 "", (is (= {:FORGEJO__database__USER-c1 "",