fix: auto-config ssh urls and push to them

This commit is contained in:
2021-12-27 18:06:56 +01:00
parent b98397144a
commit eb1b6be4c5
6 changed files with 85 additions and 19 deletions

View File

@ -14,6 +14,7 @@ import (
"coopcloud.tech/abra/pkg/limit"
"coopcloud.tech/abra/pkg/recipe"
"github.com/AlecAivazis/survey/v2"
"github.com/go-git/go-git/v5"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -154,6 +155,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
catl[recipeMeta.Name] = recipe.RecipeMeta{
Name: recipeMeta.Name,
Repository: recipeMeta.CloneURL,
SSHURL: recipeMeta.SSHURL,
Icon: recipeMeta.AvatarURL,
DefaultBranch: recipeMeta.DefaultBranch,
Description: recipeMeta.Description,
@ -212,7 +214,17 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
}
if internal.Push {
if err := gitPkg.Push(cataloguePath, false); err != nil {
repo, err := git.PlainOpen(cataloguePath)
if err != nil {
logrus.Fatal(err)
}
sshURL := fmt.Sprintf(config.SSH_URL_TEMPLATE, "recipes")
if err := gitPkg.CreateRemote(repo, "origin-ssh", sshURL, internal.Dry); err != nil {
logrus.Fatal(err)
}
if err := gitPkg.Push(cataloguePath, "origin-ssh", false, internal.Dry); err != nil {
logrus.Fatal(err)
}
}