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

panic: interface conversion: interface {} is string, not []interface {} #153

Open
dvmorris opened this issue Jul 21, 2021 · 7 comments
Open
Assignees
Labels
bug Something isn't working Provider: Google
Projects

Comments

@dvmorris
Copy link

I'm trying to generate a graph from a GCP HCL configuration, and I'm receiving this error. I installed inframap on MacOS via homebrew today, inframap--0.6.7.big_sur.bottle.tar.gz

panic: interface conversion: interface {} is string, not []interface {}

goroutine 1 [running]:
github.com/cycloidio/inframap/provider/google.Provider.PreProcess(0xc00009a2a0, 0x0, 0x0, 0x38)
	github.com/cycloidio/inframap/provider/google/google.go:192 +0xaa5
github.com/cycloidio/inframap/generate.preprocess(0xc000c00180, 0xc00009a2a0, 0xc001010100, 0xe, 0x22acba0)
	github.com/cycloidio/inframap/generate/state.go:841 +0x1b4
github.com/cycloidio/inframap/generate.FromHCL(0x1d36420, 0xc000b46c90, 0x169bb64, 0x9, 0x1010100, 0x0, 0x0, 0x2f78)
	github.com/cycloidio/inframap/generate/hcl.go:156 +0x100f
github.com/cycloidio/inframap/cmd.glob..func1(0x21b6b40, 0xc000b91b70, 0x1, 0x1, 0x0, 0x0)
	github.com/cycloidio/inframap/cmd/generate.go:69 +0x2f0
github.com/spf13/cobra.(*Command).execute(0x21b6b40, 0xc000b91b50, 0x1, 0x1, 0x21b6b40, 0xc000b91b50)
	github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0x21b7040, 0x0, 0xffffffff, 0xc00007c058)
	github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.1.3/command.go:897
github.com/cycloidio/inframap/cmd.Execute(...)
	github.com/cycloidio/inframap/cmd/root.go:27
main.main()
	github.com/cycloidio/inframap/main.go:10 +0x2e
@xescugc
Copy link
Member

xescugc commented Jul 27, 2021

Ok I see the error, it has an easy fix but I would like to be sure.

For what I see you used an HCL an input, could you check that one of the tags attribute instead of being tags = ["tag1", "tag2"] is something like tags = "tag1" which should be invalid no?

I want to be sure because we are assuming tags is always a list of strings which from the documentation https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#tags it should be. So I'll just ignore the error as it's invalid configuration on this case.

@dvmorris
Copy link
Author

I do have this in my main.tf:

  tags = var.tags

And this in my .tfvars file:

tags = ["tag1", "tag2"]

@xescugc xescugc self-assigned this Jul 27, 2021
@xescugc xescugc added the bug Something isn't working label Jul 27, 2021
@xescugc xescugc added this to To do in InfraMap Jul 27, 2021
@xescugc xescugc moved this from To do to In progress in InfraMap Jul 27, 2021
@xescugc
Copy link
Member

xescugc commented Jul 27, 2021

Ok IDK why I thought that we where already interpolating the variables, we are not, so we are reading the tags as var.tags and not as ["tag1", "tag2"].

I'll take a look to check if there is an internal function to do this or if I have to manually do the interpolation.

I see that you are using the .tfvars file, I'll check if it's read by default by Terraform (for what I see https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files there are some that maybe) but I'll most likely also add a --var-file like Terraform to specify any custom var file.

I cannot tell you an estimation on when this will be solved but I'll work on it as it's a big missing feature to interpolate variables on HCL generation.

@dvmorris
Copy link
Author

Thanks, I'm looking forward to trying out the fix whenever it's available.

@kayahk
Copy link

kayahk commented Aug 16, 2022

@dvmorris any progress on this issue?

@dvmorris
Copy link
Author

I haven't tried this in a while, have any changes been made that might make it worth trying again?

@matheusraz
Copy link

Is there any fix for this? Im facing the same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Provider: Google
Projects
InfraMap
In progress
Development

No branches or pull requests

4 participants