Skip to content
This repository was archived by the owner on Mar 16, 2022. It is now read-only.

Commit e989007

Browse files
authored
Set empty ID on 404 for ip addr (#19)
1 parent a7fc131 commit e989007

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bA
264264
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
265265
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
266266
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
267+
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
267268
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
268269
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
269270
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=

plugin/providers/phpipam/data_source_phpipam_address.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package phpipam
22

33
import (
44
"errors"
5+
"strings"
56

67
"github.com/Ouest-France/phpipam-sdk-go/controllers/addresses"
78
"github.com/hashicorp/terraform/helper/schema"
@@ -24,6 +25,11 @@ func dataSourcePHPIPAMAddressRead(d *schema.ResourceData, meta interface{}) erro
2425
case d.Get("address_id").(int) != 0:
2526
out[0], err = c.GetAddressByID(d.Get("address_id").(int))
2627
if err != nil {
28+
if strings.Contains(err.Error(), "\"code\":404") {
29+
// IP not found by id
30+
d.SetId("")
31+
return nil
32+
}
2733
return err
2834
}
2935
case d.Get("ip_address").(string) != "":

0 commit comments

Comments
 (0)