Skip to content

Commit

Permalink
generate: don't output default ruleset ref values
Browse files Browse the repository at this point in the history
Updates the output generation to skip outputting the `ref` value in the case where it is the computed default (same as `id`).

This aligns the output with the expectation in the schema[1] where the `ref` maybe computed.

[1]: cloudflare/terraform-provider-cloudflare@5b01f8d

Signed-off-by: Jacob Bednarz <[email protected]>
  • Loading branch information
jacobbednarz committed Aug 11, 2023
1 parent 17e43c0 commit 5c894cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/app/cf-terraforming/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,14 @@ func generateResources() func(cmd *cobra.Command, args []string) {
rules := jsonStructData[i].(map[string]interface{})["rules"]
if rules != nil {
for ruleCounter := range rules.([]interface{}) {
// should the `ref` be the default `id`, don't output it
// as we don't need to track a computed default.
id := rules.([]interface{})[ruleCounter].(map[string]interface{})["id"]
ref := rules.([]interface{})[ruleCounter].(map[string]interface{})["ref"]
if id == ref {
rules.([]interface{})[ruleCounter].(map[string]interface{})["ref"] = nil
}

actionParams := rules.([]interface{})[ruleCounter].(map[string]interface{})["action_parameters"]
if actionParams != nil {
// check for log custom fields that need to be transformed
Expand Down

0 comments on commit 5c894cd

Please sign in to comment.