Skip to content

Commit

Permalink
PLT-1353: Refreshed SDK and fixed overlorduid constant (#504)
Browse files Browse the repository at this point in the history
* added new unit tests (#501)

Co-authored-by: ”Srinivas <“[email protected]”>

* new unit testcases (#502)

* added new unit tests

* added new unit test cases

---------

Co-authored-by: ”Srinivas <“[email protected]”>

* PLT-1353: Refreshed sdk and fixed overlorduid constent

* refreshed sdk

* fixed reviewable

---------

Co-authored-by: Srinivas DM <[email protected]>
Co-authored-by: ”Srinivas <“[email protected]”>
  • Loading branch information
3 people authored Aug 26, 2024
1 parent 6a9a547 commit 6d785ef
Show file tree
Hide file tree
Showing 132 changed files with 606 additions and 185 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ require (
github.com/robfig/cron v1.2.0
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d
github.com/spectrocloud/palette-api-go v0.2.6
github.com/spectrocloud/palette-sdk-go v0.0.0-20240805053215-cd5a46468dda
github.com/spectrocloud/palette-sdk-go v0.0.0-20240823154409-68556f429886
github.com/stretchr/testify v1.9.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.23.5
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,8 @@ github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368 h1:eY0BOyEbGu
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368/go.mod h1:LlZ9We4kDaELYi7Is0SVmnySuDhwphJLS6ZT4wXxFIk=
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d h1:OMRbHxMJ1a+G1BYzvUYuMM0wLkYJPdnEOFx16faQ/UY=
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d/go.mod h1:MktpRPnSXDTHsQrFSD+daJFQ1zMLSR+1gWOL31jVvWE=
github.com/spectrocloud/palette-api-go v0.2.6 h1:TWkNqrAJqrJMdQSM+4bk0oHuxQ2J4FEtcUgZhpJ4Tu4=
github.com/spectrocloud/palette-api-go v0.2.6/go.mod h1:eVUuGUStbOI/gvWluNJzVcCy8vnRye3MqpWDlr94ui8=
github.com/spectrocloud/palette-sdk-go v0.0.0-20240805053215-cd5a46468dda h1:9z4L4ve3bYll4bA50+oVRZnu5S4Xx4OHnLfEtmqqTU4=
github.com/spectrocloud/palette-sdk-go v0.0.0-20240805053215-cd5a46468dda/go.mod h1:uA8TWXU822CAajPhWXwfMrlhEv8PbdNqDsJbGzRUUbw=
github.com/spectrocloud/palette-sdk-go v0.0.0-20240823154409-68556f429886 h1:PmSzDOzrhHYkFWe6eRQQpvFeCFaTIfQzISQXuAATyZ4=
github.com/spectrocloud/palette-sdk-go v0.0.0-20240823154409-68556f429886/go.mod h1:dSlNvDS0qwUWTbrYI6P8x981mcbbRHFrBg67v5zl81U=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/addon_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"

"github.com/spectrocloud/terraform-provider-spectrocloud/types"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/addon_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package spectrocloud

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/terraform-provider-spectrocloud/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/application_create_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package spectrocloud
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/terraform-provider-spectrocloud/types"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
"strings"
)
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
"strings"
)
Expand Down
71 changes: 71 additions & 0 deletions spectrocloud/cluster_common_hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,74 @@ func TestResourceMachinePoolOpenStackHash(t *testing.T) {
})
}
}

func TestResourceMachinePoolGkeHash(t *testing.T) {
testCases := []struct {
input interface{}
expected int
}{
{
input: map[string]interface{}{
"instance_type": "n1-standard-4",
"disk_size_gb": 100,
},
expected: 1800178524,
},

{
input: map[string]interface{}{
"instance_type": "n1-standard-4",
},
//expected: 987654321, // Replace with expected hash value
expected: int(hash("n1-standard-4-")),
},
}

for _, tc := range testCases {
actual := resourceMachinePoolGkeHash(tc.input)
if actual != tc.expected {
t.Errorf("Expected hash %d, but got %d for input %+v", tc.expected, actual, tc.input)
}
}
}

func TestResourceMachinePoolCustomCloudHash(t *testing.T) {
testCases := []struct {
name string
input interface{}
expected int
}{
{
name: "With all fields",
input: map[string]interface{}{
"name": "custom-cloud",
"count": 3,
"control_plane": true,
"control_plane_as_worker": false, //comment this for fail test
"additional_labels": map[string]string{"env": "prod"},
"taints": []interface{}{"key1=value1", "key2=value2"},
"node_pool_config": "standard",
},
expected: 208692298,
},
{
name: "Missing optional fields",
input: map[string]interface{}{
"name": "test-pool",
"count": 3,
"node_pool_config": "standard", //comment this for fail test
},
expected: 1525978111,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actual := resourceMachinePoolCustomCloudHash(tc.input)
fmt.Printf("Debug: For input %+v, got hash %d, expected %d\n", tc.input, actual, tc.expected)
if actual != tc.expected {
t.Errorf("For test case '%s', expected hash %d, but got %d for input %+v", tc.name, tc.expected, actual, tc.input)
}
})
}
}
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

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

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

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

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_ospatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/robfig/cron"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"

"github.com/spectrocloud/terraform-provider-spectrocloud/types"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package spectrocloud
import (
"testing"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/stretchr/testify/assert"

"github.com/spectrocloud/terraform-provider-spectrocloud/types"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package spectrocloud
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_taints.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package spectrocloud

import (
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
)

func toClusterTaints(m map[string]interface{}) []*models.V1Taint {
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sort"
"testing"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_update_strategy.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package spectrocloud

import (
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
)

func getUpdateStrategy(m map[string]interface{}) string {
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_common_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/spectrocloud/hapi/apiutil/transport"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_node_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/cluster_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/common_cluster_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package spectrocloud
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/palette-sdk-go/client"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/hapi_to_kubevirt_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"

"github.com/go-openapi/strfmt"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
kubevirtapiv1 "kubevirt.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/hapi_to_kubevirt_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
kubevirtapiv1 "kubevirt.io/api/core/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/hapi_to_kubevirt_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package convert
import (
"encoding/json"
"fmt"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"github.com/spectrocloud/terraform-provider-spectrocloud/types"
k8sv1 "k8s.io/api/core/v1"
kubevirtapiv1 "kubevirt.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/kubevirt_to_hapi_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"

"github.com/go-openapi/strfmt"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubevirtapiv1 "kubevirt.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/kubevirt_to_hapi_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"encoding/json"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
kubevirtapiv1 "kubevirt.io/api/core/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/kubevirt_to_hapi_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
kubevirtapiv1 "kubevirt.io/api/core/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/volume_hapi_to_kubevirt_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/convert/volume_kubevirt_to_hapi_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
)

Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/data_source_backup_storage_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
)

func dataSourceBackupStorageLocation() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion spectrocloud/data_source_cloud_account_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/spectrocloud/palette-api-go/models"
"github.com/spectrocloud/palette-sdk-go/api/models"
)

func dataSourceCloudAccountAws() *schema.Resource {
Expand Down
Loading

0 comments on commit 6d785ef

Please sign in to comment.