Skip to content

Commit 158b4a5

Browse files
Merge pull request #5837 from cloudflare/release-please--branches--main--changes--next
release: 5.8.2
2 parents 14d34c7 + 7e3f8c8 commit 158b4a5

17 files changed

+1066
-103
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "5.8.1"
2+
".": "5.8.2"
33
}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 5.8.2 (2025-08-01)
4+
5+
Full Changelog: [v5.8.1...v5.8.2](https://github.com/cloudflare/terraform-provider-cloudflare/compare/v5.8.1...v5.8.2)
6+
7+
### Features
8+
9+
* **api:** api update ([54b3c10](https://github.com/cloudflare/terraform-provider-cloudflare/commit/54b3c1027b30ae9ad6f388a64ea04941faea6774))
10+
* **api:** api update ([8666096](https://github.com/cloudflare/terraform-provider-cloudflare/commit/8666096e375e55731b286f30f3b722ad70761c1e))
11+
12+
13+
### Chores
14+
15+
* update model for zt gateway settings ([a084e1b](https://github.com/cloudflare/terraform-provider-cloudflare/commit/a084e1bfbf36e6fe1b3799d585d20542f792c0f0))
16+
317
## 5.8.1 (2025-08-01)
418

519
Full Changelog: [v5.8.0...v5.8.1](https://github.com/cloudflare/terraform-provider-cloudflare/compare/v5.8.0...v5.8.1)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020
required_providers {
2121
cloudflare = {
2222
source = "cloudflare/cloudflare"
23-
version = "~> 5.8.1"
23+
version = "~> 5.8.2"
2424
}
2525
}
2626
}

cmd/migrate/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
migrate

cmd/migrate/go.mod

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module github.com/cloudflare/terraform-provider-cloudflare/cmd/migrate
2+
3+
go 1.23.0
4+
5+
toolchain go1.23.11
6+
7+
require (
8+
github.com/hashicorp/hcl/v2 v2.24.0
9+
github.com/stretchr/testify v1.10.0
10+
github.com/zclconf/go-cty v1.16.3
11+
)
12+
13+
require (
14+
github.com/agext/levenshtein v1.2.2 // indirect
15+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
16+
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/google/go-cmp v0.7.0 // indirect
18+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
19+
github.com/pmezard/go-difflib v1.0.0 // indirect
20+
golang.org/x/mod v0.25.0 // indirect
21+
golang.org/x/sync v0.15.0 // indirect
22+
golang.org/x/text v0.25.0 // indirect
23+
golang.org/x/tools v0.34.0 // indirect
24+
gopkg.in/yaml.v3 v3.0.1 // indirect
25+
)

cmd/migrate/go.sum

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
2+
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
3+
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
4+
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
5+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7+
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
8+
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
9+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
10+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
11+
github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE=
12+
github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM=
13+
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
14+
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
15+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
16+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
17+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
18+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
19+
github.com/zclconf/go-cty v1.16.3 h1:osr++gw2T61A8KVYHoQiFbFd1Lh3JOCXc/jFLJXKTxk=
20+
github.com/zclconf/go-cty v1.16.3/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
21+
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo=
22+
github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM=
23+
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
24+
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
25+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
26+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
27+
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
28+
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
29+
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
30+
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
31+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
32+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
33+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
34+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

cmd/migrate/grit.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"os/exec"
7+
"strings"
8+
)
9+
10+
// checkGritInstalled checks if grit is installed and available
11+
func checkGritInstalled() error {
12+
cmd := exec.Command("grit", "--help")
13+
cmd.Stdout = nil // Suppress output during check
14+
cmd.Stderr = nil
15+
if err := cmd.Run(); err != nil {
16+
return fmt.Errorf("grit is not installed. Please install it with: npm install -g @getgrit/cli")
17+
}
18+
return nil
19+
}
20+
21+
// runGritMigrations runs the grit migrations for Cloudflare Terraform provider v5
22+
func runGritMigrations(configDir string, stateFile string, dryRun bool) error {
23+
// Define the grit patterns to apply
24+
patterns := []struct {
25+
pattern string
26+
target string
27+
}{
28+
{"github.com/cloudflare/terraform-provider-cloudflare#cloudflare_terraform_v5", "config"},
29+
{"github.com/cloudflare/terraform-provider-cloudflare#cloudflare_terraform_v5_attribute_renames_state", "state"},
30+
{"github.com/cloudflare/terraform-provider-cloudflare#cloudflare_terraform_v5_resource_renames_configuration", "config"},
31+
{"github.com/cloudflare/terraform-provider-cloudflare#cloudflare_terraform_v5_resource_renames_state", "state"},
32+
}
33+
34+
for _, p := range patterns {
35+
// Determine the target path based on pattern type
36+
targetPath := configDir
37+
if p.target == "state" && stateFile != "" {
38+
targetPath = stateFile
39+
}
40+
41+
// Skip config patterns if no config directory is specified
42+
if p.target == "config" && configDir == "" {
43+
fmt.Printf("Skipping %s (config transformations disabled)\n", p.pattern)
44+
continue
45+
}
46+
47+
// Skip state patterns if no state file is specified
48+
if p.target == "state" && stateFile == "" {
49+
fmt.Printf("Skipping %s (state transformations disabled)\n", p.pattern)
50+
continue
51+
}
52+
53+
args := []string{"apply"}
54+
if dryRun {
55+
args = append(args, "--dry-run")
56+
}
57+
args = append(args, "--verbose")
58+
args = append(args, p.pattern)
59+
args = append(args, targetPath)
60+
61+
fmt.Printf("grit %s\n", strings.Join(args, " "))
62+
cmd := exec.Command("grit", args...)
63+
cmd.Stdout = os.Stdout
64+
cmd.Stderr = os.Stderr
65+
66+
if err := cmd.Run(); err != nil {
67+
return fmt.Errorf("failed to run grit pattern %s: %w", p.pattern, err)
68+
}
69+
}
70+
71+
return nil
72+
}

cmd/migrate/helpers.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package main
2+
3+
import (
4+
"github.com/hashicorp/hcl/v2/hclsyntax"
5+
"github.com/hashicorp/hcl/v2/hclwrite"
6+
)
7+
8+
// AttributeInfo holds an attribute name and its corresponding Attribute object
9+
type AttributeInfo struct {
10+
Name string
11+
Attribute *hclwrite.Attribute
12+
}
13+
14+
// AttributesOrdered returns attributes from a body in their original order
15+
func AttributesOrdered(body *hclwrite.Body) []AttributeInfo {
16+
// Get all attributes as a map for lookup
17+
attrMap := body.Attributes()
18+
19+
// Get tokens to find the original order
20+
tokens := body.BuildTokens(nil)
21+
22+
var orderedAttrs []AttributeInfo
23+
seenAttrs := make(map[string]bool)
24+
25+
// Scan through tokens to find attribute names in order
26+
for i := 0; i < len(tokens); i++ {
27+
token := tokens[i]
28+
29+
// Look for identifier tokens that could be attribute names
30+
if token.Type == hclsyntax.TokenIdent && i+1 < len(tokens) {
31+
// Check if the next token is an equals sign
32+
nextToken := tokens[i+1]
33+
if nextToken.Type == hclsyntax.TokenEqual {
34+
attrName := string(token.Bytes)
35+
36+
// Check if this is actually an attribute and we haven't seen it yet
37+
if attr, exists := attrMap[attrName]; exists && !seenAttrs[attrName] {
38+
orderedAttrs = append(orderedAttrs, AttributeInfo{
39+
Name: attrName,
40+
Attribute: attr,
41+
})
42+
seenAttrs[attrName] = true
43+
}
44+
}
45+
}
46+
}
47+
48+
return orderedAttrs
49+
}
50+
51+
// buildTemplateStringTokens creates tokens for a template string like "${expr}/literal"
52+
func buildTemplateStringTokens(exprTokens hclwrite.Tokens, suffix string) hclwrite.Tokens {
53+
tokens := hclwrite.Tokens{
54+
{Type: hclsyntax.TokenOQuote, Bytes: []byte{'"'}},
55+
{Type: hclsyntax.TokenTemplateInterp, Bytes: []byte("${")},
56+
}
57+
58+
tokens = append(tokens, exprTokens...)
59+
tokens = append(tokens,
60+
&hclwrite.Token{Type: hclsyntax.TokenTemplateSeqEnd, Bytes: []byte{'}'}},
61+
)
62+
63+
if suffix != "" {
64+
tokens = append(tokens, &hclwrite.Token{Type: hclsyntax.TokenTemplateControl, Bytes: []byte(suffix)})
65+
}
66+
67+
tokens = append(tokens, &hclwrite.Token{Type: hclsyntax.TokenCQuote, Bytes: []byte{'"'}})
68+
69+
return tokens
70+
}
71+
72+
// buildResourceReference creates tokens for a resource reference like "type.name"
73+
func buildResourceReference(resourceType, resourceName string) hclwrite.Tokens {
74+
return hclwrite.Tokens{
75+
{Type: hclsyntax.TokenIdent, Bytes: []byte(resourceType)},
76+
{Type: hclsyntax.TokenDot, Bytes: []byte{'.'}},
77+
{Type: hclsyntax.TokenIdent, Bytes: []byte(resourceName)},
78+
}
79+
}

0 commit comments

Comments
 (0)