Skip to content

Conversation

musa-cf
Copy link
Contributor

@musa-cf musa-cf commented Mar 26, 2025

This uses the old SDK to assemble the combined rulesets and rules.

Closes #801

@@ -480,6 +480,11 @@ func TestResourceGenerationV5(t *testing.T) {
Transport: r,
},
))
apiV0, _ = cfv0.New(viper.GetString("key"), viper.GetString("email"), cfv0.HTTPClient(
Copy link
Contributor

@jacobbednarz jacobbednarz Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like it assumes we're using API key + email for the old client. shouldn't it be initialising the same credentials we already have for the newer client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's just for the unit tests though, which in the V4 test, only uses the key/email auth scheme.

On this commit, there's a fix for API client initializations to be the same outside of test runs: f4c7fcc

// The ruleset API has many gotchas that are accounted for in how we build
// the 'response' object that feeds into the HCL generation, and it's difficult
// to ensure the same compatability using the generated SDK.
useOldSDK := resourceType == "cloudflare_ruleset"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better copy the remapping logic instead of forcing this to use the old conditions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a bit too much toiling, it appears so. Based on how we've built the V5 support in so far, I have to circumvent many assumptions we make about using the newer Go SDK. I thought this was the less bad option.

@jacobbednarz jacobbednarz merged commit 050e09a into cloudflare:master Apr 1, 2025
3 checks passed
@elliotdobson
Copy link

@musa-cf all the test.tf files for rulesets are blank. Looking at other test.tf files for other features it appears these should have valid Terraform config in them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CF-TERRAFORMING for CLOUPDFLARE_RULESET resource not terraforming the RULES within ruleset
3 participants