Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interface conversion: interface {} is float64, not string #248

Closed
2 tasks done
msankhala opened this issue Apr 21, 2021 · 3 comments · Fixed by #249
Closed
2 tasks done

interface conversion: interface {} is float64, not string #248

msankhala opened this issue Apr 21, 2021 · 3 comments · Fixed by #249

Comments

@msankhala
Copy link

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the library and it is still present.

cf-terraforming version

cf-terraforming v0.1.1

Expected outcome

The terraform resource definition for cloudflare_logpush_job.

Actual outcome

panic: interface conversion: interface {} is float64, not string

goroutine 1 [running]:
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.generateResources.func1(0x20b4ce0, 0xc000486
2a0, 0x0, 0x6)
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/generate.go:522 +0x8c2b
github.com/spf13/cobra.(*Command).execute(0x20b4ce0, 0xc000486240, 0x6, 0x6, 0x20b4ce0, 0xc000486240)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x20b51e0, 0xc0002dff78, 0x1006045, 0xc0000480b8)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.Execute()
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/root.go:30 +0x31
main.main()
        /home/runner/work/cf-terraforming/cf-terraforming/cmd/cf-terraforming/main.go:8 +0x25

Steps to reproduce

Run the command:

cf-terraforming generate --resource-type "cloudflare_logpush_job" --email=<your email> --key=<api-key> --account=<cf-account-id> --zone=<cf-zoneid> > logpush_job.tf

References

No response

jacobbednarz added a commit that referenced this issue Apr 22, 2021
Updates the name generation to handle scenarios where the ID is not a
string value. This is incredibly uncommon (logpush is the only service
exposing a non-string hash value) however this will fix the crash while
I chase up the internal team whether this is intentionally different.

Fixes #248
@jacobbednarz
Copy link
Member

looks like logpush is the only service that doesn't use hash based IDs. have updated the generate command to handle floats in #249.

@steadfasterX
Copy link

looks like logpush is the only service that doesn't use hash based IDs. have updated the generate command to handle floats in #249.

thx for the fix @jacobbednarz but I still get a weird resource name:

resource "cloudflare_logpush_job" "terraform_managed_resource_229327.000000" {
  dataset            = "firewall_events"
  destination_conf   = "https://13213213"
  enabled            = false
  frequency          = "high"
  max_upload_bytes   = 5000000
  max_upload_records = 1000
  name               = "http-elastic"
  zone_id            = "12312312"
}

this problem is discussed in #381

@Awea
Copy link

Awea commented Aug 31, 2023

Hey, using cf-terraforming v0.13.0 I get the same error for --resource-type "cloudflare_load_balancer":

panic: interface conversion: interface {} is float64, not string                                                                                                             

goroutine 1 [running]:                     
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc000473410, 0xc}, {0xa0afa0?, 0xc0009c6510?}, {0xc0004733e0?, 0x87332e?}, 0x7fae7767e
5c8?)
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/util.go:244 +0x1305                                                               
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.processBlocks(0xc00024f700, 0xc0009c64e0, 0xc000394168, {0xc0004733e0, 0xf})
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/util.go:213 +0x365                                                                
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.processBlocks(0xc00024f080, 0xc0009c6240, 0xc00034b500, {0x0, 0x0})
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/util.go:192 +0x771                                                                
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.generateResources.func1(0xf3e980?, {0xaa2cd2?, 0x5?, 0x5?})
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/generate.go:1199 +0x581b
github.com/spf13/cobra.(*Command).execute(0xf3e980, {0xc0001cecd0, 0x5, 0x5})                                                                                                
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847                                                                                          
github.com/spf13/cobra.(*Command).ExecuteC(0xf3e6a0)                                  
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd                                                                                         
github.com/spf13/cobra.(*Command).Execute(...)                                        
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992                                                                                                 
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.Execute()                                                                                             
        /home/runner/work/cf-terraforming/cf-terraforming/internal/app/cf-terraforming/cmd/root.go:30 +0x25                                                                  
main.main()                                
        /home/runner/work/cf-terraforming/cf-terraforming/cmd/cf-terraforming/main.go:8 +0x17 

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 a pull request may close this issue.

4 participants