Skip to content

Commit 5cae82e

Browse files
authored
Merge branch 'main' into feature/runtime-overrides
2 parents 66b4999 + 81a386b commit 5cae82e

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ resource "spacelift_drift_detection" "default" {
393393

394394
lifecycle {
395395
precondition {
396-
condition = alltrue([for schedule in try(local.stack_configs[each.key].drift_detection_schedule, var.drift_detection_schedule) : can(regex("^([0-9,\\-\\*]+\\s+){4}[0-9,\\-\\*]+$", schedule))])
396+
condition = alltrue([for schedule in try(local.stack_configs[each.key].drift_detection_schedule, var.drift_detection_schedule) : can(regex("^([0-9,\\-*/]+\\s+){4}[0-9,\\-*/]+$", schedule))])
397397
error_message = "Invalid cron schedule format for drift detection"
398398
}
399399
}

tests/main.tftest.hcl

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
variables {
2-
root_modules_path = "./tests/fixtures/multi-instance"
2+
root_modules_path = "./tests/fixtures/multi-instance"
33
common_config_file = "common.yaml"
44
github_enterprise = {
55
namespace = "masterpointio"
66
}
7-
repository = "terraform-spacelift-automation"
7+
repository = "terraform-spacelift-automation"
88
all_root_modules_enabled = true
9-
aws_integration_enabled = false
9+
aws_integration_enabled = false
1010
before_init = [
1111
"echo 'Hello'"
1212
]
@@ -461,7 +461,7 @@ run "test_labels_are_created_correctly" {
461461
command = plan
462462

463463
assert {
464-
condition = contains(local.labels["root-module-a-test"], "nobackend")
464+
condition = contains(local.labels["root-module-a-test"], "nobackend")
465465
error_message = "Global labels were not created correctly: ${jsonencode(local.labels)}"
466466
}
467467
}
@@ -471,7 +471,7 @@ run "test_root_module_fileset_collects_all_root_modules" {
471471
command = plan
472472

473473
assert {
474-
condition = contains(local._all_root_modules, "root-module-a")
474+
condition = contains(local._all_root_modules, "root-module-a")
475475
error_message = "Root module fileset was not created correctly: ${jsonencode(local._all_root_modules)}"
476476
}
477477
}
@@ -481,7 +481,7 @@ run "test_common_labels_are_appended_to_stack_labels" {
481481
command = plan
482482

483483
assert {
484-
condition = contains(local.configs["root-module-a-test"].stack_settings.labels, "common_label") && contains(local.configs["root-module-a-test"].stack_settings.labels, "test_label")
484+
condition = contains(local.configs["root-module-a-test"].stack_settings.labels, "common_label") && contains(local.configs["root-module-a-test"].stack_settings.labels, "test_label")
485485
error_message = "Common labels were not merged correctly: ${jsonencode(local.configs)}"
486486
}
487487
}
@@ -491,7 +491,7 @@ run "test_stacks_include_expected" {
491491
command = plan
492492

493493
assert {
494-
condition = contains(local.stacks, "root-module-a-test")
494+
condition = contains(local.stacks, "root-module-a-test")
495495
error_message = "Stack names were not created correctly: ${jsonencode(local.stacks)}"
496496
}
497497
}
@@ -511,7 +511,7 @@ run "test_folder_labels_are_correct_format" {
511511
command = plan
512512

513513
assert {
514-
condition = contains(local._folder_labels["root-module-a-test"], "folder:root-module-a/test")
514+
condition = contains(local._folder_labels["root-module-a-test"], "folder:root-module-a/test")
515515
error_message = "Folder label was not created correctly for root-module-a: ${jsonencode(local._folder_labels)}"
516516
}
517517
}
@@ -521,7 +521,7 @@ run "test_workspace_when_default_tf_workspace_enabled_is_false" {
521521
command = plan
522522

523523
assert {
524-
condition = local.configs["root-module-a-test"].terraform_workspace == "test"
524+
condition = local.configs["root-module-a-test"].terraform_workspace == "test"
525525
error_message = "Terraform workspace was not set correctly when default_tf_workspace_enabled is false: ${jsonencode(local.configs)}"
526526
}
527527
}
@@ -531,7 +531,7 @@ run "test_workspace_when_default_tf_workspace_enabled" {
531531
command = plan
532532

533533
assert {
534-
condition = local.configs["root-module-a-default-example"].terraform_workspace == "default"
534+
condition = local.configs["root-module-a-default-example"].terraform_workspace == "default"
535535
error_message = "Default Terraform workspace was not used correctly: ${jsonencode(local.configs)}"
536536
}
537537
}
@@ -541,7 +541,7 @@ run "test_administrative_label_is_added_to_stack" {
541541
command = plan
542542

543543
assert {
544-
condition = contains(local.labels["root-module-a-default-example"], "administrative")
544+
condition = contains(local.labels["root-module-a-default-example"], "administrative")
545545
error_message = "Administrative label was not added to the stack: ${jsonencode(local.labels)}"
546546
}
547547
}
@@ -551,7 +551,7 @@ run "test_administrative_label_is_not_added_to_stack_when_not_administrative" {
551551
command = plan
552552

553553
assert {
554-
condition = !contains(local.labels["root-module-a-test"], "administrative")
554+
condition = !contains(local.labels["root-module-a-test"], "administrative")
555555
error_message = "Administrative label was added to the stack when it should not have been: ${jsonencode(local.labels)}"
556556
}
557557
}
@@ -561,7 +561,7 @@ run "test_depends_on_label_is_added_to_stack" {
561561
command = plan
562562

563563
assert {
564-
condition = contains(local.labels["root-module-a-test"], "depends-on:spacelift-automation-default")
564+
condition = contains(local.labels["root-module-a-test"], "depends-on:spacelift-automation-default")
565565
error_message = "Depends-on label was not added to the stack: ${jsonencode(local.labels)}"
566566
}
567567
}
@@ -571,7 +571,7 @@ run "test_before_init_excludes_the_expected_tfvars_copy_command_when_tfvars_are_
571571
command = plan
572572

573573
assert {
574-
condition = !contains(local.before_init["root-module-a-default-example"], "cp tfvars/default-example.tfvars spacelift.auto.tfvars")
574+
condition = !contains(local.before_init["root-module-a-default-example"], "cp tfvars/default-example.tfvars spacelift.auto.tfvars")
575575
error_message = "Before_init was not created correctly: ${jsonencode(local.before_init)}"
576576
}
577577
}
@@ -581,7 +581,7 @@ run "test_before_init_includes_the_expected_tfvars_copy_command" {
581581
command = plan
582582

583583
assert {
584-
condition = contains(local.before_init["root-module-a-test"], "cp tfvars/test.tfvars spacelift.auto.tfvars")
584+
condition = contains(local.before_init["root-module-a-test"], "cp tfvars/test.tfvars spacelift.auto.tfvars")
585585
error_message = "Before_init was not created correctly: ${jsonencode(local.before_init)}"
586586
}
587587
}
@@ -591,7 +591,7 @@ run "test_before_init_includes_the_default_before_init_and_stack_before_init" {
591591
command = plan
592592

593593
assert {
594-
condition = contains(local.before_init["root-module-a-default-example"], "echo 'Hello'") && contains(local.before_init["root-module-a-default-example"], "echo 'before_init'")
594+
condition = contains(local.before_init["root-module-a-default-example"], "echo 'Hello'") && contains(local.before_init["root-module-a-default-example"], "echo 'before_init'")
595595
error_message = "Before_init was not created correctly: ${jsonencode(local.before_init)}"
596596
}
597597
}

tests/single-instance.tftest.hcl

+15-15
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ variables {
33
github_enterprise = {
44
namespace = "masterpointio"
55
}
6-
repository = "terraform-spacelift-automation"
6+
repository = "terraform-spacelift-automation"
77
all_root_modules_enabled = true
8-
aws_integration_enabled = false
8+
aws_integration_enabled = false
99
before_init = [
1010
"echo 'Hello'"
1111
]
@@ -18,7 +18,7 @@ run "test_single_instance_root_module_fileset_collects_all_root_modules" {
1818
command = plan
1919

2020
assert {
21-
condition = contains(local._all_root_modules, "root-module-a")
21+
condition = contains(local._all_root_modules, "root-module-a")
2222
error_message = "Root module fileset was not created correctly: ${jsonencode(local._all_root_modules)}"
2323
}
2424
}
@@ -28,7 +28,7 @@ run "test_single_instance_stacks_include_expected" {
2828
command = plan
2929

3030
assert {
31-
condition = contains(local.stacks, "root-module-a")
31+
condition = contains(local.stacks, "root-module-a")
3232
error_message = "Stack names were not created correctly: ${jsonencode(local.stacks)}"
3333
}
3434
}
@@ -37,7 +37,7 @@ run "test_single_instance_stacks_only_include_default_stack" {
3737
command = plan
3838

3939
assert {
40-
condition = length(local._root_module_yaml_decoded["root-module-a"]) == 1 && local._root_module_yaml_decoded["root-module-a"]["default"] != null
40+
condition = length(local._root_module_yaml_decoded["root-module-a"]) == 1 && local._root_module_yaml_decoded["root-module-a"]["default"] != null
4141
error_message = "_root_module_yaml_decoded is not a single instance: ${jsonencode(local._root_module_yaml_decoded)}"
4242
}
4343
}
@@ -46,7 +46,7 @@ run "test_single_instance_stack_configs_stack_name_is_correct" {
4646
command = plan
4747

4848
assert {
49-
condition = length(local._root_module_stack_configs) == 2 && local._root_module_stack_configs["root-module-a"] != null && local._root_module_stack_configs["root-module-b"] != null
49+
condition = length(local._root_module_stack_configs) == 2 && local._root_module_stack_configs["root-module-a"] != null && local._root_module_stack_configs["root-module-b"] != null
5050
error_message = "_root_module_stack_configs is not expected structure: ${jsonencode(local._root_module_stack_configs)}"
5151
}
5252
}
@@ -55,7 +55,7 @@ run "test_single_instance_stack_configs_use_default_tf_workspace" {
5555
command = plan
5656

5757
assert {
58-
condition = local._root_module_stack_configs["root-module-a"].terraform_workspace == "default"
58+
condition = local._root_module_stack_configs["root-module-a"].terraform_workspace == "default"
5959
error_message = "terraform_workspace is not set to default: ${jsonencode(local._root_module_stack_configs)}"
6060
}
6161
}
@@ -64,7 +64,7 @@ run "test_single_instance_stack_configs_project_root_is_correct" {
6464
command = plan
6565

6666
assert {
67-
condition = local._root_module_stack_configs["root-module-a"].project_root == "${var.root_modules_path}/root-module-a"
67+
condition = local._root_module_stack_configs["root-module-a"].project_root == "${var.root_modules_path}/root-module-a"
6868
error_message = "project_root is not correct for root-module-a: ${jsonencode(local._root_module_stack_configs)}"
6969
}
7070
}
@@ -74,7 +74,7 @@ run "test_single_instance_stack_configs_custom_project_root_is_used_when_specifi
7474

7575
assert {
7676
# `tests/fixtures/single-instance/root-module-b/stack.yaml` specifies `project_root` as "" to indicate root directory of project as source.
77-
condition = local._root_module_stack_configs["root-module-b"].project_root == ""
77+
condition = local._root_module_stack_configs["root-module-b"].project_root == ""
7878
error_message = "Custom project_root not used: ${jsonencode(local._root_module_stack_configs)}"
7979
}
8080
}
@@ -84,7 +84,7 @@ run "test_single_instance_administrative_label_is_not_added_to_stack_when_not_ad
8484
command = plan
8585

8686
assert {
87-
condition = !contains(local.labels["root-module-a"], "administrative")
87+
condition = !contains(local.labels["root-module-a"], "administrative")
8888
error_message = "Administrative label was added to the stack when it should not have been: ${jsonencode(local.labels)}"
8989
}
9090
}
@@ -94,7 +94,7 @@ run "test_single_instance_depends_on_label_is_added_to_stack" {
9494
command = plan
9595

9696
assert {
97-
condition = contains(local.labels["root-module-a"], "depends-on:spacelift-automation-default")
97+
condition = contains(local.labels["root-module-a"], "depends-on:spacelift-automation-default")
9898
error_message = "Depends-on label was not added to the stack: ${jsonencode(local.labels)}"
9999
}
100100
}
@@ -104,7 +104,7 @@ run "test_single_instance_folder_label_is_added_to_stack_and_doesnt_include_work
104104
command = plan
105105

106106
assert {
107-
condition = contains(local.labels["root-module-a"], "folder:root-module-a")
107+
condition = contains(local.labels["root-module-a"], "folder:root-module-a")
108108
error_message = "Folder label was not added to the stack: ${jsonencode(local.labels)}"
109109
}
110110
}
@@ -114,7 +114,7 @@ run "test_single_instance_stack_yaml_labels_are_included_in_stack_labels" {
114114
command = plan
115115

116116
assert {
117-
condition = contains(local.labels["root-module-a"], "stack_label")
117+
condition = contains(local.labels["root-module-a"], "stack_label")
118118
error_message = "Stack.yaml labels were not included in the stack labels: ${jsonencode(local.labels)}"
119119
}
120120
}
@@ -124,7 +124,7 @@ run "test_single_instance_before_init_steps_are_added_to_stack" {
124124
command = plan
125125

126126
assert {
127-
condition = contains(local.before_init["root-module-a"], "echo 'Hello'") && contains(local.before_init["root-module-a"], "echo 'World'")
127+
condition = contains(local.before_init["root-module-a"], "echo 'Hello'") && contains(local.before_init["root-module-a"], "echo 'World'")
128128
error_message = "Before_init steps were not added to the stack: ${jsonencode(local.before_init)}"
129129
}
130130
}
@@ -134,7 +134,7 @@ run "test_single_instance_before_init_tfvar_cp_command_is_not_added_to_stack" {
134134
command = plan
135135

136136
assert {
137-
condition = !contains(local.before_init["root-module-a"], "cp tfvars/")
137+
condition = !contains(local.before_init["root-module-a"], "cp tfvars/")
138138
error_message = "Before_init tfvar cp command was added to the stack: ${jsonencode(local.before_init)}"
139139
}
140140
}

0 commit comments

Comments
 (0)