@ -8,6 +8,7 @@ import (
|
||||
"coopcloud.tech/abra/pkg/client/stack"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
apiclient "github.com/docker/docker/client"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Get retrieves an app
|
||||
@ -22,6 +23,8 @@ func Get(appName string) (config.App, error) {
|
||||
return config.App{}, err
|
||||
}
|
||||
|
||||
logrus.Debugf("retrieved '%s' for '%s'", app, appName)
|
||||
|
||||
return app, nil
|
||||
}
|
||||
|
||||
@ -51,6 +54,14 @@ func DeployedVersions(ctx context.Context, cl *apiclient.Client, app config.App)
|
||||
}
|
||||
}
|
||||
|
||||
deployed := len(services) > 0
|
||||
|
||||
if deployed {
|
||||
logrus.Debugf("detected '%s' as deployed versions of '%s'", appSpec, app.Name)
|
||||
} else {
|
||||
logrus.Debugf("detected '%s' as not deployed", app.Name)
|
||||
}
|
||||
|
||||
return appSpec, len(services) > 0, nil
|
||||
}
|
||||
|
||||
@ -58,11 +69,17 @@ func DeployedVersions(ctx context.Context, cl *apiclient.Client, app config.App)
|
||||
func ParseVersionLabel(label string) (string, string) {
|
||||
// versions may look like v4.2-abcd or v4.2-alpine-abcd
|
||||
idx := strings.LastIndex(label, "-")
|
||||
return label[:idx], label[idx+1:]
|
||||
version := label[:idx]
|
||||
digest := label[idx+1:]
|
||||
logrus.Debugf("parsed '%s' as version from '%s'", version, label)
|
||||
logrus.Debugf("parsed '%s' as digest from '%s'", digest, label)
|
||||
return version, digest
|
||||
}
|
||||
|
||||
// ParseVersionName parses a $STACK_NAME_$SERVICE_NAME service label.
|
||||
func ParseServiceName(label string) string {
|
||||
idx := strings.LastIndex(label, "_")
|
||||
return label[idx+1:]
|
||||
serviceName := label[idx+1:]
|
||||
logrus.Debugf("parsed '%s' as service name from '%s'", serviceName, label)
|
||||
return serviceName
|
||||
}
|
||||
|
Reference in New Issue
Block a user