Browse Source

refactoring

master
Sven Ullmann 2 years ago
parent
commit
53ea1c8ddf
  1. 9
      plugins/git/etc/config.json
  2. 24
      plugins/git/src/commands/clone
  3. 26
      plugins/git/src/commands/configure-ssh
  4. 26
      plugins/git/src/commands/configure-url
  5. 11
      plugins/ssh/src/includes/ssh

9
plugins/git/etc/config.json

@ -1,12 +1,5 @@
{
"git": {
"url": null,
"ssh": {
"user": null,
"domain": null,
"private_key": null,
"public_key": null,
"private_key_passphrase": null
}
"repositories": {}
}
}

24
plugins/git/src/commands/clone

@ -8,7 +8,7 @@ function usage {
echo
echoSubTitle "Usage:"
echo
echo "project-manager git:clone [project-shortname]"
echo "project-manager git:clone [shortname] [git-name]"
echo
echo "--help Prints this message"
echo
@ -16,12 +16,10 @@ function usage {
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)/includes/bash_header"
url="$(getConfig $shortname "git.url")"
sshUser="$(getConfig $shortname "git.ssh_user")"
sshDomain="$(getConfig $shortname "git.ssh_domain")"
sshPrivateKey="$(getConfig $shortname "git.ssh_private_key")"
sshPublicKey="$(getConfig $shortname "git.ssh_public_key")"
sshPrivateKeyPassphrase="$(getCryptedConfig $shortname "git.ssh_private_key_passphrase")"
gitName="$(getArgument "$2" "Git name required" true)"
escapedGitName=${gitName//./\\.}
url="$(getConfig "$shortname" "git.repositories.$escapedGitName.url")"
ssh="$(getConfig "$shortname" "git.repositories.$escapedGitName.ssh")"
workspaces_dir="$(getConfig false "project_manager.workspaces_dir")"
if [ "$url" == "" ]
@ -38,17 +36,8 @@ echoMainTitle "Cloning Repository"
echo
echoSubTitle "Please confirm following data"
echo
if [ "$ssh_private_key" != "" ]
then
echo "SSH Private Key File: $git_ssh_public_key"
fi
if [ "$ssh_public_key" != "" ]
then
echo "SSH Public Key File: $git_ssh_public_key"
fi
echo "GIT Url: $url"
echo "GIT User: $ssh_user"
echo "GIT Domain: $ssh_domain"
echo "Install Location: $workspaces_dir/$customer/$project"
echo
confirm
@ -58,4 +47,5 @@ then
mkdir -p "$workspaces_dir/$customer/$project"
fi
sshAdd "$shortname" "$ssh"
git clone "$url" "$workspaces_dir/$customer/$project"

26
plugins/git/src/commands/configure-ssh

@ -0,0 +1,26 @@
#!/bin/bash
### DO NOT EDIT THIS FILE
function usage {
echo
echoMainTitle "Configures Git Server Connection"
echo
echoSubTitle "Usage:"
echo
echo "project-manager git:configure-ssh [shortname] [git-name] [ssh-connection-name]"
echo
echo "--help Prints this message"
echo
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)/includes/bash_header"
gitName="$(getArgument "$2" "Git name required" true)"
sshConnectionName="$(getArgument "$3" "SSH connection name required" true)"
escapedGitName=${gitName//./\\.}
setConfig "$shortname" "git.repositories.$escapedGitName.ssh" "$sshConnectionName"
echo
echoSuccess "SSH Connection ($sshConnectionName) setted for Git: $gitName"
echo

26
plugins/git/src/commands/configure-url

@ -0,0 +1,26 @@
#!/bin/bash
### DO NOT EDIT THIS FILE
function usage {
echo
echoMainTitle "Configures Git Server Url"
echo
echoSubTitle "Usage:"
echo
echo "project-manager git:configure-url [shortname] [git-name] [url]"
echo
echo "--help Prints this message"
echo
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)/includes/bash_header"
gitName="$(getArgument "$2" "Git name required" true)"
url="$(getArgument "$3" "Url required" true)"
escapedGitName=${gitName//./\\.}
setConfig "$shortname" "git.repositories.$escapedGitName.url" "$url"
echo
echoSuccess "Git ($gitName) setted url: $url"
echo

11
plugins/ssh/src/includes/ssh

@ -84,4 +84,15 @@ then
ssh-copy-id -p "$port" -i "$sshDir/$name.pub" "$user@$host"
}
function sshAdd {
local shortname="$(getArgument "$1" "shortname required" true)"
local name="$(getArgument "$2" "name required" true)"
local escapedShortname=${shortname//./\\.}
local customer="$(getConfig false "project_manager.projects.$escapedShortname.customer")"
local project="$(getConfig false "project_manager.projects.$escapedShortname.project")"
local sshDir="$project_manager_dir/data/$customer/$project/.ssh"
if [ -f "$sshDir/$name" ]; then ssh-add "$sshDir/$name"; fi
}
fi
Loading…
Cancel
Save