Skip to content

Commit

Permalink
fix(networks): network id conversion to string (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredscheib authored Jun 30, 2020
1 parent 523e927 commit d96738b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/terraform-provider-paperspace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"reflect"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -316,7 +317,7 @@ func (paperspaceClient *PaperspaceClient) GetTeamNamedNetwork(teamID int, name s
}
}

return nil, fmt.Errorf("Error getting private network: %s", name)
return nil, fmt.Errorf("Error getting private network by name: %s", name)
}

func (paperspaceClient *PaperspaceClient) GetTeamNamedNetworkById(teamID int, id string) (*NamedNetwork, error) {
Expand All @@ -326,10 +327,10 @@ func (paperspaceClient *PaperspaceClient) GetTeamNamedNetworkById(teamID int, id
}

for _, namedNetwork := range namedNetworks {
if string(namedNetwork.Network.ID) == id {
if strconv.Itoa(namedNetwork.Network.ID) == id {
return &namedNetwork, nil
}
}

return nil, fmt.Errorf("Error getting private network: %s", id)
return nil, fmt.Errorf("Error getting private network by id: %s", id)
}
5 changes: 3 additions & 2 deletions src/terraform-provider-paperspace/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"math/rand"
"strconv"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
Expand Down Expand Up @@ -68,7 +69,7 @@ func resourceNetworkCreate(d *schema.ResourceData, m interface{}) error {
return resource.RetryableError(fmt.Errorf("Error creating private network: %s", err))
}

d.SetId(string(namedNetwork.Network.ID))
d.SetId(strconv.Itoa(namedNetwork.Network.ID))
return resource.NonRetryableError(resourceNetworkRead(d, m))
})
}
Expand All @@ -86,7 +87,7 @@ func resourceNetworkRead(d *schema.ResourceData, m interface{}) error {
return err
}

d.SetId(string(namedNetwork.Network.ID))
d.SetId(strconv.Itoa(namedNetwork.Network.ID))
updateNetworkSchema(d, namedNetwork.Network, namedNetwork.Name)

return nil
Expand Down

0 comments on commit d96738b

Please sign in to comment.