From ecbe0feae45a5515a59ebb5ea338f2f49b649b19 Mon Sep 17 00:00:00 2001 From: patdyn Date: Tue, 9 Jul 2024 16:22:45 +0200 Subject: [PATCH 1/4] [Skip-CI] Add todos --- src/main/cljc/dda/c4k_forgejo/core.cljc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/cljc/dda/c4k_forgejo/core.cljc b/src/main/cljc/dda/c4k_forgejo/core.cljc index 7d42c62..0283c02 100644 --- a/src/main/cljc/dda/c4k_forgejo/core.cljc +++ b/src/main/cljc/dda/c4k_forgejo/core.cljc @@ -59,6 +59,8 @@ (forgejo/generate-data-volume resolved-config) (forgejo/generate-appini-env resolved-config) (forgejo/generate-secrets auth) + ; TODO: generate-rate-limit-middleware does not use c4k-common -> refactor this + ; TODO: generate-rate-limit-ingress-and-cert should probably use cm/generate-simple-ingress (forgejo/generate-rate-limit-middleware rate-limit-defaults)] ; this does not have a vector as output (forgejo/generate-rate-limit-ingress-and-cert resolved-config) ; this function has a vector as output (when (contains? resolved-config :restic-repository) From ba649f4c2809bc6790c7154f2241477e33bdc8c4 Mon Sep 17 00:00:00 2001 From: patdyn Date: Wed, 10 Jul 2024 09:51:32 +0200 Subject: [PATCH 2/4] Use ratelimit from common --- src/main/cljc/dda/c4k_forgejo/core.cljc | 7 +--- src/main/cljc/dda/c4k_forgejo/forgejo.cljc | 38 +++++-------------- .../forgejo/middleware-ratelimit.yaml | 9 ----- .../cljc/dda/c4k_forgejo/forgejo_test.cljc | 23 ----------- 4 files changed, 12 insertions(+), 65 deletions(-) delete mode 100644 src/main/resources/forgejo/middleware-ratelimit.yaml diff --git a/src/main/cljc/dda/c4k_forgejo/core.cljc b/src/main/cljc/dda/c4k_forgejo/core.cljc index 0283c02..9b39ce1 100644 --- a/src/main/cljc/dda/c4k_forgejo/core.cljc +++ b/src/main/cljc/dda/c4k_forgejo/core.cljc @@ -58,11 +58,8 @@ (forgejo/generate-service-ssh) (forgejo/generate-data-volume resolved-config) (forgejo/generate-appini-env resolved-config) - (forgejo/generate-secrets auth) - ; TODO: generate-rate-limit-middleware does not use c4k-common -> refactor this - ; TODO: generate-rate-limit-ingress-and-cert should probably use cm/generate-simple-ingress - (forgejo/generate-rate-limit-middleware rate-limit-defaults)] ; this does not have a vector as output - (forgejo/generate-rate-limit-ingress-and-cert resolved-config) ; this function has a vector as output + (forgejo/generate-secrets auth)] ; this does not have a vector as output + (forgejo/generate-ratelimit-ingress-and-cert resolved-config) ; this function has a vector as output (when (contains? resolved-config :restic-repository) [(backup/generate-config resolved-config) (backup/generate-secret auth) diff --git a/src/main/cljc/dda/c4k_forgejo/forgejo.cljc b/src/main/cljc/dda/c4k_forgejo/forgejo.cljc index 10f35f4..7d1c86a 100644 --- a/src/main/cljc/dda/c4k_forgejo/forgejo.cljc +++ b/src/main/cljc/dda/c4k_forgejo/forgejo.cljc @@ -126,35 +126,17 @@ (cm/replace-all-matching "MAILERUSER" (b64/encode mailer-user)) (cm/replace-all-matching "MAILERPW" (b64/encode mailer-pw))))) -(defn generate-ingress-and-cert - [config] - (let [{:keys [fqdn]} config] - (ing/generate-ingress-and-cert - (merge - {:service-name "forgejo-service" - :service-port 3000 - :fqdns [fqdn]} - config)))) - -(defn-spec generate-rate-limit-ingress-and-cert pred/map-or-seq? +(defn-spec generate-ratelimit-ingress-and-cert seq? [config config?] - (-> - (generate-ingress-and-cert config) ; returns a vector - (#(assoc-in % ; Attention: heavily relying on the output order of ing/generate-ingress-and-cert - [1 :metadata :annotations :traefik.ingress.kubernetes.io/router.middlewares] - (str - (-> (second %) :metadata :annotations :traefik.ingress.kubernetes.io/router.middlewares) - ", default-ratelimit@kubernetescrd"))))) - - -; using :average and :burst seems sensible, :period may be interesting for fine tuning later on -(defn-spec generate-rate-limit-middleware pred/map-or-seq? - [config rate-limit-config?] - (let [{:keys [max-rate max-concurrent-requests]} config] - (-> - (yaml/load-as-edn "forgejo/middleware-ratelimit.yaml") - (cm/replace-key-value :average max-rate) - (cm/replace-key-value :burst max-concurrent-requests)))) + (let [{:keys [fqdn max-rate max-concurrent-requests namespace]} config] + (ing/generate-simple-ingress (merge + {:service-name "forgejo-service" + :service-port 3000 + :fqdns [fqdn] + :average-rate max-rate + :burst-rate max-concurrent-requests + :namespace namespace} + config)))) (defn-spec generate-data-volume pred/map-or-seq? [config vol?] diff --git a/src/main/resources/forgejo/middleware-ratelimit.yaml b/src/main/resources/forgejo/middleware-ratelimit.yaml deleted file mode 100644 index 918dd95..0000000 --- a/src/main/resources/forgejo/middleware-ratelimit.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: traefik.containo.us/v1alpha1 -kind: Middleware -metadata: - name: ratelimit - namespace: forgejo -spec: - rateLimit: # Config options for rate limiting: https://doc.traefik.io/traefik/middlewares/http/ratelimit/ - average: AVG - burst: BRS \ No newline at end of file diff --git a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc index e8837bd..51f3021 100644 --- a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc +++ b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc @@ -163,26 +163,3 @@ :storage-c2 "15Gi"} (th/map-diff (cut/generate-data-volume {:volume-total-storage-size 1}) (cut/generate-data-volume {:volume-total-storage-size 15}))))) - -(deftest should-generate-middleware-ratelimit - (is (= {:apiVersion "traefik.containo.us/v1alpha1", - :kind "Middleware", - :metadata {:name "ratelimit", :namespace "forgejo"}, - :spec {:rateLimit {:average 10, :burst 5}}} - (cut/generate-rate-limit-middleware {:max-rate 10, :max-concurrent-requests 5})))) - -(deftest should-generate-middleware-ratelimit-ingress-and-cert - (is (= {:traefik.ingress.kubernetes.io/router.entrypoints "web, websecure", - :traefik.ingress.kubernetes.io/router.middlewares - "default-redirect-https@kubernetescrd, default-ratelimit@kubernetescrd", - :metallb.universe.tf/address-pool "public"} - (-> (second - (cut/generate-rate-limit-ingress-and-cert - {:fqdn "test.de" - :mailer-from "" - :mailer-host "m.t.de" - :mailer-port "123" - :service-noreply-address "" - :average 10 - :burst 5})) - :metadata :annotations)))) From 786c06cc0ad10a7dbc672492b0a53aa54059955c Mon Sep 17 00:00:00 2001 From: Clemens Date: Wed, 10 Jul 2024 10:02:16 +0200 Subject: [PATCH 3/4] release: 3.4.4 --- infrastructure/backup/build.py | 2 +- infrastructure/federated/build.py | 2 +- package.json | 2 +- project.clj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infrastructure/backup/build.py b/infrastructure/backup/build.py index 4503c5f..46e2429 100644 --- a/infrastructure/backup/build.py +++ b/infrastructure/backup/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "c4k-forgejo" MODULE = "backup" PROJECT_ROOT_PATH = "../.." -version = "3.4.4-dev" +version = "3.4.4" @init diff --git a/infrastructure/federated/build.py b/infrastructure/federated/build.py index 8001247..b0ca20d 100644 --- a/infrastructure/federated/build.py +++ b/infrastructure/federated/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = 'c4k-forgejo' MODULE = 'federated' PROJECT_ROOT_PATH = '../..' -version = "3.4.4-dev" +version = "3.4.4" @init def initialize(project): diff --git a/package.json b/package.json index 814ba93..91aeb98 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "c4k-forgejo", "description": "Generate c4k yaml for a forgejo deployment.", "author": "meissa GmbH", - "version": "3.4.4-SNAPSHOT", + "version": "3.4.4", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-forgejo#readme", "repository": "https://www.npmjs.com/package/c4k-forgejo", "license": "APACHE2", diff --git a/project.clj b/project.clj index a08839f..4de460c 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-forgejo "3.4.4-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-forgejo "3.4.4" :description "forgejo c4k-installation package" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" From 11123e253f420401152524982dfa7c07c2cf8b07 Mon Sep 17 00:00:00 2001 From: Clemens Date: Wed, 10 Jul 2024 10:02:16 +0200 Subject: [PATCH 4/4] bump version to: 3.4.5-SNAPSHOT --- infrastructure/backup/build.py | 2 +- infrastructure/federated/build.py | 2 +- package.json | 2 +- project.clj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infrastructure/backup/build.py b/infrastructure/backup/build.py index 46e2429..2a43c08 100644 --- a/infrastructure/backup/build.py +++ b/infrastructure/backup/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = "c4k-forgejo" MODULE = "backup" PROJECT_ROOT_PATH = "../.." -version = "3.4.4" +version = "3.4.5-dev" @init diff --git a/infrastructure/federated/build.py b/infrastructure/federated/build.py index b0ca20d..30cefe9 100644 --- a/infrastructure/federated/build.py +++ b/infrastructure/federated/build.py @@ -6,7 +6,7 @@ from ddadevops import * name = 'c4k-forgejo' MODULE = 'federated' PROJECT_ROOT_PATH = '../..' -version = "3.4.4" +version = "3.4.5-dev" @init def initialize(project): diff --git a/package.json b/package.json index 91aeb98..e4039aa 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "c4k-forgejo", "description": "Generate c4k yaml for a forgejo deployment.", "author": "meissa GmbH", - "version": "3.4.4", + "version": "3.4.5-SNAPSHOT", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-forgejo#readme", "repository": "https://www.npmjs.com/package/c4k-forgejo", "license": "APACHE2", diff --git a/project.clj b/project.clj index 4de460c..ed3592e 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-forgejo "3.4.4" +(defproject org.domaindrivenarchitecture/c4k-forgejo "3.4.5-SNAPSHOT" :description "forgejo c4k-installation package" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0"