4
4
"context"
5
5
"fmt"
6
6
"regexp"
7
+ "strings"
7
8
"time"
8
9
9
10
"github.com/hashicorp/go-version"
@@ -1146,6 +1147,16 @@ func getECRRegistryAccountIdFromInstanceProfile(instanceProfile string) string {
1146
1147
return ""
1147
1148
}
1148
1149
1150
+ func getHopsworksVersion (v string ) * version.Version {
1151
+ ver := strings .Split (v , "_" )[0 ]
1152
+ versionObj , _ := version .NewVersion (ver )
1153
+ return versionObj
1154
+ }
1155
+
1156
+ func getHopsworksVersion3_0 () * version.Version {
1157
+ return getHopsworksVersion ("3.0.0" )
1158
+ }
1159
+
1149
1160
func createAWSCluster (d * schema.ResourceData , baseRequest * api.CreateCluster ) * api.CreateAWSCluster {
1150
1161
req := api.CreateAWSCluster {
1151
1162
CreateCluster : * baseRequest ,
@@ -1167,10 +1178,9 @@ func createAWSCluster(d *schema.ResourceData, baseRequest *api.CreateCluster) *a
1167
1178
req .EksClusterName = v .(string )
1168
1179
}
1169
1180
1170
- clusterVersion , _ := version .NewVersion (d .Get ("version" ).(string ))
1171
- versionWithDefaultECR , _ := version .NewVersion ("3.0.0" )
1181
+ clusterVersion := getHopsworksVersion (d .Get ("version" ).(string ))
1172
1182
1173
- if req .EksClusterName != "" || clusterVersion .GreaterThan (versionWithDefaultECR ) {
1183
+ if req .EksClusterName != "" || clusterVersion .GreaterThan (getHopsworksVersion3_0 () ) {
1174
1184
if registry , okR := d .GetOk ("aws_attributes.0.ecr_registry_account_id" ); okR {
1175
1185
req .EcrRegistryAccountId = registry .(string )
1176
1186
} else {
@@ -1253,10 +1263,9 @@ func createAzureCluster(d *schema.ResourceData, baseRequest *api.CreateCluster)
1253
1263
req .AksClusterName = aks .(string )
1254
1264
}
1255
1265
1256
- clusterVersion , _ := version .NewVersion (d .Get ("version" ).(string ))
1257
- versionWithDefaultECR , _ := version .NewVersion ("3.0.0" )
1266
+ clusterVersion := getHopsworksVersion (d .Get ("version" ).(string ))
1258
1267
1259
- if req .AksClusterName != "" || clusterVersion .GreaterThan (versionWithDefaultECR ) {
1268
+ if req .AksClusterName != "" || clusterVersion .GreaterThan (getHopsworksVersion3_0 () ) {
1260
1269
if registry , okR := d .GetOk ("azure_attributes.0.acr_registry_name" ); okR {
1261
1270
req .AcrRegistryName = registry .(string )
1262
1271
} else {
@@ -1464,11 +1473,10 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int
1464
1473
upgradeInProgressToVersion , upgradeInProgressToVersionOk := d .GetOk ("upgrade_in_progress.0.to_version" )
1465
1474
1466
1475
if ! upgradeInProgressFromVersionOk && ! upgradeInProgressToVersionOk {
1467
- clusterVersion , _ := version .NewVersion (toVersion )
1468
- versionWithDefaultECR , _ := version .NewVersion ("3.0.0" )
1476
+ clusterVersion := getHopsworksVersion (toVersion )
1469
1477
1470
1478
dockerRegistryAccount := ""
1471
- if clusterVersion .GreaterThan (versionWithDefaultECR ) {
1479
+ if clusterVersion .GreaterThan (getHopsworksVersion3_0 () ) {
1472
1480
if _ , ok := d .GetOk ("aws_attributes" ); ok {
1473
1481
if v , okR := d .GetOk ("aws_attributes.0.ecr_registry_account_id" ); okR {
1474
1482
dockerRegistryAccount = v .(string )
0 commit comments