From 412230bd99b7e9dde630cd25ae45e3a0f014b057 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Fri, 1 Jul 2022 19:52:10 +0530 Subject: [PATCH] feat: create repo and add deploy key util --- integration/ci.sh | 7 ++++++- integration/lib.sh | 38 +++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/integration/ci.sh b/integration/ci.sh index 5d4b0f4..a25fa34 100755 --- a/integration/ci.sh +++ b/integration/ci.sh @@ -11,6 +11,7 @@ init() { else docker_compose_down || true docker_compose_up + sed -i /localhost.*/d ~/.ssh/known_hosts setup_env sleep 5 # wait_for_env @@ -29,4 +30,8 @@ teardown() { fi } -$1 +new_fleet_repo() { + new_fleet_repo_init $2 +} + +$1 $@ diff --git a/integration/lib.sh b/integration/lib.sh index e9d8048..079b9c2 100755 --- a/integration/lib.sh +++ b/integration/lib.sh @@ -120,31 +120,20 @@ support_repo_init() { $GITEA_HOSTEA_SUPPORT_REPO } -# register user "Hostea" on Gitea and create support repository -fleet_repo_init() { - python -m integration \ - gitea register \ - $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \ - $GITEA_HOSTEA_EMAIL \ - $GITEA_URL || true - python -m integration \ - gitea login \ - $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \ - $GITEA_HOSTEA_EMAIL \ - $GITEA_URL +new_fleet_repo_init() { python -m integration \ gitea create_repo \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \ $GITEA_HOSTEA_EMAIL \ $GITEA_URL \ - $GITEA_HOSTEA_FLEET_REPO + $1 python -m integration \ gitea add_deploy_key \ $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \ $GITEA_HOSTEA_EMAIL \ $GITEA_URL \ - $GITEA_HOSTEA_FLEET_REPO \ + $1 \ $GITEA_HOSTEA_FLEET_DEPLOY_KEY tmp_dir=$(mktemp -d) @@ -159,7 +148,8 @@ fleet_repo_init() { git init git add README git commit -m "init" - git remote add origin $GITEA_HOSTEA_FLEET_REPO_REMOTE + REMOTE="$GITEA_SSH_URL/$GITEA_HOSTEA_USERNAME/$1.git" + git remote add origin $REMOTE GIT_SSH_COMMAND="/usr/bin/ssh -oStrictHostKeyChecking=no -i $GITEA_HOSTEA_FLEET_DEPLOY_KEY_PRIVATE" \ git push --set-upstream origin master popd @@ -167,6 +157,24 @@ fleet_repo_init() { } + +# register user "Hostea" on Gitea and create support repository +fleet_repo_init() { + python -m integration \ + gitea register \ + $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \ + $GITEA_HOSTEA_EMAIL \ + $GITEA_URL || true + python -m integration \ + gitea login \ + $GITEA_HOSTEA_USERNAME $GITEA_HOSTEA_PASSWORD \ + $GITEA_HOSTEA_EMAIL \ + $GITEA_URL + + new_fleet_repo_init $GITEA_HOSTEA_FLEET_REPO + +} + # Create user on Hostea to simulate a Hostea customer hostea_customer_simulation() { python -m integration \