This commit is contained in:
jem 2021-03-17 19:31:12 +01:00
parent 9fb9cb13f3
commit c91af154ec
9 changed files with 56 additions and 37 deletions

View file

@ -99,7 +99,6 @@ release:
rules:
- if: '$CI_COMMIT_TAG != null'
variables:
CI_COMMIT_TAG: "0.1.1"
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"
FRONTEND_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot/${$CI_COMMIT_TAG}/k8s-mastodon-bot.js"

View file

@ -2,7 +2,7 @@
"name": "k8s-mastodon-bot",
"description": "Generate k8s yaml for a mastodon-bot deployment.",
"author": "meissa GmbH",
"version": "0.1.2",
"version": "0.1.3-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/k8s-mastodon-bot#readme",
"repository": "https://www.npmjs.com/package/k8s-mastodon-bot",
"license": "APACHE2",

View file

@ -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"
:url "https://www.domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0"

View file

@ -22,23 +22,24 @@
:nitter-urls? false
;; accounts you wish to mirror
:accounts ["arstechnica" "WIRED"]}
:target {:target-type :mastodon
;; optional flag specifying wether the name of the account
;; will be appended in the post, defaults to false
:append-screen-name? false
;; optional visibility flag: direct, private, unlisted, public
;; defaults to public
:visibility "unlisted"
;; optional boolean to mark content as sensitive. Defaults to true.
:sensitive? true
;; optional boolean defaults to false
;; only sources containing media will be posted when set to true
:media-only? true
;; optional limit for the post length. Defaults to 300.
:max-post-length 300
;; optional signature for posts. Defaults to "not present".
:signature "#newsbot"}
}]}
:target {:target-type :mastodon
;; optional flag specifying wether the name of the account
;; will be appended in the post, defaults to false
:append-screen-name? false
;; optional visibility flag: direct, private, unlisted, public
;; defaults to public
:visibility "unlisted"
;; optional boolean to mark content as sensitive. Defaults to true.
:sensitive? true
;; optional boolean defaults to false
;; only sources containing media will be posted when set to true
:media-only? true
;; optional limit for the post length. Defaults to 300.
:max-post-length 300
;; optional signature for posts. Defaults to "not present".
:signature "#newsbot"}
}]
:auth {}}}
</textarea><br><br>
<label for="auth" class="form-label">Your auth.edn:</label>

View file

@ -3,12 +3,9 @@
(:require
[clojure.spec.alpha :as s]
[clojure.string :as cs]
[expound.alpha :as expound]
[clojure.java.io :as io]
[dda.k8s-mastodon-bot.core :as core]))
(alter-var-root #'s/*explain-out* (constantly expound/printer))
(def usage
"usage:

View file

@ -1,10 +1,18 @@
(ns dda.k8s-mastodon-bot.core
(:require
[clojure.string :as cs]
[clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]
#?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]])
[mastodon-bot.core-domain :as cd]
[dda.k8s-mastodon-bot.yaml :as yaml]))
[expound.alpha :as expound]
[mastodon-bot.core-domain :as cd]
[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]
(->
@ -18,11 +26,11 @@
(yaml/from-string (yaml/load-resource "deployment.yaml"))))
(defn-spec generate any?
[my-config cd/config?
[my-config ::config
my-auth cd/auth?]
(cs/join "\n"
[(yaml/to-string (generate-config my-config my-auth))
"---"
(yaml/to-string (generate-deployment))]))
(st/instrument 'dda.k8s-mastodon-bot.core)

View file

@ -1,12 +1,8 @@
(ns dda.k8s-mastodon-bot.browser
(:require
[clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]
[expound.alpha :as expound]
[dda.k8s-mastodon-bot.core :as core]))
(set! s/*explain-out* expound/printer)
(defn config-from-document []
(-> js/document
(.getElementById "config")
@ -17,7 +13,7 @@
(.getElementById "auth")
(.-value)))
(defn render-to-document
(defn render-output-to-document
[input]
(-> js/document
(.getElementById "output")
@ -29,7 +25,11 @@
(.getElementById "generate-button")
(.addEventListener "click"
#(-> (core/generate (config-from-document) (auth-from-document))
(render-to-document)))))
(st/instrument 'dda.k8s-mastodon-bot.core)
(render-output-to-document)
(print "1"))))
(-> js/document
(.getElementById "config")
(.addEventListener "blur"
#(-> (s/explain ::core/config (config-from-document))
(print))))
)

View 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")))))

View file

@ -1,6 +1,7 @@
(ns dda.k8s-mastodon-bot.yaml-test
(: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]))
(deftest should-parse-yaml-string