pg-format / pgraphs

Property Graph Exchange Format (PG) converter
MIT License
18 stars 2 forks source link

Unable to convert dot file generated by the "terraform graph" command #27

Open Jubblin opened 6 months ago

Jubblin commented 6 months ago

When executed agaiunst a terraform generated dot file nothing is output to stderr or stdout.

version:

docker run -it ghcr.io/jubblin/pgraphs:main -V
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
pgraph 0.6.6

command executed: <terraform.dot docker run -i ghcr.io/jubblin/pgraphs:main -f dot

have confirmed all ok using supplied example:

<example.dot docker run -i ghcr.io/jubblin/pgraphs:main -f dot
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
{"type":"node","id":101,"labels":[],"properties":{"country":["United States"],"name":["Carol"]}}
{"type":"node","id":102,"labels":[],"properties":{"country":["Japan"],"name":["Bob"]}}
{"type":"edge","from":101,"to":102,"labels":[],"properties":{"since":[2012]},"undirected":true}
{"type":"edge","from":101,"to":102,"labels":[],"properties":{"engaged":["false"],"since":[2015]},"undirected":true}

generated dot file:

digraph {
    compound = "true"
    newrank = "true"
    subgraph "root" {
        "[root] libvirt_cloudinit_disk.commoninit (expand)" [label = "libvirt_cloudinit_disk.commoninit", shape = "box"]
        "[root] libvirt_domain.virt-machine (expand)" [label = "libvirt_domain.virt-machine", shape = "box"]
        "[root] libvirt_volume.base-volume-qcow2 (expand)" [label = "libvirt_volume.base-volume-qcow2", shape = "box"]
        "[root] libvirt_volume.volume-qcow2 (expand)" [label = "libvirt_volume.volume-qcow2", shape = "box"]
        "[root] provider[\"registry.terraform.io/dmacvicar/libvirt\"]" [label = "provider[\"registry.terraform.io/dmacvicar/libvirt\"]", shape = "diamond"]
        "[root] var.additional_disk_ids" [label = "var.additional_disk_ids", shape = "note"]
        "[root] var.autostart" [label = "var.autostart", shape = "note"]
        "[root] var.base_pool_name" [label = "var.base_pool_name", shape = "note"]
        "[root] var.base_volume_name" [label = "var.base_volume_name", shape = "note"]
        "[root] var.bridge" [label = "var.bridge", shape = "note"]
        "[root] var.cpu_mode" [label = "var.cpu_mode", shape = "note"]
        "[root] var.dhcp" [label = "var.dhcp", shape = "note"]
        "[root] var.graphics" [label = "var.graphics", shape = "note"]
        "[root] var.index_start" [label = "var.index_start", shape = "note"]
        "[root] var.ip_address" [label = "var.ip_address", shape = "note"]
        "[root] var.ip_gateway" [label = "var.ip_gateway", shape = "note"]
        "[root] var.ip_nameserver" [label = "var.ip_nameserver", shape = "note"]
        "[root] var.local_admin" [label = "var.local_admin", shape = "note"]
        "[root] var.local_admin_passwd" [label = "var.local_admin_passwd", shape = "note"]
        "[root] var.memory" [label = "var.memory", shape = "note"]
        "[root] var.os_img_url" [label = "var.os_img_url", shape = "note"]
        "[root] var.pool" [label = "var.pool", shape = "note"]
        "[root] var.runcmd" [label = "var.runcmd", shape = "note"]
        "[root] var.share_filesystem" [label = "var.share_filesystem", shape = "note"]
        "[root] var.ssh_admin" [label = "var.ssh_admin", shape = "note"]
        "[root] var.ssh_keys" [label = "var.ssh_keys", shape = "note"]
        "[root] var.ssh_private_key" [label = "var.ssh_private_key", shape = "note"]
        "[root] var.system_volume" [label = "var.system_volume", shape = "note"]
        "[root] var.time_zone" [label = "var.time_zone", shape = "note"]
        "[root] var.vcpu" [label = "var.vcpu", shape = "note"]
        "[root] var.vm_count" [label = "var.vm_count", shape = "note"]
        "[root] var.vm_hostname_prefix" [label = "var.vm_hostname_prefix", shape = "note"]
        "[root] var.xml_override" [label = "var.xml_override", shape = "note"]
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] local.all_keys (expand)"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] local.runcmd (expand)"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] provider[\"registry.terraform.io/dmacvicar/libvirt\"]"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.dhcp"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.index_start"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.ip_address"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.ip_gateway"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.ip_nameserver"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.local_admin"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.local_admin_passwd"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.pool"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.share_filesystem"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.ssh_admin"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.time_zone"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.vm_count"
        "[root] libvirt_cloudinit_disk.commoninit (expand)" -> "[root] var.vm_hostname_prefix"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] libvirt_cloudinit_disk.commoninit (expand)"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] libvirt_volume.volume-qcow2 (expand)"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.additional_disk_ids"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.autostart"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.bridge"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.cpu_mode"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.graphics"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.memory"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.ssh_private_key"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.vcpu"
        "[root] libvirt_domain.virt-machine (expand)" -> "[root] var.xml_override"
        "[root] libvirt_volume.base-volume-qcow2 (expand)" -> "[root] provider[\"registry.terraform.io/dmacvicar/libvirt\"]"
        "[root] libvirt_volume.base-volume-qcow2 (expand)" -> "[root] var.base_volume_name"
        "[root] libvirt_volume.base-volume-qcow2 (expand)" -> "[root] var.os_img_url"
        "[root] libvirt_volume.base-volume-qcow2 (expand)" -> "[root] var.pool"
        "[root] libvirt_volume.base-volume-qcow2 (expand)" -> "[root] var.vm_hostname_prefix"
        "[root] libvirt_volume.volume-qcow2 (expand)" -> "[root] libvirt_volume.base-volume-qcow2 (expand)"
        "[root] libvirt_volume.volume-qcow2 (expand)" -> "[root] var.base_pool_name"
        "[root] libvirt_volume.volume-qcow2 (expand)" -> "[root] var.index_start"
        "[root] libvirt_volume.volume-qcow2 (expand)" -> "[root] var.system_volume"
        "[root] libvirt_volume.volume-qcow2 (expand)" -> "[root] var.vm_count"
        "[root] local.all_keys (expand)" -> "[root] var.ssh_keys"
        "[root] local.runcmd (expand)" -> "[root] var.runcmd"
        "[root] output.ip_address (expand)" -> "[root] libvirt_domain.virt-machine (expand)"
        "[root] output.name (expand)" -> "[root] libvirt_domain.virt-machine (expand)"
        "[root] provider[\"registry.terraform.io/dmacvicar/libvirt\"] (close)" -> "[root] libvirt_domain.virt-machine (expand)"
        "[root] root" -> "[root] output.ip_address (expand)"
        "[root] root" -> "[root] output.name (expand)"
        "[root] root" -> "[root] provider[\"registry.terraform.io/dmacvicar/libvirt\"] (close)"
    }
}
nichtich commented 6 months ago

Your .dot file contains a subgraph - this is not supported by pgraphs (by now). Removing the line subgraph "root" { and one ending } allows processing the graph, for instance to xml.

Next time please run docker pull ghcr.io/pg-format/pgraphs and execute via docker run -it --rm ghcr.io/pg-format/pgraphs to use the latest version.