forked from toolshed/abra
Compare commits
3 Commits
fix-integr
...
fix-deploy
Author | SHA1 | Date | |
---|---|---|---|
33d5885f6f | |||
8a01b8eb41 | |||
87663b95c2 |
@ -261,7 +261,7 @@ func init() {
|
||||
AppCmdCommand.Flags().BoolVarP(
|
||||
&requestTTY,
|
||||
"tty",
|
||||
"T",
|
||||
"t",
|
||||
false,
|
||||
"request remote TTY",
|
||||
)
|
||||
|
@ -303,8 +303,12 @@ func getDeployVersion(cliArgs []string, deployMeta stack.DeployMeta, app app.App
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
log.Debugf("version: taking chaos version: %s", v)
|
||||
return v, v, nil
|
||||
cv, err := app.Recipe.GetVersionLabelLocal()
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
log.Debugf("version: taking chaos version: %s, %s", v, cv)
|
||||
return v, cv, nil
|
||||
}
|
||||
|
||||
// Check if the deploy version is set with a cli argument
|
||||
|
@ -81,8 +81,35 @@ var AppNewCommand = &cobra.Command{
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
recipeVersion = chaosVersion
|
||||
// NOTE(d1): rely on tags as there is no recipe.EnvVersion yet because
|
||||
// the app has not been fully created. we rely on the local git state of
|
||||
// the repository
|
||||
tags, err := recipe.Tags()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
internal.SortVersionsDesc(tags)
|
||||
|
||||
if len(tags) == 0 {
|
||||
// NOTE(d1): this is a new recipe with no released versions
|
||||
recipeVersion = config.UNKNOWN_DEFAULT
|
||||
} else {
|
||||
recipeVersion = tags[len(tags)-1]
|
||||
}
|
||||
|
||||
if err := recipe.IsDirty(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !internal.Offline && !recipe.Dirty {
|
||||
if err := recipe.EnsureUpToDate(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !internal.Chaos {
|
||||
if err := recipe.EnsureIsClean(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ var AppSecretGenerateCommand = &cobra.Command{
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if len(args) <= 2 && !generateAllSecrets {
|
||||
if len(args) == 1 && !generateAllSecrets {
|
||||
log.Fatal("missing arguments [secret]/[version] or '--all'")
|
||||
}
|
||||
|
||||
if len(args) > 2 && generateAllSecrets {
|
||||
if len(args) > 1 && generateAllSecrets {
|
||||
log.Fatal("cannot use '[secret] [version]' and '--all' together")
|
||||
}
|
||||
|
||||
|
@ -59,16 +59,16 @@ Passing "--prune/-p" does not remove those volumes.`,
|
||||
chaosVersion = deployMeta.ChaosVersion
|
||||
}
|
||||
|
||||
version := deployMeta.Version
|
||||
toWriteVersion := deployMeta.Version
|
||||
if deployMeta.IsChaos {
|
||||
version = chaosVersion
|
||||
toWriteVersion = chaosVersion
|
||||
}
|
||||
|
||||
if err := internal.UndeployOverview(
|
||||
app,
|
||||
deployMeta.Version,
|
||||
chaosVersion,
|
||||
version,
|
||||
toWriteVersion,
|
||||
); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -86,6 +86,10 @@ Passing "--prune/-p" does not remove those volumes.`,
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := app.WriteRecipeVersion(toWriteVersion, false); err != nil {
|
||||
log.Fatalf("writing recipe version failed: %s", err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func NewVersionOverview(
|
||||
releaseNotes string) error {
|
||||
deployConfig := "compose.yml"
|
||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
||||
deployConfig = formatComposeFiles(composeFiles)
|
||||
deployConfig = composeFiles
|
||||
}
|
||||
|
||||
server := app.Server
|
||||
@ -64,7 +64,10 @@ func NewVersionOverview(
|
||||
|
||||
upperKind := strings.ToUpper(kind)
|
||||
|
||||
envVersion := app.Recipe.EnvVersionRaw
|
||||
envVersion, err := recipe.GetEnvVersionRaw(app.Recipe.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if envVersion == "" {
|
||||
envVersion = config.NO_VERSION_DEFAULT
|
||||
@ -125,10 +128,6 @@ func NewVersionOverview(
|
||||
return nil
|
||||
}
|
||||
|
||||
func formatComposeFiles(composeFiles string) string {
|
||||
return strings.ReplaceAll(composeFiles, ":", "\n")
|
||||
}
|
||||
|
||||
// DeployOverview shows a deployment overview
|
||||
func DeployOverview(
|
||||
app appPkg.App,
|
||||
@ -141,7 +140,7 @@ func DeployOverview(
|
||||
) error {
|
||||
deployConfig := "compose.yml"
|
||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
||||
deployConfig = formatComposeFiles(composeFiles)
|
||||
deployConfig = composeFiles
|
||||
}
|
||||
|
||||
server := app.Server
|
||||
@ -226,7 +225,7 @@ func UndeployOverview(
|
||||
) error {
|
||||
deployConfig := "compose.yml"
|
||||
if composeFiles, ok := app.Env["COMPOSE_FILE"]; ok {
|
||||
deployConfig = formatComposeFiles(composeFiles)
|
||||
deployConfig = composeFiles
|
||||
}
|
||||
|
||||
server := app.Server
|
||||
|
@ -135,8 +135,6 @@ func GetEnvVersionRaw(name string) (string, error) {
|
||||
|
||||
func Get(name string) Recipe {
|
||||
version := ""
|
||||
versionRaw := ""
|
||||
dirty := false
|
||||
if strings.Contains(name, ":") {
|
||||
split := strings.Split(name, ":")
|
||||
if len(split) > 2 {
|
||||
@ -145,9 +143,7 @@ func Get(name string) Recipe {
|
||||
name = split[0]
|
||||
|
||||
version = split[1]
|
||||
versionRaw = version
|
||||
if strings.HasSuffix(version, config.DIRTY_DEFAULT) {
|
||||
dirty = true
|
||||
version = strings.Replace(split[1], config.DIRTY_DEFAULT, "", 1)
|
||||
log.Debugf("removed dirty suffix from .env version: %s -> %s", split[1], version)
|
||||
}
|
||||
@ -173,8 +169,6 @@ func Get(name string) Recipe {
|
||||
r := Recipe{
|
||||
Name: name,
|
||||
EnvVersion: version,
|
||||
EnvVersionRaw: versionRaw,
|
||||
Dirty: dirty,
|
||||
Dir: dir,
|
||||
GitURL: gitURL,
|
||||
SSHURL: sshURL,
|
||||
@ -194,9 +188,7 @@ func Get(name string) Recipe {
|
||||
|
||||
type Recipe struct {
|
||||
Name string
|
||||
// EnvVersion without +U
|
||||
EnvVersion string
|
||||
EnvVersionRaw string
|
||||
Dirty bool // NOTE(d1): git terminology for unstaged changes
|
||||
Dir string
|
||||
GitURL string
|
||||
|
@ -56,7 +56,7 @@ teardown(){
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "create new app with version commit" {
|
||||
@test "create new app with chaos commit" {
|
||||
tagHash=$(_get_tag_hash "0.3.0+1.21.0")
|
||||
|
||||
run $ABRA app new "$TEST_RECIPE" "$tagHash" \
|
||||
@ -129,10 +129,6 @@ teardown(){
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_equal "$(_git_status)" "?? foo"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_success
|
||||
assert_output --partial 'foo'
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
}
|
||||
@ -214,7 +210,7 @@ teardown(){
|
||||
--chaos
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_output --partial "version: ${currentHash:0:8}"
|
||||
assert_output --partial "version: $latestRelease"
|
||||
assert_output --partial "chaos: ${currentHash:0:8}"
|
||||
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
@ -242,7 +238,7 @@ teardown(){
|
||||
--chaos
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_output --partial "version: ${currentHash:0:8}"
|
||||
assert_output --partial "version: unknown"
|
||||
assert_output --partial "chaos: ${currentHash:0:8}"
|
||||
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
|
@ -165,13 +165,14 @@ teardown(){
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
|
||||
assert_success
|
||||
assert_output --partial "0.1.1+1.20.2"
|
||||
assert_output --partial "0.2.0+1.21.0"
|
||||
refute_output --partial "false"
|
||||
assert_output --partial "${tagHash:0:8}"
|
||||
|
||||
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
|
||||
assert_success
|
||||
assert_output --partial "0.1.1+1.20.2"
|
||||
assert_output --partial "0.1.0+1.20.0"
|
||||
|
||||
tagHash=$(_get_tag_hash "0.1.1+1.20.2")
|
||||
refute_output --partial "${tagHash:0:8}"
|
||||
assert_output --partial "false"
|
||||
}
|
||||
|
||||
|
@ -41,11 +41,6 @@ teardown(){
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" test_pass_one
|
||||
assert_failure
|
||||
assert_output --partial 'missing arguments'
|
||||
|
||||
run $ABRA app secret generate "$TEST_APP_DOMAIN" testSecret testVersion --all
|
||||
assert_failure
|
||||
|
@ -64,6 +64,10 @@ teardown(){
|
||||
# env version
|
||||
assert_output --regexp 'CURRENT VERSION.*' + "${latestRelease}"
|
||||
assert_output --regexp 'NEW VERSION.*' + "${headHash:0:8}"
|
||||
|
||||
run grep -q "TYPE=$TEST_RECIPE:${headHash:0:8}" \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "chaos deploy with unstaged commits and undeploy" {
|
||||
@ -89,6 +93,10 @@ teardown(){
|
||||
assert_output --regexp 'CURRENT VERSION.*' + "${latestRelease}"
|
||||
assert_output --regexp 'NEW VERSION.*' + "${headHash:0:8}+U"
|
||||
|
||||
run grep -q "TYPE=$TEST_RECIPE:${headHash:0:8}" \
|
||||
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
assert_success
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ teardown(){
|
||||
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
|
||||
assert_success
|
||||
assert_output --partial "0.1.1+1.20.2"
|
||||
assert_output --partial "0.1.0+1.20.0"
|
||||
assert_output --partial "${tagHash:0:8}"
|
||||
|
||||
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
|
||||
assert_success
|
||||
|
Reference in New Issue
Block a user