Add: gitea and gh
This commit is contained in:
parent
0d0e0b9262
commit
b70bd9ad17
@ -519,6 +519,8 @@ idm_core_init ()
|
|||||||
idm_lib_order_set gpg 11 89 11
|
idm_lib_order_set gpg 11 89 11
|
||||||
#idm_lib_order_set git 50 50 50
|
#idm_lib_order_set git 50 50 50
|
||||||
#idm_lib_order_set tomb 50 50 50
|
#idm_lib_order_set tomb 50 50 50
|
||||||
|
idm_lib_order_set gh 50 50 50
|
||||||
|
idm_lib_order_set gitea 50 50 50
|
||||||
|
|
||||||
# Load external lib
|
# Load external lib
|
||||||
idm_lib_load lib
|
idm_lib_load lib
|
||||||
@ -618,6 +620,9 @@ idm_core_cli ()
|
|||||||
if [[ -f "$IDM_ID_ENV" ]]; then
|
if [[ -f "$IDM_ID_ENV" ]]; then
|
||||||
. "$IDM_ID_ENV"
|
. "$IDM_ID_ENV"
|
||||||
fi
|
fi
|
||||||
|
if [[ -f "$IDM_DIR_ID/$id.secrets" ]]; then
|
||||||
|
. "$IDM_DIR_ID/$id.secrets"
|
||||||
|
fi
|
||||||
|
|
||||||
# Dispatch
|
# Dispatch
|
||||||
#lib_log DEBUG "menu=$menu action=${action:-_} id=$id opt=$opt"
|
#lib_log DEBUG "menu=$menu action=${action:-_} id=$id opt=$opt"
|
||||||
|
|||||||
55
lib/idmgr_mod_gh.sh
Normal file
55
lib/idmgr_mod_gh.sh
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#IDM_MOD_PS1_DEPS="s4 id pass gpg ssh"
|
||||||
|
#IDM_DISABLE_AUTO+="gh__ls"
|
||||||
|
|
||||||
|
## Prompt functions
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
#SHELL_PS1="${SHELL_PS1:-${PS1}"
|
||||||
|
|
||||||
|
idm_gh ()
|
||||||
|
{
|
||||||
|
local action=${1-}
|
||||||
|
shift || true
|
||||||
|
|
||||||
|
idm_gh__ls
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gh__ls ()
|
||||||
|
{
|
||||||
|
local id=${1}
|
||||||
|
|
||||||
|
if [[ -n "${GH_TOKEN-}" ]] ; then
|
||||||
|
echo " enabled (repo: ${GH_REPO})"
|
||||||
|
else
|
||||||
|
echo " disabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gh__help ()
|
||||||
|
{
|
||||||
|
echo "Github CLI"
|
||||||
|
printf " %-20s: %s\n" "gh enable" "Enable gh token"
|
||||||
|
printf " %-20s: %s\n" "gh disable" "Disable gh token"
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gh__enable ()
|
||||||
|
{
|
||||||
|
|
||||||
|
if [[ -n "${gh_token-}" ]] ; then
|
||||||
|
echo "export GH_TOKEN=\"$gh_token\""
|
||||||
|
echo "export GH_REPO=\"$gh_repo\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
idm_gh__disable ()
|
||||||
|
{
|
||||||
|
echo "unset GH_TOKEN"
|
||||||
|
echo "unset GH_REPO"
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gh__kill () { idm_gh__disable ${@-}; }
|
||||||
78
lib/idmgr_mod_gitea.sh
Normal file
78
lib/idmgr_mod_gitea.sh
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#IDM_MOD_PS1_DEPS="s4 id pass gpg ssh"
|
||||||
|
#IDM_DISABLE_AUTO+="gitea__ls"
|
||||||
|
|
||||||
|
## Prompt functions
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
#SHELL_PS1="${SHELL_PS1:-${PS1}"
|
||||||
|
|
||||||
|
idm_gitea ()
|
||||||
|
{
|
||||||
|
local action=${1-}
|
||||||
|
shift || true
|
||||||
|
|
||||||
|
idm_gitea__ls
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gitea__ls ()
|
||||||
|
{
|
||||||
|
local id=${1}
|
||||||
|
|
||||||
|
if [[ -n "${GITEA_LOGIN-}" ]] ; then
|
||||||
|
echo " enabled (repo: ${GITEA_LOGIN} ${GITEA_URL})"
|
||||||
|
else
|
||||||
|
echo " disabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gitea__help ()
|
||||||
|
{
|
||||||
|
echo "Github CLI"
|
||||||
|
printf " %-20s: %s\n" "gitea enable" "Enable gitea token"
|
||||||
|
printf " %-20s: %s\n" "gitea disable" "Disable gitea token"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
idm_gitea__register ()
|
||||||
|
{
|
||||||
|
local gitea_url=$1
|
||||||
|
local gitea_login=$2
|
||||||
|
local gitea_token=$3
|
||||||
|
|
||||||
|
if tea login list -o simple | grep -q "^$gitea_login"; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
tea login add \
|
||||||
|
--url "$gitea_url" \
|
||||||
|
--name "$gitea_login" \
|
||||||
|
--token "$gitea_token" > /dev/null
|
||||||
|
>&2 echo "Tea login installed: $gitea_login ($gitea_url)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gitea__enable ()
|
||||||
|
{
|
||||||
|
|
||||||
|
[[ -n "${gitea_url-}" ]] || return 0
|
||||||
|
[[ -n "${gitea_login-}" ]] || return 0
|
||||||
|
[[ -n "${gitea_token-}" ]] || return 0
|
||||||
|
|
||||||
|
idm_gitea__register $gitea_url $gitea_login $gitea_token
|
||||||
|
|
||||||
|
echo "export GITEA_SERVER_URL=\"$gitea_token\""
|
||||||
|
echo "export GITEA_LOGIN=\"$gitea_login\""
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
idm_gitea__disable ()
|
||||||
|
{
|
||||||
|
echo "unset GITEA_SERVER_URL"
|
||||||
|
echo "unset GITEA_LOGIN"
|
||||||
|
}
|
||||||
|
|
||||||
|
idm_gitea__kill () { idm_gitea__disable ${@-}; }
|
||||||
Loading…
x
Reference in New Issue
Block a user