diff --git a/azureopenshift/parse/cluster.go b/azureopenshift/parse/cluster.go index 89ad52e..92dbbea 100644 --- a/azureopenshift/parse/cluster.go +++ b/azureopenshift/parse/cluster.go @@ -3,12 +3,9 @@ package parse // NOTE: this file is generated via 'go:generate' - manual changes will be overwritten import ( - "errors" "fmt" - "regexp" "strings" - redhatopenshift "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift" "github.com/rh-mobb/terraform-provider-azureopenshift/helpers/azure" ) @@ -65,22 +62,3 @@ func ClusterID(input string) (*ClusterId, error) { return &resourceId, nil } - -//heack: we want to get load balancer name. But API does not expose that yet. - -func InternalClusterId(clusterName string, workerProfiles []*redhatopenshift.WorkerProfile) (*string, error) { - if len(workerProfiles) < 1 { - return nil, errors.New("need at least 1 worker profile to calculate internal cluster id") - } - profile := (workerProfiles)[0] - es := `(.+)-(.+?)-worker-.+` - rgx, err := regexp.Compile(es) - if err != nil { - return nil, err - } - matches := rgx.FindStringSubmatch(*profile.Name) - if len(matches) != 3 { - return nil, fmt.Errorf("can not capture the internal cluster id with cluster name %s, profile worker name %s, matches: %v", clusterName, *profile.Name, matches) - } - return &matches[2], nil -} diff --git a/azureopenshift/parse/cluster_test.go b/azureopenshift/parse/cluster_test.go deleted file mode 100644 index 0511320..0000000 --- a/azureopenshift/parse/cluster_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package parse_test - -import ( - "testing" - - redhatopenshift "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift" - "github.com/rh-mobb/terraform-provider-azureopenshift/azureopenshift/parse" -) - -func TestParseInternalClusterId(t *testing.T) { - captureClusterId("test-tf", "test-tf-2gk5b-worker-eastus21", t) - captureClusterId("test-tf-001", "test-tf-001-2gk5b-worker-eastus22", t) - captureClusterId("aro-001-xxxx-cp4i-dev-use2", "aro-001-xxxx-cp4i-dev-2gk5b-worker-eastus21", t) -} - -func captureClusterId(clusterName, testString string, t *testing.T) { - workerProfiles := []*redhatopenshift.WorkerProfile{ - { - Name: &testString, - }, - } - clusterId, err := parse.InternalClusterId(clusterName, workerProfiles) - if err != nil { - t.Errorf("can not get id with cluster name %s and work profile name %s: error %v", clusterName, testString, err) - } else if *clusterId != "2gk5b" { - t.Errorf("the cluster id shoud equal to %s, but it is %s", "2gk5b", *clusterId) - } -} diff --git a/azureopenshift/redhatopenshift_cluster_resource.go b/azureopenshift/redhatopenshift_cluster_resource.go index 6d246ec..f76880a 100644 --- a/azureopenshift/redhatopenshift_cluster_resource.go +++ b/azureopenshift/redhatopenshift_cluster_resource.go @@ -204,12 +204,6 @@ func resourceOpenShiftCluster() *schema.Resource { Sensitive: true, }, - "internal_cluster_id": { - Type: schema.TypeString, - Computed: true, - Optional: true, - }, - "worker_profile": { Type: schema.TypeList, Required: true, @@ -514,13 +508,6 @@ func resourceOpenShiftClusterRead(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("setting `worker_profile`: %+v", err) } - internalClusterId, err := parse.InternalClusterId(*resp.Name, props.WorkerProfiles) - if err != nil { - return err - } - - d.Set("internal_cluster_id", internalClusterId) - apiServerProfile := flattenOpenShiftAPIServerProfile(props.ApiserverProfile) if err := d.Set("api_server_profile", apiServerProfile); err != nil { return fmt.Errorf("setting `api_server_profile`: %+v", err) @@ -700,14 +687,16 @@ func flattenOpenShiftMasterProfile(profile *redhatopenshift.MasterProfile) []int } func flattenOpenShiftWorkerProfiles(profiles []*redhatopenshift.WorkerProfile) []interface{} { - if profiles == nil { + + // Expect the default worker profile only has one item + if profiles == nil || len(profiles) != 1 { return []interface{}{} } results := make([]interface{}, 0) result := make(map[string]interface{}) - result["node_count"] = int32(len(profiles)) + result["node_count"] = profiles[0].Count for _, profile := range profiles { if result["disk_size_gb"] == nil && profile.DiskSizeGB != nil { diff --git a/docs/resources/redhatopenshift_cluster.md b/docs/resources/redhatopenshift_cluster.md index 635aa81..25345aa 100644 --- a/docs/resources/redhatopenshift_cluster.md +++ b/docs/resources/redhatopenshift_cluster.md @@ -30,7 +30,6 @@ description: |- - `cluster_profile` (Block List, Max: 1) (see [below for nested schema](#nestedblock--cluster_profile)) - `cluster_resource_group` (String) (Name for the managed resources' RG. OpenShift will create this RG) - `ingress_profile` (Block List, Max: 1) (see [below for nested schema](#nestedblock--ingress_profile)) -- `internal_cluster_id` (String) (5-digit string appended to resources inside the managed Resource Group) - `kubeadmin_password` (String, Sensitive) - `kubeadmin_username` (String, Sensitive) - `network_profile` (Block List, Max: 1) (see [below for nested schema](#nestedblock--network_profile)) diff --git a/go.mod b/go.mod index 4c0af23..979b566 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,12 @@ module github.com/rh-mobb/terraform-provider-azureopenshift go 1.21 -toolchain go1.21.3 +// toolchain go1.21.3 require ( // Tag on sdk/resourcemanager/redhatopenshift/armredhatopenshift/v1.3.0 // NOTE: do not upgrade, this is a breaking change. - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift v1.3.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift v1.4.0 github.com/Azure/go-autorest/autorest v0.11.27 github.com/hashicorp/go-azure-helpers v0.33.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 @@ -16,9 +16,9 @@ require ( ) require ( - // NOTE: do not upgrade, this is a breaking change. - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 + // NOTE: do not upgrade, this is a breaking change. + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( diff --git a/go.sum b/go.sum index 77e5e51..613afa5 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 h1:9kDVnTz3vbfweTqAUmk/a/pH5pWFCHtvRpHYC0G/dcA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift v1.3.0 h1:cfwKRh/rjSuFD8q6xpzf0QrjrNhojZ+7f1kd4Pin9dU= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift v1.3.0/go.mod h1:gd2AQItO9TKnTAGll01Nyia0vJP1lHuSeCGK39UtUow= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift v1.4.0 h1:JzvbqVwpP2v8mqL6iR7bMkPWGvOhvzRdG53c44SCGd4= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redhatopenshift/armredhatopenshift v1.4.0/go.mod h1:H7M23akJJ6PZRnzdidlmJWF/+upaVzD81SKtZXYf9Ys= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.27 h1:F3R3q42aWytozkV8ihzcgMO4OA4cuqr3bNlsEuF6//A=