From 349695509586e2ff3b7859e78b76670f740d504e Mon Sep 17 00:00:00 2001 From: caes Date: Thu, 28 May 2020 03:29:12 -0400 Subject: [PATCH] Removed keys from broker code, retired keys in commit history, and moved key to secret file. --- .gitignore | 1 + broker.sh | 49 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 4c684fe..af2efba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ errors .eslintrc.json +gitlab_read.pat diff --git a/broker.sh b/broker.sh index b817188..47002c7 100755 --- a/broker.sh +++ b/broker.sh @@ -231,10 +231,12 @@ get_remote_ssh_port () { get_remote_user () { local user=$(get_data $* remote user) - if [[ -z $user ]]; then - user=$dealer + if [[ -z $user ]] || [[ $user == "null" ]]; then + echo $dealer + else + echo $user fi - echo $user + return } ###################################################################### @@ -556,17 +558,9 @@ cluster_info () { # new gitlab gitlab_http_port="45080" gitlab_ssh_port="45022" -gitlab_read_token="uYoP-1HRpvMx3MWoRDHF" - -# old gitlab (overwriting new) -gitlab_http_port="45000" -gitlab_ssh_port="45002" -gitlab_read_token="JF1ymVmbfe1cp4z8eKKb" -#master token overwrite -#gitlab_read_token="G3Z9G5HeiTp74zFfeUnN" -gitlab_token="$gitlab_read_token" gitlab_owner="$dealer" +gitlab_token=$(gitlab_get_token) gitlab_url="gitlab.adamo.network" gitlab_http_url="http://${gitlab_url}:${gitlab_http_port}" gitlab_ssh_url="ssh://git@${gitlab_url}:${gitlab_ssh_port}" @@ -591,6 +585,28 @@ git_update_self () { cd ${owd} } +git_pull_all () { + owd=`pwd` + for gitdir in `git_list_dirs_under $1`; do + local dir=$(dirname $gitdir) + if [[ $TESTING_MODE ]]; then + pr_vars dir owd + else + cd $dir + git pull + cd $owd + fi + done +} + +git_list_dirs_under () { + find $1 -type d -a -name '.git' +} + +gitlab_get_token () { + cat ${program_root}/gitlab_read.pat +} + # $1: directory # $2: gitlab namespace path (this better exist!) gitlab_create_project_from_repo () { @@ -609,14 +625,19 @@ gitlab_create_project_from_repo () { else local uri="${gitlab_ssh_url}" fi - echo git push --set-upstream ${uri}/${name}.git $branch + pr_vars uri name branch + if [[ $TESTING_MODE ]]; then + echo git push --set-upstream ${uri}.git $branch + else + git push --set-upstream ${uri}.git $branch + fi cd $owd return 0 } gitlab_create_projects_for_all_in_dir () { local root=$1 - for gitdir in `find $root -type d -a -name '.git'`; do + for gitdir in `git_list_dirs_under $root`; do local dir=$(dirname $gitdir) local path=$(echo $dir|sed "s|${root}/||") gitlab_create_project_from_repo $dir $path