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

Commit

Permalink
Set empty ID on 404 for ip addr (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-ruth authored Jun 4, 2020
1 parent a7fc131 commit e989007
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bA
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
6 changes: 6 additions & 0 deletions plugin/providers/phpipam/data_source_phpipam_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package phpipam

import (
"errors"
"strings"

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

0 comments on commit e989007

Please sign in to comment.