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

Azure: Missing HCL tests #70

Open
xescugc opened this issue Nov 9, 2020 · 0 comments
Open

Azure: Missing HCL tests #70

xescugc opened this issue Nov 9, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@xescugc
Copy link
Member

xescugc commented Nov 9, 2020

For Azure the testdata/azure.tf was added but no test using it.

I tried to add the test but the current implementation does not work, some things I've found:

func getRsIDByName(cfgs map[string]map[string]interface{}, name interface{}) (string, bool) {
    sname := name.(string)
	for _, cfg := range cfgs {
		rsName := cfg["name"]
		if rsName == name {
			pvid, ok := cfg["id"].(string)
			return pvid, ok
		} else if can, ok = cfg[provider.HCLCanonicalKey]; ok && fmt.Sprintf("${%s.name}",can) == sname {
            return sname, true
        }
	}
	return "", false
}

And also the main issue is that on the HCL the graph build before doing any operation is:

strict digraph G {                                                                                                                                                                                                  
        "azurerm_virtual_network_peering.example-1"->"azurerm_virtual_network.myterraformnetwork";                                                                                                                  
        "azurerm_virtual_network_peering.example-1"->"azurerm_virtual_network.myterraformnetwork2";                                                                                                                 
        "azurerm_linux_virtual_machine.myterraformvm" [ shape=ellipse ];                                                                                                                                            
        "azurerm_linux_virtual_machine.myterraformvm2" [ shape=ellipse ];                                                                                                                                           
        "azurerm_virtual_network.myterraformnetwork" [ shape=ellipse ];                                                                                                                                             
        "azurerm_virtual_network.myterraformnetwork2" [ shape=ellipse ];                                                                                                                                            
        "azurerm_virtual_network_peering.example-1" [ shape=rectangle ];                                                                                                                                            
                                                                                                                                                                                                                    
}

Which means that the azurerm_linux_virtual_machine are not connected to anything and will be removed on the first operation. They are not connected to anything as the "only" allowed connection is azurerm_virtual_network_peering and they do not know it. They know of azurerm_resource_group and azurerm_network_interface and those are not valid Nodes/Edges so are discarted.

The solution should be to add those resources as edges and the attributes needed on the Provider and fix the ResourceInOutNodes to know how to read those Edges.

@xescugc xescugc added the bug Something isn't working label Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant