Skip to content

Commit

Permalink
pointer logic fixed|
Browse files Browse the repository at this point in the history
  • Loading branch information
Florin Mihalache committed May 21, 2021
1 parent e6f85d3 commit 838b972
Show file tree
Hide file tree
Showing 68 changed files with 56 additions and 22,387 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ require (
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/profitbricks/profitbricks-sdk-go/v5 v5.0.32
github.com/spf13/afero v1.3.1 // indirect
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJA
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So=
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
Expand Down Expand Up @@ -228,8 +226,6 @@ github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/ionos-cloud/sdk-go/v5 v5.1.0 h1:q6KWvirQ2td8f+w3sltWzQ7w1Sl9TbiSOcFRdarfSPo=
github.com/ionos-cloud/sdk-go/v5 v5.1.0/go.mod h1:dU3BVZgiBDAKyo41hFk7D5KWHfqyp4YL4rePIAi2JyM=
github.com/jarcoal/httpmock v1.0.5 h1:cHtVEcTxRSX4J0je7mWPfc9BpDpqzXSJ5HbymZmyHck=
github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down Expand Up @@ -314,8 +310,6 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/profitbricks/profitbricks-sdk-go/v5 v5.0.32 h1:WhV4paOBZWuIONDyCeOS7Brz8JkcktFEDKeijh0zB7k=
github.com/profitbricks/profitbricks-sdk-go/v5 v5.0.32/go.mod h1:x/4Vomth5nMhzd81Fqji+HfoE8S7cEulROLWFmx/U20=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
1 change: 1 addition & 0 deletions ionoscloud/data_source_datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func getDatacenter(client *ionoscloud.APIClient, d *schema.ResourceData) (*ionos
if locationOk {
location = t.(string)
}

if !idOk && !nameOk && !locationOk {
return nil, fmt.Errorf("either id, location or name must be set")
}
Expand Down
9 changes: 5 additions & 4 deletions ionoscloud/data_source_k8s_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func dataSourceK8sReadCluster(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("an error occurred while fetching k8s clusters: %s", err.Error())
}

found := false
if clusters.Items != nil {
for _, c := range *clusters.Items {
tmpCluster, _, err := client.KubernetesApi.K8sFindByClusterId(ctx, *c.Id).Execute()
Expand All @@ -144,18 +145,18 @@ func dataSourceK8sReadCluster(d *schema.ResourceData, meta interface{}) error {
if tmpCluster.Properties.Name != nil && *tmpCluster.Properties.Name == name.(string) {
/* lan found */
cluster = tmpCluster
found = true
break
}

}
}
if !found {
return errors.New("k8s cluster not found")
}

}

if &cluster == nil {
return errors.New("k8s cluster not found")
}

if err = setK8sClusterData(d, &cluster, client); err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion ionoscloud/data_source_k8s_cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build k8s

package ionoscloud

import (
Expand Down Expand Up @@ -77,6 +79,6 @@ resource "ionoscloud_k8s_cluster" "test_ds_k8s_cluster" {
}
data "ionoscloud_k8s_cluster" "test_ds_k8s_cluster" {
name = "test_"
name = "test_cluster"
}
`
9 changes: 6 additions & 3 deletions ionoscloud/data_source_k8s_node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func dataSourceK8sReadNodePool(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("an error occurred while fetching k8s nodepools: %s", err.Error())
}

found := false
if clusters.Items != nil {
for _, c := range *clusters.Items {
tmpNodePool, _, err := client.KubernetesApi.K8sNodepoolsFindById(ctx, clusterId.(string), *c.Id).Execute()
Expand All @@ -205,15 +206,17 @@ func dataSourceK8sReadNodePool(d *schema.ResourceData, meta interface{}) error {
if tmpNodePool.Properties.Name != nil && *tmpNodePool.Properties.Name == name.(string) {
/* lan found */
nodePool = tmpNodePool
found = true
break
}
}
}

}
if !found {
return errors.New("k8s nodePool not found")
}


if &nodePool == nil {
return errors.New("k8s nodePool not found")
}

if err = setK8sNodePoolData(d, &nodePool); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion ionoscloud/data_source_k8s_node_pool_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build k8s

package ionoscloud

import (
Expand Down Expand Up @@ -143,6 +145,6 @@ resource "ionoscloud_k8s_node_pool" "test_ds_k8s_node_pool" {
data "ionoscloud_k8s_node_pool" "test_ds_k8s_node_pool" {
k8s_cluster_id = ionoscloud_k8s_cluster.test_ds_k8s_cluster.id
name = "_nodepool"
name = "test_nodepool"
}
`
8 changes: 5 additions & 3 deletions ionoscloud/data_source_lan.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func dataSourceLanRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("an error occurred while fetching lans: %s", err.Error())
}

found := false
if lans.Items != nil {
for _, l := range *lans.Items {
if l.Properties.Name != nil && *l.Properties.Name == name.(string) {
Expand All @@ -150,14 +151,15 @@ func dataSourceLanRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return fmt.Errorf("an error occurred while fetching lan %s: %s", *l.Id, err)
}
found = true
break
}
}
}
}

if &lan == nil {
return errors.New("lan not found")
if !found {
return fmt.Errorf("lan not found")
}
}

if err = setLanData(d, &lan); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ionoscloud/data_source_lan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ resource "ionoscloud_lan" "test_ds_lan" {
data "ionoscloud_lan" "test_lan" {
datacenter_id = ionoscloud_datacenter.test_ds_lan.id
name = "test_ds_"
name = "test_ds_lan"
}
`
8 changes: 5 additions & 3 deletions ionoscloud/data_source_private_crossconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func dataSourcePccRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("an error occurred while fetching pccs: %s", err.Error())
}

found := false
if pccs.Items != nil {
for _, p := range *pccs.Items {
if p.Properties.Name != nil && *p.Properties.Name == name.(string) {
Expand All @@ -206,14 +207,15 @@ func dataSourcePccRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return fmt.Errorf("an error occurred while fetching the pcc with ID %s: %s", *p.Id, err)
}
found = true
break
}
}
}
}
if !found {
return errors.New("pcc not found")
}

if &pcc == nil {
return errors.New("pcc not found")
}

if err = setPccDataSource(d, &pcc); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ionoscloud/data_source_private_crossconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ resource "ionoscloud_private_crossconnect" "test_ds_pcc" {
description = "test_ds_pcc description"
}
data "ionoscloud_private_crossconnect" "test_pcc" {
name = "test_ds_"
name = "test_ds_pcc"
}
`
9 changes: 6 additions & 3 deletions ionoscloud/data_source_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ func dataSourceServerRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("an error occurred while fetching servers: %s", err.Error())
}

found := false
if servers.Items != nil {
for _, s := range *servers.Items {
if s.Properties.Name != nil && *s.Properties.Name == name.(string) {
Expand All @@ -583,14 +584,16 @@ func dataSourceServerRead(d *schema.ResourceData, meta interface{}) error {
if err != nil {
return fmt.Errorf("an error occurred while fetching the server with ID %s: %s", *s.Id, err)
}
found = true
break
}
}
}
}

if &server == nil {
return errors.New("server not found")
if !found {
return errors.New("server not found")
}

}

if err = setServerData(d, &server); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion ionoscloud/data_source_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ resource "ionoscloud_server" "test_datasource_server" {
data "ionoscloud_server" "test_server" {
datacenter_id = ionoscloud_datacenter.test_datasource_server.id
name = "test_datasource_"
name = "test_datasource_server"
}
`
2 changes: 2 additions & 0 deletions ionoscloud/import_k8s_cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build k8s

package ionoscloud

import (
Expand Down
4 changes: 4 additions & 0 deletions ionoscloud/import_k8s_node_pool_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build k8s

package ionoscloud

import (
Expand All @@ -14,10 +16,12 @@ func TestAcck8sNodepool_ImportBasic(t *testing.T) {
publicIp1 := os.Getenv("TF_ACC_IONOS_PUBLIC_IP_1")
if publicIp1 == "" {
t.Errorf("TF_ACC_IONOS_PUBLIC_1 not set; please set it to a valid public IP for the us/las zone")
t.FailNow()
}
publicIp2 := os.Getenv("TF_ACC_IONOS_PUBLIC_IP_2")
if publicIp2 == "" {
t.Errorf("TF_ACC_IONOS_PUBLIC_2 not set; please set it to a valid public IP for the us/las zone")
t.FailNow()
}

resource.Test(t, resource.TestCase{
Expand Down
2 changes: 2 additions & 0 deletions ionoscloud/resource_k8s_cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build k8s

package ionoscloud

import (
Expand Down
5 changes: 5 additions & 0 deletions ionoscloud/resource_k8s_node_pool_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build k8s

package ionoscloud

import (
Expand All @@ -19,14 +21,17 @@ func TestAcck8sNodepool_Basic(t *testing.T) {
publicIp1 := os.Getenv("TF_ACC_IONOS_PUBLIC_IP_1")
if publicIp1 == "" {
t.Errorf("TF_ACC_IONOS_PUBLIC_1 not set; please set it to a valid public IP for the us/las zone")
t.FailNow()
}
publicIp2 := os.Getenv("TF_ACC_IONOS_PUBLIC_IP_2")
if publicIp2 == "" {
t.Errorf("TF_ACC_IONOS_PUBLIC_2 not set; please set it to a valid public IP for the us/las zone")
t.FailNow()
}
publicIp3 := os.Getenv("TF_ACC_IONOS_PUBLIC_IP_3")
if publicIp3 == "" {
t.Errorf("TF_ACC_IONOS_PUBLIC_3 not set; please set it to a valid public IP for the us/las zone")
t.FailNow()
}

resource.Test(t, resource.TestCase{
Expand Down
31 changes: 0 additions & 31 deletions vendor/github.com/go-resty/resty/v2/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/go-resty/resty/v2/.travis.yml

This file was deleted.

36 changes: 0 additions & 36 deletions vendor/github.com/go-resty/resty/v2/BUILD.bazel

This file was deleted.

Loading

0 comments on commit 838b972

Please sign in to comment.