@@ -6,7 +6,7 @@ package odb
6
6
import (
7
7
"context"
8
8
"errors"
9
- "regexp "
9
+ "github.com/YakDriver/regexache "
10
10
"strings"
11
11
"time"
12
12
@@ -74,7 +74,7 @@ func (r *resourceCloudVmCluster) Schema(ctx context.Context, req resource.Schema
74
74
diskRedundancyType := fwtypes .StringEnumType [odbtypes.DiskRedundancy ]()
75
75
computeModelType := fwtypes .StringEnumType [odbtypes.ComputeModel ]()
76
76
giVersionValidator := []validator.String {
77
- stringvalidator .RegexMatches (regexp .MustCompile (MajorGiVersionPattern ), "Gi version must be of the format 19.0.0.0" ),
77
+ stringvalidator .RegexMatches (regexache .MustCompile (MajorGiVersionPattern ), "Gi version must be of the format 19.0.0.0" ),
78
78
}
79
79
resp .Schema = schema.Schema {
80
80
Attributes : map [string ]schema.Attribute {
@@ -489,8 +489,8 @@ func (r *resourceCloudVmCluster) Create(ctx context.Context, req resource.Create
489
489
plan .HostnamePrefix = types .StringValue (hostnamePrefix )
490
490
plan .HostnamePrefixComputed = types .StringValue (* createdVmCluster .Hostname )
491
491
//scan listener port not returned by API directly
492
- plan .ScanListenerPortTcp = types . Int32PointerValue ( createdVmCluster .ListenerPort )
493
- plan .GiVersionComputed = types . StringPointerValue ( createdVmCluster .GiVersion )
492
+ plan .ScanListenerPortTcp = flex . Int32ToFramework ( ctx , createdVmCluster .ListenerPort )
493
+ plan .GiVersionComputed = flex . StringToFramework ( ctx , createdVmCluster .GiVersion )
494
494
giVersionMajor , err := getMajorGiVersion (createdVmCluster .GiVersion )
495
495
if err != nil {
496
496
resp .Diagnostics .AddError (
@@ -499,7 +499,7 @@ func (r *resourceCloudVmCluster) Create(ctx context.Context, req resource.Create
499
499
)
500
500
return
501
501
}
502
- plan .GiVersion = types . StringPointerValue ( giVersionMajor )
502
+ plan .GiVersion = flex . StringToFramework ( ctx , giVersionMajor )
503
503
resp .Diagnostics .Append (flex .Flatten (ctx , createdVmCluster , & plan )... )
504
504
if resp .Diagnostics .HasError () {
505
505
return
@@ -532,8 +532,8 @@ func (r *resourceCloudVmCluster) Read(ctx context.Context, req resource.ReadRequ
532
532
state .HostnamePrefix = types .StringValue (hostnamePrefix )
533
533
state .HostnamePrefixComputed = types .StringValue (* out .Hostname )
534
534
//scan listener port not returned by API directly
535
- state .ScanListenerPortTcp = types . Int32PointerValue ( out .ListenerPort )
536
- state .GiVersionComputed = types . StringPointerValue ( out .GiVersion )
535
+ state .ScanListenerPortTcp = flex . Int32ToFramework ( ctx , out .ListenerPort )
536
+ state .GiVersionComputed = flex . StringToFramework ( ctx , out .GiVersion )
537
537
giVersionMajor , err := getMajorGiVersion (out .GiVersion )
538
538
if err != nil {
539
539
resp .Diagnostics .AddError (
@@ -542,7 +542,7 @@ func (r *resourceCloudVmCluster) Read(ctx context.Context, req resource.ReadRequ
542
542
)
543
543
return
544
544
}
545
- state .GiVersion = types . StringPointerValue ( giVersionMajor )
545
+ state .GiVersion = flex . StringToFramework ( ctx , giVersionMajor )
546
546
resp .Diagnostics .Append (flex .Flatten (ctx , out , & state )... )
547
547
if resp .Diagnostics .HasError () {
548
548
return
@@ -656,7 +656,7 @@ func FindCloudVmClusterForResourceByID(ctx context.Context, conn *odb.Client, id
656
656
func getMajorGiVersion (giVersionComputed * string ) (* string , error ) {
657
657
giVersionMajor := strings .Split (* giVersionComputed , "." )[0 ]
658
658
giVersionMajor = giVersionMajor + ".0.0.0"
659
- regxGiVersionMajor := regexp .MustCompile (MajorGiVersionPattern )
659
+ regxGiVersionMajor := regexache .MustCompile (MajorGiVersionPattern )
660
660
if ! regxGiVersionMajor .MatchString (giVersionMajor ) {
661
661
err := errors .New ("gi_version major retrieved from gi_version_computed does not match the pattern 19.0.0.0" )
662
662
return nil , err
0 commit comments