forked from toolshed/abra
refactor!: simplifying publish logic
This commit is contained in:
@ -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