@@ -48,6 +48,8 @@ import (
4848
4949 dbapi "github.com/oracle/oracle-database-operator/apis/database/v1alpha1"
5050 dbcommons "github.com/oracle/oracle-database-operator/commons/database"
51+ "golang.org/x/text/cases"
52+ "golang.org/x/text/language"
5153
5254 "github.com/go-logr/logr"
5355 corev1 "k8s.io/api/core/v1"
@@ -130,7 +132,7 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
130132 if singleInstanceDatabase .Status .Status == "" {
131133 singleInstanceDatabase .Status .Status = dbcommons .StatusPending
132134 if singleInstanceDatabase .Spec .Edition != "" {
133- singleInstanceDatabase .Status .Edition = strings .Title (singleInstanceDatabase .Spec .Edition )
135+ singleInstanceDatabase .Status .Edition = cases .Title ( language . English ). String (singleInstanceDatabase .Spec .Edition )
134136 } else {
135137 singleInstanceDatabase .Status .Edition = dbcommons .ValueUnavailable
136138 }
@@ -150,7 +152,7 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
150152 return result , nil
151153 }
152154 if err != nil {
153- r .Log .Error (err ,err .Error ())
155+ r .Log .Error (err , err .Error ())
154156 return result , err
155157 }
156158
@@ -205,8 +207,6 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
205207 }
206208 }
207209
208-
209-
210210 if strings .ToUpper (singleInstanceDatabase .Status .Role ) == "PRIMARY" {
211211
212212 // Update DB config
@@ -236,17 +236,17 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
236236 if err != nil {
237237 return requeueY , err
238238 }
239-
240- databaseOpenMode ,err := dbcommons .GetDatabaseOpenMode (readyPod , r , r .Config , ctx , req , singleInstanceDatabase .Spec .Edition )
241-
239+
240+ databaseOpenMode , err := dbcommons .GetDatabaseOpenMode (readyPod , r , r .Config , ctx , req , singleInstanceDatabase .Spec .Edition )
241+
242242 if err != nil {
243243 r .Log .Error (err , err .Error ())
244244 return requeueY , err
245245 }
246246 r .Log .Info ("DB openMode Output" )
247247 r .Log .Info (databaseOpenMode )
248248 if databaseOpenMode == "READ_ONLY" {
249- out , err := dbcommons .ExecCommand (r , r .Config , readyPod .Name , readyPod .Namespace , "" , ctx , req , false , "bash" , "-c" ,fmt .Sprintf ("echo -e \" %s\" | %s" ,dbcommons .ModifyStdbyDBOpenMode ,dbcommons .SQLPlusCLI ))
249+ out , err := dbcommons .ExecCommand (r , r .Config , readyPod .Name , readyPod .Namespace , "" , ctx , req , false , "bash" , "-c" , fmt .Sprintf ("echo -e \" %s\" | %s" , dbcommons .ModifyStdbyDBOpenMode , dbcommons .SQLPlusCLI ))
250250 if err != nil {
251251 r .Log .Error (err , err .Error ())
252252 return requeueY , err
@@ -398,7 +398,7 @@ func (r *SingleInstanceDatabaseReconciler) validate(m *dbapi.SingleInstanceDatab
398398
399399 // If Express/Free Edition, ensure Replicas=1
400400 if (m .Spec .Edition == "express" || m .Spec .Edition == "free" ) && m .Spec .Replicas > 1 {
401- eventMsgs = append (eventMsgs , m .Spec .Edition + " edition supports only one replica" )
401+ eventMsgs = append (eventMsgs , m .Spec .Edition + " edition supports only one replica" )
402402 }
403403 // If no persistence, ensure Replicas=1
404404 if m .Spec .Persistence .Size == "" && m .Spec .Replicas > 1 {
@@ -422,10 +422,10 @@ func (r *SingleInstanceDatabaseReconciler) validate(m *dbapi.SingleInstanceDatab
422422 eventMsgs = append (eventMsgs , "cloneFrom cannot be updated" )
423423 }
424424 if (m .Spec .Edition == "express" || m .Spec .Edition == "free" ) && m .Spec .CloneFrom != "" {
425- eventMsgs = append (eventMsgs , "cloning not supported for " + m .Spec .Edition + " edition" )
425+ eventMsgs = append (eventMsgs , "cloning not supported for " + m .Spec .Edition + " edition" )
426426 }
427427 if (m .Spec .Edition == "express" || m .Spec .Edition == "free" ) && m .Spec .PrimaryDatabaseRef != "" && m .Spec .CreateAsStandby {
428- eventMsgs = append (eventMsgs , "Standby database creation is not supported for " + m .Spec .Edition + " edition" )
428+ eventMsgs = append (eventMsgs , "Standby database creation is not supported for " + m .Spec .Edition + " edition" )
429429 }
430430 if m .Status .OrdsReference != "" && m .Status .Persistence .Size != "" && m .Status .Persistence != m .Spec .Persistence {
431431 eventMsgs = append (eventMsgs , "uninstall ORDS to change Peristence" )
@@ -1502,7 +1502,7 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
15021502 if sid == "" || pdbName == "" || edition == "" {
15031503 return requeueN , nil
15041504 }
1505- m .Status .Edition = strings .Title (edition )
1505+ m .Status .Edition = cases .Title ( language . English ). String (edition )
15061506 }
15071507
15081508 if m .Spec .LoadBalancer {
@@ -2050,27 +2050,26 @@ func (r *SingleInstanceDatabaseReconciler) validateDBReadiness(m *dbapi.SingleIn
20502050 m .Status .ReleaseUpdate = version
20512051 }
20522052 }
2053- dbMajorVersion , err := strconv .Atoi (strings .Split (m .Status .ReleaseUpdate ,"." )[0 ])
2053+ dbMajorVersion , err := strconv .Atoi (strings .Split (m .Status .ReleaseUpdate , "." )[0 ])
20542054 if err != nil {
20552055 r .Log .Error (err , err .Error ())
20562056 return requeueY , readyPod , err
20572057 }
20582058 r .Log .Info ("DB Major Version is " + strconv .Itoa (dbMajorVersion ))
20592059 // Validating that free edition of the database is only supported from database 23c onwards
2060- if ( m .Spec .Edition == "free" && dbMajorVersion < 23 ) {
2061- r . Log . Info ( " Oracle Database Free is only supported from version 23c onwards")
2062- r .Recorder .Eventf (m , corev1 .EventTypeWarning , "Spec Error" , "Oracle Database Free is only supported from version 23c onwards" )
2060+ if m .Spec .Edition == "free" && dbMajorVersion < 23 {
2061+ errMsg := "the Oracle Database Free is only available from version 23c onwards"
2062+ r .Recorder .Eventf (m , corev1 .EventTypeWarning , "Spec Error" , errMsg )
20632063 m .Status .Status = dbcommons .StatusError
2064- return requeueN , readyPod , errors .New ("Oracle Database Free is only supported from version 23c onwards" )
2064+ return requeueN , readyPod , errors .New (errMsg )
20652065 }
2066- // Checking if OEM is supported in the provided Database version
2067- if ( dbMajorVersion >= 23 ) {
2066+ // Checking if OEM is supported in the provided Database version
2067+ if dbMajorVersion >= 23 {
20682068 m .Status .OemExpressUrl = dbcommons .ValueUnavailable
20692069 } else {
20702070 m .Status .OemExpressUrl = oemExpressUrl
20712071 }
20722072
2073-
20742073 if strings .ToUpper (m .Status .Role ) == "PRIMARY" && m .Status .DatafilesPatched != "true" {
20752074 eventReason := "Datapatch Pending"
20762075 eventMsg := "datapatch execution pending"
@@ -2647,7 +2646,6 @@ func (r *SingleInstanceDatabaseReconciler) manageSingleInstanceDatabaseDeletion(
26472646 m * dbapi.SingleInstanceDatabase ) (ctrl.Result , error ) {
26482647 log := r .Log .WithValues ("manageSingleInstanceDatabaseDeletion" , req .NamespacedName )
26492648
2650-
26512649 // Check if the SingleInstanceDatabase instance is marked to be deleted, which is
26522650 // indicated by the deletion timestamp being set.
26532651 isSingleInstanceDatabaseMarkedToBeDeleted := m .GetDeletionTimestamp () != nil
@@ -2704,11 +2702,11 @@ func (r *SingleInstanceDatabaseReconciler) cleanupSingleInstanceDatabase(req ctr
27042702 return requeueY , nil
27052703 }
27062704
2707- if ( m .Status .DgBrokerConfigured ) {
2705+ if m .Status .DgBrokerConfigured {
27082706 eventReason := "Cannot Delete"
2709- eventMsg := "Database cannot be deleted as it is present in a DataGuard Broker configuration"
2707+ eventMsg := "database cannot be deleted as it is present in a DataGuard Broker configuration"
27102708 r .Recorder .Eventf (m , corev1 .EventTypeWarning , eventReason , eventReason )
2711- return requeueY ,errors .New (eventMsg )
2709+ return requeueY , errors .New (eventMsg )
27122710 }
27132711
27142712 // call deletePods() with zero pods in avaiable and nil readyPod to delete all pods
@@ -2864,7 +2862,7 @@ func ValidatePrimaryDatabaseForStandbyCreation(r *SingleInstanceDatabaseReconcil
28642862 log .Info (fmt .Sprintf ("Validating primary database %s configuration..." , primary .Name ))
28652863 err = ValidateDatabaseConfiguration (primary )
28662864 if err != nil {
2867- r .Recorder .Eventf (stdby ,corev1 .EventTypeWarning ,"Spec Error" , "all of Archivelog, Flashback and ForceLogging modes are not enabled in the primary database " + primary .Name )
2865+ r .Recorder .Eventf (stdby , corev1 .EventTypeWarning , "Spec Error" , "all of Archivelog, Flashback and ForceLogging modes are not enabled in the primary database " + primary .Name )
28682866 stdby .Status .Status = dbcommons .StatusError
28692867 return err
28702868 }
0 commit comments