From dd594d5811c58864e96b72c862c39c7fb025fedc Mon Sep 17 00:00:00 2001 From: Ned McClain Date: Fri, 1 Jun 2018 08:08:22 -0600 Subject: [PATCH] Add Packet support (#89) --- README.md | 1 + parser_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ resource.go | 1 + 3 files changed, 47 insertions(+) diff --git a/README.md b/README.md index 44fddcf..691bbee 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The following providers are supported: * Exoscale * Google Compute Engine * OpenStack +* Packet * Scaleway * SoftLayer * VMware diff --git a/parser_test.go b/parser_test.go index 001eaeb..931baf2 100644 --- a/parser_test.go +++ b/parser_test.go @@ -292,6 +292,37 @@ const exampleStateFile = ` "default_ip_address": "10.20.30.50" } } + }, + "packet_device.thirteen": { + "type": "packet_device", + "depends_on": [], + "primary": { + "id": "e35816e2-b9b4-4ef3-9317-a32b98f6cb44", + "attributes": { + "billing_cycle": "hourly", + "created": "2018-04-02T14:52:34Z", + "facility": "ewr1", + "hostname": "sa-test-1", + "id": "e35816e2-b9b4-4ef3-9317-a32b98f6cb44", + "locked": "false", + "network.#": "3", + "network.0.address": "10.0.0.13", + "network.0.cidr": "31", + "network.0.family": "4", + "network.0.gateway": "10.0.0.254", + "network.0.public": "true", + "operating_system": "ubuntu_16_04", + "plan": "baremetal_0", + "project_id": "123456d5-087a-4976-877a-45b86584b786", + "state": "active", + "tags.#": "0", + "updated": "2018-04-02T14:57:13Z" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" } } } @@ -306,6 +337,7 @@ const expectedListOutput = ` "10.0.0.1", "10.0.0.10", "10.0.0.11", + "10.0.0.13", "10.0.0.7", "10.0.0.8", "10.0.0.9", @@ -337,6 +369,7 @@ const expectedListOutput = ` "ten": ["10.0.0.10"], "eleven": ["10.0.0.11"], "twelve": ["10.20.30.50"], + "thirteen": ["10.0.0.13"], "one.0": ["10.0.0.1"], "dup.0": ["10.0.0.1"], @@ -352,6 +385,7 @@ const expectedListOutput = ` "ten.0": ["10.0.0.10"], "eleven.0": ["10.0.0.11"], "twelve.0": ["10.20.30.50"], + "thirteen.0": ["10.0.0.13"], "type_aws_instance": ["10.0.0.1", "10.0.1.1", "50.0.0.1"], "type_digitalocean_droplet": ["192.168.0.3"], @@ -363,6 +397,7 @@ const expectedListOutput = ` "type_google_compute_instance": ["10.0.0.8"], "type_triton_machine": ["10.0.0.10"], "type_scaleway_server": ["10.0.0.11"], + "type_packet_device": ["10.0.0.13"], "role_rrrrrrrr": ["10.20.30.40"], "role_web": ["10.0.0.1"], @@ -379,6 +414,7 @@ const expectedInventoryOutput = `[all] 10.0.0.1 10.0.0.10 10.0.0.11 +10.0.0.13 10.0.0.7 10.0.0.8 10.0.0.9 @@ -481,6 +517,12 @@ olddatacenter="\u003c0.7_format" [ten.0] 10.0.0.10 +[thirteen] +10.0.0.13 + +[thirteen.0] +10.0.0.13 + [three] 192.168.0.3 @@ -519,6 +561,9 @@ olddatacenter="\u003c0.7_format" [type_openstack_compute_instance_v2] 10.120.0.226 +[type_packet_device] +10.0.0.13 + [type_scaleway_server] 10.0.0.11 diff --git a/resource.go b/resource.go index 9cadb51..b18d5f8 100644 --- a/resource.go +++ b/resource.go @@ -32,6 +32,7 @@ func init() { "ipv4_address_private", // SoftLayer "networks.0.ip4address", // Exoscale "primaryip", // Joyent Triton + "network.0.address", // Packet } // type.name.0