diff --git a/plugins/git/etc/config.json b/plugins/git/etc/config.json index c2c97ed..6e6b892 100644 --- a/plugins/git/etc/config.json +++ b/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": {} } } \ No newline at end of file diff --git a/plugins/git/src/commands/clone b/plugins/git/src/commands/clone index 8778a13..e338308 100644 --- a/plugins/git/src/commands/clone +++ b/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" \ No newline at end of file diff --git a/plugins/git/src/commands/configure-ssh b/plugins/git/src/commands/configure-ssh new file mode 100644 index 0000000..213f5f3 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/plugins/git/src/commands/configure-url b/plugins/git/src/commands/configure-url new file mode 100644 index 0000000..19e834c --- /dev/null +++ b/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 \ No newline at end of file diff --git a/plugins/ssh/src/includes/ssh b/plugins/ssh/src/includes/ssh index 33793e0..0b9b304 100644 --- a/plugins/ssh/src/includes/ssh +++ b/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