forked from toolshed/abra
refactor!: simplifying publish logic
This commit is contained in:
@ -306,7 +306,7 @@ var PatchFlag = &cli.BoolFlag{
|
||||
Name: "patch",
|
||||
Usage: "Increase the patch part of the version",
|
||||
Value: false,
|
||||
Aliases: []string{"p", "z"},
|
||||
Aliases: []string{"pa", "z"},
|
||||
Destination: &Patch,
|
||||
}
|
||||
|
||||
@ -319,38 +319,13 @@ var DryFlag = &cli.BoolFlag{
|
||||
Destination: &Dry,
|
||||
}
|
||||
|
||||
var Push bool
|
||||
var PushFlag = &cli.BoolFlag{
|
||||
Name: "push",
|
||||
Usage: "Git push changes",
|
||||
var Publish bool
|
||||
var PublishFlag = &cli.BoolFlag{
|
||||
Name: "publish",
|
||||
Usage: "Publish changes to git.coopcloud.tech",
|
||||
Value: false,
|
||||
Aliases: []string{"P"},
|
||||
Destination: &Push,
|
||||
}
|
||||
|
||||
var CommitMessage string
|
||||
var CommitMessageFlag = &cli.StringFlag{
|
||||
Name: "commit-message",
|
||||
Usage: "Commit message (implies --commit)",
|
||||
Aliases: []string{"cm"},
|
||||
Destination: &CommitMessage,
|
||||
}
|
||||
|
||||
var Commit bool
|
||||
var CommitFlag = &cli.BoolFlag{
|
||||
Name: "commit",
|
||||
Usage: "Commit new changes",
|
||||
Value: false,
|
||||
Aliases: []string{"c"},
|
||||
Destination: &Commit,
|
||||
}
|
||||
|
||||
var TagMessage string
|
||||
var TagMessageFlag = &cli.StringFlag{
|
||||
Name: "tag-comment",
|
||||
Usage: "Description for release tag",
|
||||
Aliases: []string{"t", "tm"},
|
||||
Destination: &TagMessage,
|
||||
Aliases: []string{"p"},
|
||||
Destination: &Publish,
|
||||
}
|
||||
|
||||
var Domain string
|
||||
@ -439,14 +414,14 @@ var SkipUpdatesFlag = &cli.BoolFlag{
|
||||
Name: "skip-updates",
|
||||
Aliases: []string{"s"},
|
||||
Value: false,
|
||||
Usage: "Skip updating git repositories",
|
||||
Usage: "Skip updating recipe repositories",
|
||||
Destination: &SkipUpdates,
|
||||
}
|
||||
|
||||
var RegistryUsername string
|
||||
var RegistryUsernameFlag = &cli.StringFlag{
|
||||
Name: "username",
|
||||
Aliases: []string{"u"},
|
||||
Aliases: []string{"user"},
|
||||
Value: "",
|
||||
Usage: "Registry username",
|
||||
EnvVars: []string{"REGISTRY_USERNAME"},
|
||||
@ -456,7 +431,7 @@ var RegistryUsernameFlag = &cli.StringFlag{
|
||||
var RegistryPassword string
|
||||
var RegistryPasswordFlag = &cli.StringFlag{
|
||||
Name: "password",
|
||||
Aliases: []string{"p"},
|
||||
Aliases: []string{"pass"},
|
||||
Value: "",
|
||||
Usage: "Registry password",
|
||||
EnvVars: []string{"REGISTRY_PASSWORD"},
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"coopcloud.tech/abra/pkg/recipe"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -64,20 +65,29 @@ func SetBumpType(bumpType string) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetMainApp retrieves the main 'app' image name
|
||||
func GetMainApp(recipe recipe.Recipe) string {
|
||||
var app string
|
||||
// GetMainAppImage retrieves the main 'app' image name
|
||||
func GetMainAppImage(recipe recipe.Recipe) (string, error) {
|
||||
var path string
|
||||
|
||||
for _, service := range recipe.Config.Services {
|
||||
name := service.Name
|
||||
if name == "app" {
|
||||
app = strings.Split(service.Image, ":")[0]
|
||||
if service.Name == "app" {
|
||||
img, err := reference.ParseNormalizedNamed(service.Image)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
path = reference.Path(img)
|
||||
if strings.Contains(path, "library") {
|
||||
path = strings.Split(path, "/")[1]
|
||||
}
|
||||
|
||||
return path, nil
|
||||
}
|
||||
}
|
||||
|
||||
if app == "" {
|
||||
logrus.Fatalf("%s has no main 'app' service?", recipe.Name)
|
||||
if path == "" {
|
||||
return path, fmt.Errorf("%s has no main 'app' service?", recipe.Name)
|
||||
}
|
||||
|
||||
return app
|
||||
return path, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user