forked from toolshed/abra
feat(deploy): Simplifies deploy overview (#508)
This simplifies the deploy overview, to only show 3 version fields: - CURRENT DEPLOYMENT - CURRENT ENV - NEW DEPLOYMENT It also fixes a few errors around version detection Reviewed-on: toolshed/abra#508 Co-authored-by: p4u1 <p4u1_f4u1@riseup.net> Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
@ -45,6 +46,9 @@ func (r Recipe) Ensure(ctx EnsureContext) error {
|
||||
|
||||
if r.EnvVersion != "" && !ctx.IgnoreEnvVersion {
|
||||
log.Debugf("ensuring env version %s", r.EnvVersion)
|
||||
if strings.Contains(r.EnvVersion, "+U") {
|
||||
log.Fatalf("can not redeploy chaos version (%s) without --chaos", r.EnvVersion)
|
||||
}
|
||||
|
||||
if _, err := r.EnsureVersion(r.EnvVersion); err != nil {
|
||||
return err
|
||||
@ -274,19 +278,14 @@ func (r Recipe) EnsureUpToDate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsDirty checks whether a recipe is dirty or not. N.B., if you call IsDirty
|
||||
// from another Recipe method, you should propagate the pointer reference (*).
|
||||
func (r *Recipe) IsDirty() error {
|
||||
// IsDirty checks whether a recipe is dirty or not.
|
||||
func (r *Recipe) IsDirty() (bool, error) {
|
||||
isClean, err := gitPkg.IsClean(r.Dir)
|
||||
if err != nil {
|
||||
return err
|
||||
return false, err
|
||||
}
|
||||
|
||||
if !isClean {
|
||||
r.Dirty = true
|
||||
}
|
||||
|
||||
return nil
|
||||
return !isClean, nil
|
||||
}
|
||||
|
||||
// ChaosVersion constructs a chaos mode recipe version.
|
||||
@ -300,8 +299,12 @@ func (r *Recipe) ChaosVersion() (string, error) {
|
||||
|
||||
version = formatter.SmallSHA(head.String())
|
||||
|
||||
if err := r.IsDirty(); err != nil {
|
||||
return version, err
|
||||
dirty, err := r.IsDirty()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if dirty {
|
||||
return fmt.Sprintf("%s%s", version, config.DIRTY_DEFAULT), nil
|
||||
}
|
||||
|
||||
return version, nil
|
||||
|
Reference in New Issue
Block a user