diff --git a/gitea/README.org b/gitea/README.org new file mode 100644 index 0000000..c58ae99 --- /dev/null +++ b/gitea/README.org @@ -0,0 +1,28 @@ +# -*- ispell-local-dictionary: "english" -*- +#+SETUPFILE: ~/.emacs.d/etc/setup/default.setup +#+SETUPFILE: ~/.emacs.d/etc/setup/latex.setup +#+SETUPFILE: ~/.emacs.d/etc/setup/html-readtheorg-local.setup + +#+TITLE: Gitea + +* Usage + +#+begin_src yaml +gitea: + charm: gitea + options: + config: ## this entry is merged in app.ini + #app-name: "Gitea: Git with a cup of tea" + service: + #disable_registration: false + #require-signin-view: false + #register-email-confirm: false + #enable-notify-mail: false + #allow-only-external-registration: false + #enable-captcha: false + #default-keep-email-private: false + #default-allow-create-organization: true + #default-enable-timetracking: true + #no-reply-address: noreply.example.org +#+end_src + diff --git a/gitea/hooks/init b/gitea/hooks/init index a15b0f3..14da5d9 100755 --- a/gitea/hooks/init +++ b/gitea/hooks/init @@ -99,3 +99,7 @@ ENABLE_OPENID_SIGNIN = false ENABLE_OPENID_SIGNUP = false EOF +config=$(options-get config 2>/dev/null ) || true +ini=$(e "$config" | gitea:ini-make ) || exit 1 + +e "$ini" | ini merge || exit 1 diff --git a/gitea/lib/common b/gitea/lib/common index 3e05dbc..0116673 100644 --- a/gitea/lib/common +++ b/gitea/lib/common @@ -19,4 +19,42 @@ $MASTER_BASE_SERVICE_NAME: - compose.config_hash=$config_hash " -} \ No newline at end of file +} +join_by_dot() { + local IFS="." + echo "$*" +} + +gitea:ini-make() { + local key val type + local sep= + [ -n "$1" ] && printf "\n[%s]\n" "$(IFS="."; echo "$*")" + while read-0 key type val; do + case "${type##*\!}" in + map|seq) + e "$val" | gitea:ini-make "$@" "$key" || return 1 + continue + ;; + bool) + val="${val%$'\n'}" + case "${val,,}" in + true|ok|yes|y) + val=true + ;; + false|ko|nok|no|n) + val=false + ;; + *) + die "Invalid value for ${WHITE}$key$NORMAL, please use a boolean value." + ;; + esac + ;; + str|*) + val="${val%$'\n'}" + ;; + esac + key=${key//-/_} + key=${key^^} + printf "%s = %s\n" "$key" "$val" + done < <( yq -0 'to_entries | map([.key, .value | type, .value | to_yaml])[] | .[]' ) +} diff --git a/gitea/metadata.yml b/gitea/metadata.yml index fdd514f..33aaa1f 100644 --- a/gitea/metadata.yml +++ b/gitea/metadata.yml @@ -12,8 +12,21 @@ docker-compose: data-resources: - /data -# default-options: -# config: | +default-options: + config: + #app-name: "Gitea: Git with a cup of tea" + service: + #disable_registration: false + #require-signin-view: false + #register-email-confirm: false + #enable-notify-mail: false + #allow-only-external-registration: false + #enable-captcha: false + #default-keep-email-private: false + #default-allow-create-organization: true + #default-enable-timetracking: true + #no-reply-address: noreply.example.org + provides: vcs-manager: