Skip to content

Commit e04727d

Browse files
Merge branch 'next' into yihuaf/mconn-1060/fix-mconn-resources
2 parents 9442983 + 033cf6d commit e04727d

File tree

879 files changed

+2867
-2228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

879 files changed

+2867
-2228
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1782
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6cea8c0c5482c999b7241fa9a19362dd8504dfee40bb5f704f88822a73abd134.yml
3-
openapi_spec_hash: e3cadc523ac8c8a891d9aa1104b1c357
4-
config_hash: eda5b3d9487ce675d1fadf88153b457d
1+
configured_endpoints: 1783
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e408a7cdec2dae3d1a18842dcc59280c56050fb042569139aec3fe0f12e0d461.yml
3+
openapi_spec_hash: 7e210c76f5dd4c79b3e67204ad279b81
4+
config_hash: a433f3793b734bc6fcc9d9e0c27ff8c2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
data "cloudflare_queue_consumer" "example_queue_consumer" {
22
account_id = "023e105f4ecef8ad9ca31a8372d0c353"
33
queue_id = "023e105f4ecef8ad9ca31a8372d0c353"
4+
consumer_id = "023e105f4ecef8ad9ca31a8372d0c353"
45
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data "cloudflare_queue_consumers" "example_queue_consumers" {
2+
account_id = "023e105f4ecef8ad9ca31a8372d0c353"
3+
queue_id = "023e105f4ecef8ad9ca31a8372d0c353"
4+
}

examples/resources/cloudflare_regional_hostname/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ resource "cloudflare_regional_hostname" "example_regional_hostname" {
22
zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
33
hostname = "foo.example.com"
44
region_key = "ca"
5-
routing = "routing"
5+
routing = "dns"
66
}

examples/resources/cloudflare_snippet_rules/resource.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "cloudflare_snippet_rules" "example_snippet_rules" {
22
zone_id = "9f1839b6152d298aca64c4e906b6d074"
3-
body = [{
4-
expression = "ip.src ne 1.1.1.1"
3+
rules = [{
4+
expression = "ip.src eq 1.1.1.1"
55
snippet_name = "my_snippet"
66
description = "Execute my_snippet when IP address is 1.1.1.1."
77
enabled = true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/aws/aws-sdk-go-v2/credentials v1.17.34
1111
github.com/aws/aws-sdk-go-v2/service/s3 v1.63.0
1212
github.com/cloudflare/cloudflare-go v0.104.0
13-
github.com/cloudflare/cloudflare-go/v4 v4.6.0
13+
github.com/cloudflare/cloudflare-go/v5 v5.0.0
1414
github.com/davecgh/go-spew v1.1.1
1515
github.com/hashicorp/go-uuid v1.0.3
1616
github.com/hashicorp/terraform-plugin-docs v0.21.0

go.sum

Lines changed: 102 additions & 215 deletions
Large diffs are not rendered by default.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package customvalidator
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag"
7+
"github.com/hashicorp/terraform-plugin-framework/attr"
8+
"github.com/hashicorp/terraform-plugin-framework/diag"
9+
"github.com/hashicorp/terraform-plugin-framework/path"
10+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
11+
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
12+
"github.com/hashicorp/terraform-plugin-framework/types"
13+
"strings"
14+
)
15+
16+
func RequiresOtherStringAttributeToNotBeOneOf(pathExpr path.Expression, wantStrValues ...string) requiresOtherAttributeToNotBeOneOfValidator {
17+
var wantValues []attr.Value
18+
for _, v := range wantStrValues {
19+
wantValues = append(wantValues, types.StringValue(v))
20+
}
21+
return requiresOtherAttributeToNotBeOneOfValidator{
22+
pathExpr,
23+
wantValues,
24+
}
25+
}
26+
27+
type requiresOtherAttributeToNotBeOneOfValidator struct {
28+
pathExpr path.Expression
29+
wantValues []attr.Value
30+
}
31+
32+
func (i requiresOtherAttributeToNotBeOneOfValidator) Description(ctx context.Context) string {
33+
var wantValuesAsStrings []string
34+
for _, v := range i.wantValues {
35+
wantValuesAsStrings = append(wantValuesAsStrings, v.String())
36+
}
37+
return fmt.Sprintf("can not be set if %q is one of: %s", i.pathExpr, strings.Join(wantValuesAsStrings, ", "))
38+
}
39+
40+
func (i requiresOtherAttributeToNotBeOneOfValidator) MarkdownDescription(ctx context.Context) string {
41+
return i.Description(ctx)
42+
}
43+
44+
func (i requiresOtherAttributeToNotBeOneOfValidator) validateAny(ctx context.Context, cfg *tfsdk.Config, attrPathExpr path.Expression, attrPath path.Path, value attr.Value, resDiagnostics *diag.Diagnostics) {
45+
if value.IsNull() || value.IsUnknown() {
46+
return
47+
}
48+
49+
expression := attrPathExpr.Merge(i.pathExpr)
50+
matchedPaths, diags := cfg.PathMatches(ctx, expression)
51+
resDiagnostics.Append(diags...)
52+
53+
for _, mp := range matchedPaths {
54+
// If the user specifies the same attribute this validator is applied to,
55+
// also as part of the input, skip it
56+
if mp.Equal(attrPath) {
57+
continue
58+
}
59+
60+
var mpVal attr.Value
61+
resDiagnostics.Append(cfg.GetAttribute(ctx, mp, &mpVal)...)
62+
63+
// Collect all errors
64+
if diags.HasError() {
65+
continue
66+
}
67+
68+
// Delay validation until all involved attribute have a known value
69+
if mpVal.IsUnknown() {
70+
return
71+
}
72+
73+
foundMatch := false
74+
for _, wantValue := range i.wantValues {
75+
if mpVal.Equal(wantValue) {
76+
foundMatch = true
77+
break
78+
}
79+
}
80+
81+
if foundMatch {
82+
description := fmt.Sprintf("%q %s", attrPath, i.Description(ctx))
83+
resDiagnostics.Append(validatordiag.InvalidAttributeCombinationDiagnostic(
84+
attrPath,
85+
description,
86+
))
87+
}
88+
}
89+
}
90+
91+
func (i requiresOtherAttributeToNotBeOneOfValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, res *validator.BoolResponse) {
92+
i.validateAny(ctx, &req.Config, req.PathExpression, req.Path, req.ConfigValue, &res.Diagnostics)
93+
}
94+
95+
func (i requiresOtherAttributeToNotBeOneOfValidator) ValidateString(ctx context.Context, req validator.StringRequest, res *validator.StringResponse) {
96+
i.validateAny(ctx, &req.Config, req.PathExpression, req.Path, req.ConfigValue, &res.Diagnostics)
97+
}
98+
99+
func (i requiresOtherAttributeToNotBeOneOfValidator) ValidateObject(ctx context.Context, req validator.ObjectRequest, res *validator.ObjectResponse) {
100+
i.validateAny(ctx, &req.Config, req.PathExpression, req.Path, req.ConfigValue, &res.Diagnostics)
101+
}
102+
103+
func (i requiresOtherAttributeToNotBeOneOfValidator) ValidateList(ctx context.Context, req validator.ListRequest, res *validator.ListResponse) {
104+
i.validateAny(ctx, &req.Config, req.PathExpression, req.Path, req.ConfigValue, &res.Diagnostics)
105+
}

internal/logging/logging.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"slices"
1010
"strings"
1111

12-
"github.com/cloudflare/cloudflare-go/v4/option"
12+
"github.com/cloudflare/cloudflare-go/v5/option"
1313

1414
"github.com/hashicorp/terraform-plugin-log/tflog"
1515
)

internal/provider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import (
77
"fmt"
88
"os"
99
"regexp"
10-
11-
"github.com/cloudflare/cloudflare-go/v4"
12-
"github.com/cloudflare/cloudflare-go/v4/option"
1310
"github.com/cloudflare/terraform-provider-cloudflare/internal/consts"
11+
"github.com/cloudflare/cloudflare-go/v5"
12+
"github.com/cloudflare/cloudflare-go/v5/option"
1413
"github.com/cloudflare/terraform-provider-cloudflare/internal/services/access_rule"
1514
"github.com/cloudflare/terraform-provider-cloudflare/internal/services/account"
1615
"github.com/cloudflare/terraform-provider-cloudflare/internal/services/account_api_token_permission_groups"
@@ -708,6 +707,7 @@ func (p *CloudflareProvider) DataSources(ctx context.Context) []func() datasourc
708707
queue.NewQueueDataSource,
709708
queue.NewQueuesDataSource,
710709
queue_consumer.NewQueueConsumerDataSource,
710+
queue_consumer.NewQueueConsumersDataSource,
711711
api_shield.NewAPIShieldDataSource,
712712
api_shield_discovery_operation.NewAPIShieldDiscoveryOperationsDataSource,
713713
api_shield_operation.NewAPIShieldOperationDataSource,

0 commit comments

Comments
 (0)