From 1ed935d9f3400457cded4e8b6a1f0ea4a32eb274 Mon Sep 17 00:00:00 2001 From: jasminSPC Date: Wed, 18 Jul 2018 00:04:22 +0200 Subject: [PATCH 1/2] Packet documentation --- README.md | 4 ++++ provider/packet/packet_discover.go | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7743edcd..93695ad8 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ function. * SoftLayer [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/softlayer/softlayer_discover.go#L16-L25) * Triton [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/triton/triton_discover.go#L17-L27) * vSphere [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/vsphere/vsphere_discover.go#L148-L155) + * Packet [Config options](https://github.com/hashicorp/go-discover/blob/master/provider/packet/packet_discover.go#L25-L35) HashiCorp maintains acceptance tests that regularly allocate and run tests with real resources to verify the behavior of several of these providers. Those @@ -68,6 +69,9 @@ provider=triton account=testaccount url=https://us-sw-1.api.joyentcloud.com key_ # vSphere provider=vsphere category_name=consul-role tag_name=consul-server host=... user=... password=... insecure_ssl=[true|false] + +# Packet +provider=packet packet_auth_token=token packet_project=uuid packet_url=... address_type=... ``` ## Command Line Tool Usage diff --git a/provider/packet/packet_discover.go b/provider/packet/packet_discover.go index 510e977a..66bf9ffe 100644 --- a/provider/packet/packet_discover.go +++ b/provider/packet/packet_discover.go @@ -24,11 +24,16 @@ func (p *Provider) SetUserAgent(s string) { func (p *Provider) Help() string { return `Packet: provider: "packet" - packet_project: UUID of packet project - packet_url: Packet REST URL - packet_auth_token: Packet authentication token - address_type: "private_v4", "public_v4" or "public_v6". Defaults to "private_v4". - ` + packet_project: UUID of packet project. Required + packet_auth_token: Packet authentication token. Required + packet_url: Packet REST URL. Optional + address_type: "private_v4", "public_v4" or "public_v6". Defaults to "private_v4". Optional + + Variables can also be provided by environmental variables: + export PACKET_PROJECT for packet_project + export PACKET_URL for packet_url + export PACKET_AUTH_TOKEN for packet_auth_token +` } // Addrs function From f8ca019542121381cc673bddea2a68f25856184b Mon Sep 17 00:00:00 2001 From: jasminSPC Date: Wed, 18 Jul 2018 00:14:37 +0200 Subject: [PATCH 2/2] removed 'packet_' from required parameters --- README.md | 2 +- provider/packet/packet_discover.go | 24 ++++++++--------- provider/packet/packet_discover_test.go | 34 ++++++++++++------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 93695ad8..7e61ba97 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ provider=triton account=testaccount url=https://us-sw-1.api.joyentcloud.com key_ provider=vsphere category_name=consul-role tag_name=consul-server host=... user=... password=... insecure_ssl=[true|false] # Packet -provider=packet packet_auth_token=token packet_project=uuid packet_url=... address_type=... +provider=packet auth_token=token project=uuid url=... address_type=... ``` ## Command Line Tool Usage diff --git a/provider/packet/packet_discover.go b/provider/packet/packet_discover.go index 66bf9ffe..5ad1eead 100644 --- a/provider/packet/packet_discover.go +++ b/provider/packet/packet_discover.go @@ -23,24 +23,24 @@ func (p *Provider) SetUserAgent(s string) { // Help function func (p *Provider) Help() string { return `Packet: - provider: "packet" - packet_project: UUID of packet project. Required - packet_auth_token: Packet authentication token. Required - packet_url: Packet REST URL. Optional - address_type: "private_v4", "public_v4" or "public_v6". Defaults to "private_v4". Optional + provider: "packet" + project: UUID of packet project. Required + auth_token: Packet authentication token. Required + url: Packet REST URL. Optional + address_type: "private_v4", "public_v4" or "public_v6". Defaults to "private_v4". Optional Variables can also be provided by environmental variables: - export PACKET_PROJECT for packet_project - export PACKET_URL for packet_url - export PACKET_AUTH_TOKEN for packet_auth_token + export PACKET_PROJECT for project + export PACKET_URL for url + export PACKET_AUTH_TOKEN for auth_token ` } // Addrs function func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error) { - authToken := argsOrEnv(args, "packet_auth_token", "PACKET_AUTH_TOKEN") - projectID := argsOrEnv(args, "packet_project", "PACKET_PROJECT") - packetURL := argsOrEnv(args, "packet_url", "PACKET_URL") + authToken := argsOrEnv(args, "auth_token", "PACKET_AUTH_TOKEN") + projectID := argsOrEnv(args, "project", "PACKET_PROJECT") + packetURL := argsOrEnv(args, "url", "PACKET_URL") addressType := args["address_type"] if addressType != "private_v4" && addressType != "public_v4" && addressType != "public_v6" { @@ -56,7 +56,7 @@ func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error var devices []packngo.Device if projectID == "" { - return nil, fmt.Errorf("discover-packet: 'packet_project' parameter must be provider") + return nil, fmt.Errorf("discover-packet: 'project' parameter must be provider") } devices, _, err = c.Devices.List(projectID, nil) diff --git a/provider/packet/packet_discover_test.go b/provider/packet/packet_discover_test.go index f9dfc726..2c98bafa 100644 --- a/provider/packet/packet_discover_test.go +++ b/provider/packet/packet_discover_test.go @@ -14,16 +14,16 @@ var _ discover.ProviderWithUserAgent = (*packet.Provider)(nil) func TestAddrsDefault(t *testing.T) { args := discover.Config{ - "provider": "packet", - "packet_auth_token": os.Getenv("PACKET_TOKEN"), - "packet_project": os.Getenv("PACKET_PROJECT"), + "provider": "packet", + "auth_token": os.Getenv("PACKET_TOKEN"), + "project": os.Getenv("PACKET_PROJECT"), } - if args["packet_auth_token"] == "" { + if args["auth_token"] == "" { t.Skip("Packet credentials missing") } - if args["packet_project"] == "" { + if args["project"] == "" { t.Skip("Packet project UUID missing") } @@ -43,17 +43,17 @@ func TestAddrsDefault(t *testing.T) { func TestAddrsPublicV6(t *testing.T) { args := discover.Config{ - "provider": "packet", - "packet_auth_token": os.Getenv("PACKET_TOKEN"), - "packet_project": os.Getenv("PACKET_PROJECT"), - "address_type": "public_v6", + "provider": "packet", + "auth_token": os.Getenv("PACKET_TOKEN"), + "project": os.Getenv("PACKET_PROJECT"), + "address_type": "public_v6", } - if args["packet_auth_token"] == "" { + if args["auth_token"] == "" { t.Skip("Packet credentials missing") } - if args["packet_project"] == "" { + if args["project"] == "" { t.Skip("Packet project UUID missing") } @@ -73,17 +73,17 @@ func TestAddrsPublicV6(t *testing.T) { func TestAddrsPublicV4(t *testing.T) { args := discover.Config{ - "provider": "packet", - "packet_auth_token": os.Getenv("PACKET_TOKEN"), - "packet_project": os.Getenv("PACKET_PROJECT"), - "address_type": "public_v4", + "provider": "packet", + "auth_token": os.Getenv("PACKET_TOKEN"), + "project": os.Getenv("PACKET_PROJECT"), + "address_type": "public_v4", } - if args["packet_auth_token"] == "" { + if args["auth_token"] == "" { t.Skip("Packet credentials missing") } - if args["packet_project"] == "" { + if args["project"] == "" { t.Skip("Packet project UUID missing") }