wip
This commit is contained in:
parent
9fb9cb13f3
commit
c91af154ec
9 changed files with 56 additions and 37 deletions
|
@ -99,7 +99,6 @@ release:
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_TAG != null'
|
- if: '$CI_COMMIT_TAG != null'
|
||||||
variables:
|
variables:
|
||||||
CI_COMMIT_TAG: "0.1.1"
|
|
||||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
||||||
UBERJAR_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot-standalone/${$CI_COMMIT_TAG}/k8s-mastodon-bot-standalone.jar"
|
UBERJAR_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot-standalone/${$CI_COMMIT_TAG}/k8s-mastodon-bot-standalone.jar"
|
||||||
FRONTEND_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot/${$CI_COMMIT_TAG}/k8s-mastodon-bot.js"
|
FRONTEND_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot/${$CI_COMMIT_TAG}/k8s-mastodon-bot.js"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "k8s-mastodon-bot",
|
"name": "k8s-mastodon-bot",
|
||||||
"description": "Generate k8s yaml for a mastodon-bot deployment.",
|
"description": "Generate k8s yaml for a mastodon-bot deployment.",
|
||||||
"author": "meissa GmbH",
|
"author": "meissa GmbH",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3-SNAPSHOT",
|
||||||
"homepage": "https://gitlab.com/domaindrivenarchitecture/k8s-mastodon-bot#readme",
|
"homepage": "https://gitlab.com/domaindrivenarchitecture/k8s-mastodon-bot#readme",
|
||||||
"repository": "https://www.npmjs.com/package/k8s-mastodon-bot",
|
"repository": "https://www.npmjs.com/package/k8s-mastodon-bot",
|
||||||
"license": "APACHE2",
|
"license": "APACHE2",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject dda/k8s-mastodon-bot "0.1.2"
|
(defproject dda/k8s-mastodon-bot "0.1.3-SNAPSHOT"
|
||||||
:description "common utils for dda config"
|
:description "common utils for dda config"
|
||||||
:url "https://www.domaindrivenarchitecture.org"
|
:url "https://www.domaindrivenarchitecture.org"
|
||||||
:license {:name "Apache License, Version 2.0"
|
:license {:name "Apache License, Version 2.0"
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
:max-post-length 300
|
:max-post-length 300
|
||||||
;; optional signature for posts. Defaults to "not present".
|
;; optional signature for posts. Defaults to "not present".
|
||||||
:signature "#newsbot"}
|
:signature "#newsbot"}
|
||||||
}]}
|
}]
|
||||||
|
:auth {}}}
|
||||||
</textarea><br><br>
|
</textarea><br><br>
|
||||||
|
|
||||||
<label for="auth" class="form-label">Your auth.edn:</label>
|
<label for="auth" class="form-label">Your auth.edn:</label>
|
||||||
|
|
|
@ -3,12 +3,9 @@
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.string :as cs]
|
[clojure.string :as cs]
|
||||||
[expound.alpha :as expound]
|
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[dda.k8s-mastodon-bot.core :as core]))
|
[dda.k8s-mastodon-bot.core :as core]))
|
||||||
|
|
||||||
(alter-var-root #'s/*explain-out* (constantly expound/printer))
|
|
||||||
|
|
||||||
(def usage
|
(def usage
|
||||||
"usage:
|
"usage:
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
(ns dda.k8s-mastodon-bot.core
|
(ns dda.k8s-mastodon-bot.core
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as cs]
|
[clojure.string :as cs]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[clojure.spec.test.alpha :as st]
|
||||||
#?(: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]])
|
||||||
|
[expound.alpha :as expound]
|
||||||
[mastodon-bot.core-domain :as cd]
|
[mastodon-bot.core-domain :as cd]
|
||||||
[dda.k8s-mastodon-bot.yaml :as yaml]))
|
[dda.k8s-mastodon-bot.yaml :as yaml]))
|
||||||
|
|
||||||
|
#?(:clj (alter-var-root #'s/*explain-out* (constantly expound/printer))
|
||||||
|
:cljs (set! s/*explain-out* expound/printer))
|
||||||
|
|
||||||
|
(s/def ::config cd/config?)
|
||||||
|
|
||||||
(defn generate-config [my-config my-auth]
|
(defn generate-config [my-config my-auth]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "config.yaml"))
|
(yaml/from-string (yaml/load-resource "config.yaml"))
|
||||||
|
@ -18,11 +26,11 @@
|
||||||
(yaml/from-string (yaml/load-resource "deployment.yaml"))))
|
(yaml/from-string (yaml/load-resource "deployment.yaml"))))
|
||||||
|
|
||||||
(defn-spec generate any?
|
(defn-spec generate any?
|
||||||
[my-config cd/config?
|
[my-config ::config
|
||||||
my-auth cd/auth?]
|
my-auth cd/auth?]
|
||||||
(cs/join "\n"
|
(cs/join "\n"
|
||||||
[(yaml/to-string (generate-config my-config my-auth))
|
[(yaml/to-string (generate-config my-config my-auth))
|
||||||
"---"
|
"---"
|
||||||
(yaml/to-string (generate-deployment))]))
|
(yaml/to-string (generate-deployment))]))
|
||||||
|
|
||||||
|
(st/instrument 'dda.k8s-mastodon-bot.core)
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
(ns dda.k8s-mastodon-bot.browser
|
(ns dda.k8s-mastodon-bot.browser
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.spec.test.alpha :as st]
|
|
||||||
[expound.alpha :as expound]
|
|
||||||
[dda.k8s-mastodon-bot.core :as core]))
|
[dda.k8s-mastodon-bot.core :as core]))
|
||||||
|
|
||||||
(set! s/*explain-out* expound/printer)
|
|
||||||
|
|
||||||
(defn config-from-document []
|
(defn config-from-document []
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "config")
|
(.getElementById "config")
|
||||||
|
@ -17,7 +13,7 @@
|
||||||
(.getElementById "auth")
|
(.getElementById "auth")
|
||||||
(.-value)))
|
(.-value)))
|
||||||
|
|
||||||
(defn render-to-document
|
(defn render-output-to-document
|
||||||
[input]
|
[input]
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById "output")
|
(.getElementById "output")
|
||||||
|
@ -29,7 +25,11 @@
|
||||||
(.getElementById "generate-button")
|
(.getElementById "generate-button")
|
||||||
(.addEventListener "click"
|
(.addEventListener "click"
|
||||||
#(-> (core/generate (config-from-document) (auth-from-document))
|
#(-> (core/generate (config-from-document) (auth-from-document))
|
||||||
(render-to-document)))))
|
(render-output-to-document)
|
||||||
|
(print "1"))))
|
||||||
|
(-> js/document
|
||||||
(st/instrument 'dda.k8s-mastodon-bot.core)
|
(.getElementById "config")
|
||||||
|
(.addEventListener "blur"
|
||||||
|
#(-> (s/explain ::core/config (config-from-document))
|
||||||
|
(print))))
|
||||||
|
)
|
||||||
|
|
13
src/test/cljc/dda/k8s_mastodon_bot/core_test.cljc
Normal file
13
src/test/cljc/dda/k8s_mastodon_bot/core_test.cljc
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
(ns dda.k8s-mastodon-bot.core-test
|
||||||
|
(:require
|
||||||
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||||
|
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||||
|
[dda.k8s-mastodon-bot.core :as cut]))
|
||||||
|
|
||||||
|
(deftest should-generate-yaml
|
||||||
|
(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.yaml")))))
|
|
@ -1,6 +1,7 @@
|
||||||
(ns dda.k8s-mastodon-bot.yaml-test
|
(ns dda.k8s-mastodon-bot.yaml-test
|
||||||
(:require
|
(:require
|
||||||
[clojure.test :refer [deftest is testing are]]
|
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
|
||||||
|
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
|
||||||
[dda.k8s-mastodon-bot.yaml :as cut]))
|
[dda.k8s-mastodon-bot.yaml :as cut]))
|
||||||
|
|
||||||
(deftest should-parse-yaml-string
|
(deftest should-parse-yaml-string
|
||||||
|
|
Loading…
Reference in a new issue