Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions provider/cluster_rosa_classic_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ func (t *ClusterRosaClassicResourceType) GetSchema(ctx context.Context) (result
Type: types.StringType,
Computed: true,
},
"domain": {
Description: "DNS Domain of Cluster",
Type: types.StringType,
Computed: true,
},
"compute_nodes": {
Description: "Number of compute nodes of the cluster.",
Type: types.Int64Type,
Expand Down Expand Up @@ -686,6 +691,9 @@ func populateRosaClassicClusterState(ctx context.Context, object *cmv1.Cluster,
state.ConsoleURL = types.String{
Value: object.Console().URL(),
}
state.Domain = types.String{
Value: fmt.Sprintf("%s.%s", object.Name(), object.DNS().BaseDomain()),
}
state.ComputeNodes = types.Int64{
Value: int64(object.Nodes().Compute()),
}
Expand Down
13 changes: 9 additions & 4 deletions provider/cluster_rosa_classic_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
"net/http"

"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -48,6 +49,7 @@ const (
rosaCreatorArn = "arn:aws:iam::123456789012:dummy/dummy"
apiUrl = "https://api.my-cluster.com:6443"
consoleUrl = "https://console.my-cluster.com"
baseDomain = "alias.p1.openshiftapps.com"
machineType = "m5.xlarge"
availabilityZone1 = "us-east-1a"
availabilityZone2 = "us-east-1b"
Expand Down Expand Up @@ -76,7 +78,8 @@ var (

func generateBasicRosaClassicClusterJson() map[string]interface{} {
return map[string]interface{}{
"id": clusterId,
"id": clusterId,
"name": clusterName,
"region": map[string]interface{}{
"id": regionId,
},
Expand All @@ -90,6 +93,9 @@ func generateBasicRosaClassicClusterJson() map[string]interface{} {
"console": map[string]interface{}{
"url": consoleUrl,
},
"dns": map[string]interface{}{
"base_domain": baseDomain,
},
"nodes": map[string]interface{}{
"compute_machine_type": map[string]interface{}{
"id": machineType,
Expand Down Expand Up @@ -151,9 +157,7 @@ func generateBasicRosaClassicClusterState() *ClusterRosaClassicState {
Value: httpsProxy,
},
},
Sts: &Sts{

},
Sts: &Sts{},
}
}

Expand Down Expand Up @@ -218,6 +222,7 @@ var _ = Describe("Rosa Classic Sts cluster", func() {
Expect(clusterState.Properties.Elems["rosa_creator_arn"].Equal(types.String{Value: rosaCreatorArn})).To(Equal(true))
Expect(clusterState.APIURL.Value).To(Equal(apiUrl))
Expect(clusterState.ConsoleURL.Value).To(Equal(consoleUrl))
Expect(clusterState.Domain.Value).To(Equal(fmt.Sprintf("%s.%s", clusterName, baseDomain)))
Expect(clusterState.ComputeMachineType.Value).To(Equal(machineType))
Expect(clusterState.AvailabilityZones.Elems).To(HaveLen(1))
Expect(clusterState.AvailabilityZones.Elems[0].Equal(types.String{Value: availabilityZone1})).To(Equal(true))
Expand Down
1 change: 1 addition & 0 deletions provider/cluster_rosa_classic_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ClusterRosaClassicState struct {
ComputeMachineType types.String `tfsdk:"compute_machine_type"`
ComputeNodes types.Int64 `tfsdk:"compute_nodes"`
ConsoleURL types.String `tfsdk:"console_url"`
Domain types.String `tfsdk:"domain"`
HostPrefix types.Int64 `tfsdk:"host_prefix"`
ID types.String `tfsdk:"id"`
ExternalID types.String `tfsdk:"external_id"`
Expand Down