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

Update Terraform to v0.12 #11

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: go
go:
- '1.12'
env:
- GO111MODULE=on GOPROXY=https://proxy.golang.org
deploy:
provider: releases
api_key:
secure: tRoe90iEct050/XQcQ1oS1Wm5Yl2V+t8K1I1Hy66aWHoGf6NRxk9VRlKyg/Fr21pcZ4vhKwtH6dvTUhKPM8TtaUf1oC1wlwZnsq2oIEAuxRMh3bCd7Psyycmd5Oo8bF3gQ0FXmpwXSDh8D8qXjx190GyP+4lV0mSehWxOv+hM4ob7v19iUmkqL3EbJonTu+weDweuAUpZsfuODUYp12vT6uRFeN85RlJccOWvTstj1W6uiycDfjDTU3N2/PmTkohQmG8JSrDZ03+89pzkTfNUGWT/y9mNsGrMlKtTIJ+tcKEuzY+pUEIooxuB9y/np3EJyfCLE/MPrMz1kxkWfn++4wkQ/C8u7KiaPC9XDF9CfOEAa7SStlx+WsezSeqCHkPYuOEFEIdXOCrlmUWwHnOjqIlYT76fOUl2mQ1MMGc/eXYS91GBu2GinRK9XrC4O3Y2+FDFhDRBoWZAXoPgjkIocae/CI2/nnD6uQ1YhJy77tbdDzrlLykXpqSeiHuzNfVTfPE+9YJfnAPq2aUjvYCHE7sKnyAIeEQJxDGGzO7erVO6UJJYRo+B2QKbgxzFSaZup+0qFMkZrrakdIS4iFyrzi0INcIKGDNyejgXAbuoYhRxYzKu3ywsM8HG+ykK3wC6dpIarwKywJhDYPsjYSnu3n060bqzo1nd+yuJaXg6+E=
file_glob: true
file: terraform-provider-phpipam_*
skip_cleanup: true
on:
repo: Ouest-France/terraform-provider-phpipam
branch: master
tags: true
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
build:
go build -o terraform-provider-phpipam_${TRAVIS_TAG}

test:
go test -v $(shell go list ./... | grep -v /vendor/)

testacc:
TF_ACC=1 go test -v ./plugin/providers/phpipam -run="TestAcc"

build: deps
gox -osarch="linux/amd64 windows/amd64 darwin/amd64" \
-output="pkg/{{.OS}}_{{.Arch}}/terraform-provider-phpipam" .

release: release_bump release_build

release_bump:
Expand All @@ -16,8 +15,5 @@ release_bump:
release_build:
scripts/release_build.sh

deps:
go get -u github.com/mitchellh/gox

clean:
rm -rf pkg/
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Terraform, allowing for the management and lookup of sections, VLANs, subnets,
and IP addresses, entirely within Terraform.

[3]: https://phpipam.net/api/api_documentation/
[4]: https://github.com/paybyphone/phpipam-sdk-go
[4]: https://github.com/Ouest-France/phpipam-sdk-go

## Installing

Expand All @@ -25,7 +25,7 @@ into your config. Check the [releases page][6] of this repo to get releases for
Linux, OS X, and Windows.

[5]: https://www.terraform.io/docs/plugins/basics.html
[6]: https://github.com/paybyphone/terraform-provider-phpipam/releases
[6]: https://github.com/Ouest-France/terraform-provider-phpipam/releases

## Usage

Expand Down Expand Up @@ -707,29 +707,16 @@ data "phpipam_subnet" "subnet" {
subnet_mask = 24
}

// Get the first available address
data "phpipam_first_free_address" "next_address" {
subnet_id = "${data.phpipam_subnet.subnet.subnet_id}"
}

// Reserve the address. Note that we use ignore_changes here to ensure that we
// don't end up re-allocating this address on future Terraform runs.
resource "phpipam_address" {
subnet_id = "${data.phpipam_subnet.subnet.subnet_id}"
ip_address = "${data.phpipam_first_free_address.next_address.ip_address}"
hostname = "tf-test-host.example.internal"
description = "Managed by Terraform"

custom_fields = {
CustomTestAddresses = "terraform-test"
}

lifecycle {
ignore_changes = [
"subnet_id",
"ip_address",
]
}
}
```

Expand All @@ -739,7 +726,7 @@ The resource takes the following parameters:

* `subnet_id` (Required) - The database ID of the subnet this IP address
belongs to.
* `ip_address` (Required) - The IP address to reserve.
* `ip_address` (Optional) - The IP address to reserve. If not defined, first free IP in subnet is used.
* `is_gateway` (Optional) - `true` if this IP address has been designated as a
gateway.
* `description` (Optional) - The description provided to this IP address.
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/Ouest-France/terraform-provider-phpipam

go 1.12

require (
github.com/Ouest-France/phpipam-sdk-go v0.0.0-20180829134422-31a77e0f2eda
github.com/hashicorp/terraform v0.12.0
github.com/imdario/mergo v0.3.7 // indirect
)
367 changes: 367 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/hashicorp/terraform/plugin"
"github.com/paybyphone/terraform-provider-phpipam/plugin/providers/phpipam"
"github.com/Ouest-France/terraform-provider-phpipam/plugin/providers/phpipam"
)

func main() {
Expand Down
10 changes: 7 additions & 3 deletions plugin/providers/phpipam/address_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/addresses"
"github.com/paybyphone/phpipam-sdk-go/phpipam"
"github.com/Ouest-France/phpipam-sdk-go/controllers/addresses"
"github.com/Ouest-France/phpipam-sdk-go/phpipam"
)

// resourceAddressOptionalFields represents all the fields that are optional in
Expand Down Expand Up @@ -101,7 +101,11 @@ func resourceAddressSchema() map[string]*schema.Schema {
for k, v := range s {
switch {
// IP Address and Subnet ID are ForceNew
case k == "subnet_id" || k == "ip_address":
case k == "ip_address":
v.ForceNew = true
v.Optional = true
v.Computed = true
case k == "subnet_id":
v.Required = true
v.ForceNew = true
case k == "custom_fields":
Expand Down
12 changes: 6 additions & 6 deletions plugin/providers/phpipam/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package phpipam
import (
"log"

"github.com/paybyphone/phpipam-sdk-go/controllers/addresses"
"github.com/paybyphone/phpipam-sdk-go/controllers/sections"
"github.com/paybyphone/phpipam-sdk-go/controllers/subnets"
"github.com/paybyphone/phpipam-sdk-go/controllers/vlans"
"github.com/paybyphone/phpipam-sdk-go/phpipam"
"github.com/paybyphone/phpipam-sdk-go/phpipam/session"
"github.com/Ouest-France/phpipam-sdk-go/controllers/addresses"
"github.com/Ouest-France/phpipam-sdk-go/controllers/sections"
"github.com/Ouest-France/phpipam-sdk-go/controllers/subnets"
"github.com/Ouest-France/phpipam-sdk-go/controllers/vlans"
"github.com/Ouest-France/phpipam-sdk-go/phpipam"
"github.com/Ouest-France/phpipam-sdk-go/phpipam/session"
)

// Config provides the configuration for the PHPIPAM provider.
Expand Down
6 changes: 3 additions & 3 deletions plugin/providers/phpipam/custom_field_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"regexp"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/addresses"
"github.com/paybyphone/phpipam-sdk-go/controllers/subnets"
"github.com/paybyphone/phpipam-sdk-go/controllers/vlans"
"github.com/Ouest-France/phpipam-sdk-go/controllers/addresses"
"github.com/Ouest-France/phpipam-sdk-go/controllers/subnets"
"github.com/Ouest-France/phpipam-sdk-go/controllers/vlans"
)

// customFieldFilterSchema returns a *schema.Schema for the custom_field_filter
Expand Down
2 changes: 1 addition & 1 deletion plugin/providers/phpipam/data_source_phpipam_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/addresses"
"github.com/Ouest-France/phpipam-sdk-go/controllers/addresses"
)

func dataSourcePHPIPAMAddress() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion plugin/providers/phpipam/data_source_phpipam_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/sections"
"github.com/Ouest-France/phpipam-sdk-go/controllers/sections"
)

func dataSourcePHPIPAMSection() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion plugin/providers/phpipam/data_source_phpipam_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/subnets"
"github.com/Ouest-France/phpipam-sdk-go/controllers/subnets"
)

func dataSourcePHPIPAMSubnet() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion plugin/providers/phpipam/data_source_phpipam_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/vlans"
"github.com/Ouest-France/phpipam-sdk-go/controllers/vlans"
)

func dataSourcePHPIPAMVLAN() *schema.Resource {
Expand Down
9 changes: 7 additions & 2 deletions plugin/providers/phpipam/resource_phpipam_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/phpipam"
"github.com/Ouest-France/phpipam-sdk-go/phpipam"
)

// resourcePHPIPAMAddress returns the resource structure for the phpipam_address
Expand All @@ -31,10 +31,15 @@ func resourcePHPIPAMAddressCreate(d *schema.ResourceData, meta interface{}) erro
// Assert the ID field here is empty. If this is not empty the request will fail.
in.ID = 0

if _, err := c.CreateAddress(in); err != nil {
ip, err := c.CreateAddress(in)
if err != nil {
return err
}

if in.IPAddress == "" {
d.Set("ip_address", ip)
}

// If we have custom fields, set them now. We need to get the IP address's ID
// beforehand.
if customFields, ok := d.GetOk("custom_fields"); ok {
Expand Down
4 changes: 2 additions & 2 deletions plugin/providers/phpipam/section_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/sections"
"github.com/paybyphone/phpipam-sdk-go/phpipam"
"github.com/Ouest-France/phpipam-sdk-go/controllers/sections"
"github.com/Ouest-France/phpipam-sdk-go/phpipam"
)

// resourceSectionOptionalFields represents all the fields that are optional in
Expand Down
4 changes: 2 additions & 2 deletions plugin/providers/phpipam/subnet_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/subnets"
"github.com/paybyphone/phpipam-sdk-go/phpipam"
"github.com/Ouest-France/phpipam-sdk-go/controllers/subnets"
"github.com/Ouest-France/phpipam-sdk-go/phpipam"
)

// resourceSubnetOptionalFields represents all the fields that are optional in
Expand Down
2 changes: 1 addition & 1 deletion plugin/providers/phpipam/vlan_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/paybyphone/phpipam-sdk-go/controllers/vlans"
"github.com/Ouest-France/phpipam-sdk-go/controllers/vlans"
)

// resourceVLANOptionalFields represents all the fields that are optional in
Expand Down
19 changes: 0 additions & 19 deletions vendor/github.com/apparentlymart/go-cidr/LICENSE

This file was deleted.

105 changes: 0 additions & 105 deletions vendor/github.com/apparentlymart/go-cidr/cidr/cidr.go

This file was deleted.

Loading