Skip to content

Commit c46f54b

Browse files
authored
Merge pull request #342 from diggerhq/fix-merge-conflict
merge develop into split-digger-config
2 parents ef9f312 + f3e32e2 commit c46f54b

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

pkg/core/execution/execution.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type DiggerExecutor struct {
3232
}
3333

3434
func (d DiggerExecutor) planFileName() string {
35-
return d.ProjectNamespace + "#" + d.ProjectName + ".tfplan"
35+
return strings.ReplaceAll(d.ProjectNamespace, "/", ":") + "#" + d.ProjectName + ".tfplan"
3636
}
3737

3838
func (d DiggerExecutor) localPlanFilePath() string {
@@ -257,6 +257,10 @@ func cleanupTerraformOutput(nonEmptyOutput bool, planError error, stdout string,
257257
}
258258
}
259259

260+
// This should not happen but in case we get here we avoid slice bounds out of range exception by resetting endPos
261+
if endPos <= startPos {
262+
endPos = len(stdout)
263+
}
260264
return stdout[startPos:endPos]
261265
}
262266

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package execution
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"strings"
6+
"testing"
7+
)
8+
9+
func TestCorrectCleanUpWithoutRegexDoesNotProduceException(t *testing.T) {
10+
stdout := `
11+
Note: Objects have changed outside of Terraform
12+
13+
Terraform detected the following changes made outside of Terraform since the
14+
last "terraform apply" which may have affected this plan:
15+
16+
# docker_image.xxxx has been deleted
17+
- resource "docker_image" "aaa" {
18+
19+
}
20+
21+
22+
Unless you have made equivalent changes to your configuration, or ignored the
23+
relevant attributes using ignore_changes, the following plan may include
24+
actions to undo or respond to these changes.
25+
26+
─────────────────────────────────────────────────────────────────────────────
27+
28+
Terraform used the selected providers to generate the following execution
29+
plan. Resource actions are indicated with the following symbols:
30+
+ create
31+
32+
Terraform will perform the following actions:
33+
34+
# docker_image.xxxx will be created
35+
+ resource "docker_image" "xxx" {
36+
+ id = (known after apply)
37+
+ image_id = (known after apply)
38+
+ name = "***.dkr.ecr.***.amazonaws.com/xxx-yyy:latest"
39+
+ repo_digest = (known after apply)
40+
+ triggers = {
41+
+ "dir_sha1" = "aaaa"
42+
}
43+
44+
+ build {
45+
+ cache_from = []
46+
+ context = "docker/"
47+
+ dockerfile = "Dockerfile"
48+
+ extra_hosts = []
49+
+ remove = true
50+
+ security_opt = []
51+
+ tag = [
52+
+ "xxx:latest",
53+
]
54+
}
55+
}
56+
57+
# docker_registry_image.xxx will be created
58+
+ resource "docker_registry_image" "xxx" {
59+
+ id = (known after apply)
60+
+ insecure_skip_verify = false
61+
+ keep_remotely = true
62+
+ name = "***.dkr.ecr.***.amazonaws.com/xxx-yyy:latest"
63+
+ sha256_digest = (known after apply)
64+
}
65+
66+
Plan: 2 to add, 0 to change, 0 to destroy.
67+
`
68+
res := cleanupTerraformPlan(true, nil, stdout, "")
69+
index := strings.Index(stdout, "Terraform will perform the following actions:")
70+
assert.Equal(t, stdout[index:], res)
71+
}

0 commit comments

Comments
 (0)