Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #44 from rh-mobb/support_multiple_workerpool
Browse files Browse the repository at this point in the history
Support multiple workerpools
  • Loading branch information
datianshi authored Dec 5, 2023
2 parents a6f9610 + 972bb1d commit a93b432
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 77 deletions.
22 changes: 0 additions & 22 deletions azureopenshift/parse/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
28 changes: 0 additions & 28 deletions azureopenshift/parse/cluster_test.go

This file was deleted.

19 changes: 4 additions & 15 deletions azureopenshift/redhatopenshift_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion docs/resources/redhatopenshift_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down

0 comments on commit a93b432

Please sign in to comment.