Skip to content

Commit ee54dd2

Browse files
committed
removed dot imports and unused codes
1 parent d0b6c59 commit ee54dd2

9 files changed

+43
-325
lines changed

commons/oci/database.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func isAttrChanged(lastSucObj interface{}, curObj interface{}) bool {
175175
if !ok {
176176
return false
177177
}
178-
curIntPtr, ok := curObj.(*int)
178+
curIntPtr := curObj.(*int)
179179

180180
if lastSucIntPtr != nil && curIntPtr != nil && *curIntPtr != 0 && *lastSucIntPtr != *curIntPtr {
181181
return true
@@ -500,15 +500,6 @@ func getCompleteWorkRetryPolicy() common.RetryPolicy {
500500
return getRetryPolicy(shouldRetry)
501501
}
502502

503-
func getConflictRetryPolicy() common.RetryPolicy {
504-
// retry for 409 conflict status code
505-
shouldRetry := func(r common.OCIOperationResponse) bool {
506-
return r.Error != nil && r.Response.HTTPResponse().StatusCode == 409
507-
}
508-
509-
return getRetryPolicy(shouldRetry)
510-
}
511-
512503
func getRetryPolicy(retryOperation func(common.OCIOperationResponse) bool) common.RetryPolicy {
513504
// maximum times of retry
514505
attempts := uint(10)

commons/oci/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func GetOCIProvider(kubeClient client.Client, authData APIKeyAuth) (common.Confi
7777
} else if authData.ConfigMapName == nil && authData.SecretName == nil {
7878
return auth.InstancePrincipalConfigurationProvider()
7979
} else {
80-
return nil, errors.New("You have to provide both the OCI ConfigMap and the privateKey to authorize with API signing key, " +
81-
"or leave them both empty to authorize with Instance Principal. Check if the spec configuration is correct.")
80+
return nil, errors.New("both the OCI ConfigMap and the privateKey are required to authorize with API signing key; " +
81+
"leave them both empty to authorize with Instance Principal")
8282
}
8383
}
8484

test/e2e/autonomousdatabase_controller_bind_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ import (
4242
"context"
4343
"time"
4444

45-
. "github.com/onsi/ginkgo"
46-
. "github.com/onsi/gomega"
4745
"github.com/oracle/oci-go-sdk/v45/common"
4846
"github.com/oracle/oci-go-sdk/v45/database"
4947
"github.com/oracle/oci-go-sdk/v45/workrequests"
@@ -61,7 +59,6 @@ import (
6159
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
6260

6361
var _ = Describe("test ADB binding with hardLink=true", func() {
64-
const bindingHardLinkTestFileName = "bind_adb_hardLink.yaml"
6562
var adbLookupKey types.NamespacedName
6663
const downloadedWallet = "instance-wallet-secret-1"
6764
var adbID *string

test/e2e/autonomousdatabase_controller_create_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ import (
4242
"context"
4343
"time"
4444

45-
. "github.com/onsi/ginkgo"
46-
. "github.com/onsi/gomega"
4745
"github.com/oracle/oci-go-sdk/v45/common"
4846
"github.com/oracle/oci-go-sdk/v45/database"
4947
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -59,11 +57,6 @@ import (
5957
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
6058

6159
var _ = Describe("test ADB provisioning", func() {
62-
const (
63-
changeStateTimeout = time.Second * 300
64-
changeStateInterval = time.Second * 10
65-
)
66-
6760
AfterEach(func() {
6861
// IMPORTANT: The operator might have to call reconcile multiple times to finish an operation.
6962
// If we do the update immediately, the previous reconciliation will overwrite the changes.

test/e2e/behavior/shared_behaviors.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ import (
4545
"reflect"
4646
"time"
4747

48-
. "github.com/onsi/ginkgo"
49-
. "github.com/onsi/gomega"
48+
"github.com/onsi/ginkgo"
49+
"github.com/onsi/gomega"
5050
"github.com/oracle/oci-go-sdk/v45/common"
5151
"github.com/oracle/oci-go-sdk/v45/database"
5252
corev1 "k8s.io/api/core/v1"
@@ -65,6 +65,19 @@ import (
6565
* to the function, which is likely to be nil or zero value.
6666
**************************************************************/
6767

68+
var (
69+
Describe = ginkgo.Describe
70+
By = ginkgo.By
71+
GinkgoWriter = ginkgo.GinkgoWriter
72+
Expect = gomega.Expect
73+
BeNil = gomega.BeNil
74+
Eventually = gomega.Eventually
75+
Equal = gomega.Equal
76+
Succeed = gomega.Succeed
77+
BeNumerically = gomega.BeNumerically
78+
BeTrue = gomega.BeTrue
79+
)
80+
6881
func AssertProvision(k8sClient *client.Client, adbLookupKey *types.NamespacedName) func() {
6982
return func() {
7083
// Set the timeout to 15 minutes. The provision operation might take up to 10 minutes

test/e2e/suite_test.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import (
4444
"testing"
4545
"time"
4646

47-
. "github.com/onsi/ginkgo"
48-
. "github.com/onsi/gomega"
47+
"github.com/onsi/ginkgo"
48+
"github.com/onsi/gomega"
4949
"github.com/onsi/gomega/gexec"
5050
"github.com/oracle/oci-go-sdk/v45/common"
5151
"github.com/oracle/oci-go-sdk/v45/database"
@@ -77,6 +77,21 @@ This test suite runs the integration test which checks the following scenario
7777
5. Test ADB binding with hardLink=true
7878
**/
7979

80+
// To avoid dot import
81+
var (
82+
BeforeSuite = ginkgo.BeforeSuite
83+
AfterSuite = ginkgo.AfterSuite
84+
Describe = ginkgo.Describe
85+
AfterEach = ginkgo.AfterEach
86+
By = ginkgo.By
87+
It = ginkgo.It
88+
Expect = gomega.Expect
89+
Succeed = gomega.Succeed
90+
HaveOccurred = gomega.HaveOccurred
91+
BeNil = gomega.BeNil
92+
Equal = gomega.Equal
93+
)
94+
8095
var cfg *rest.Config
8196
var k8sClient client.Client
8297
var configProvider common.ConfigurationProvider
@@ -100,15 +115,15 @@ const SharedAdminPassSecretName string = "adb-admin-password"
100115
const SharedWalletPassSecretName = "adb-wallet-password"
101116

102117
func TestAPIs(t *testing.T) {
103-
RegisterFailHandler(Fail)
118+
gomega.RegisterFailHandler(ginkgo.Fail)
104119

105-
RunSpecsWithDefaultAndCustomReporters(t,
120+
ginkgo.RunSpecsWithDefaultAndCustomReporters(t,
106121
"Controller Suite",
107-
[]Reporter{printer.NewlineReporter{}})
122+
[]ginkgo.Reporter{printer.NewlineReporter{}})
108123
}
109124

110-
var _ = BeforeSuite(func(done Done) {
111-
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
125+
var _ = BeforeSuite(func(done ginkgo.Done) {
126+
logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true)))
112127

113128
By("bootstrapping test environment")
114129
testEnv = &envtest.Environment{
@@ -145,7 +160,7 @@ var _ = BeforeSuite(func(done Done) {
145160
Expect(err).ToNot(HaveOccurred())
146161

147162
go func() {
148-
defer GinkgoRecover()
163+
defer ginkgo.GinkgoRecover()
149164
err = k8sManager.Start(ctrl.SetupSignalHandler())
150165
Expect(err).ToNot(HaveOccurred(), "failed to run manager")
151166
gexec.KillAndWait(4 * time.Second)

test/e2e/util/oci_config_util.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ type configUtil struct {
6262

6363
//ConfigFileInfo
6464
FileInfo *configFileInfo
65-
66-
provider common.ConfigurationProvider
6765
}
6866

6967
func (p configUtil) readAndParseConfigFile() (*configFileInfo, error) {
@@ -125,17 +123,7 @@ func (p configUtil) CreateOCISecret(secretNamespace string, secretName string) (
125123
}
126124

127125
func (p configUtil) GetConfigProvider() (common.ConfigurationProvider, error) {
128-
if p.provider != nil {
129-
return p.provider, nil
130-
}
131-
132-
newProvider, err := common.ConfigurationProviderFromFileWithProfile(p.OCIConfigPath, p.Profile, "")
133-
if err != nil {
134-
return nil, nil
135-
}
136-
137-
p.provider = newProvider
138-
return newProvider, nil
126+
return common.ConfigurationProviderFromFileWithProfile(p.OCIConfigPath, p.Profile, "")
139127
}
140128

141129
func openConfigFile(configFilePath string) (data []byte, err error) {
@@ -193,7 +181,7 @@ func parseConfigFile(data []byte, profile string) (info *configFileInfo, err err
193181

194182
//Look for profile
195183
for i, line := range splitContent {
196-
if match := profileRegex.FindStringSubmatch(line); match != nil && len(match) > 1 && match[1] == profile {
184+
if match := profileRegex.FindStringSubmatch(line); len(match) > 1 && match[1] == profile {
197185
start := i + 1
198186
return parseConfigAtLine(start, splitContent)
199187
}

test/e2e/util/oci_db_request.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -130,30 +130,6 @@ func generateRetryPolicy(retryFunc func(r common.OCIOperationResponse) bool) com
130130
return common.NewRetryPolicy(attempts, retryFunc, nextDuration)
131131
}
132132

133-
func NewDisplayNameRetryPolicy(name string) common.RetryPolicy {
134-
shouldRetry := func(r common.OCIOperationResponse) bool {
135-
if databaseResponse, ok := r.Response.(database.GetAutonomousDatabaseResponse); ok {
136-
// do the retry until lifecycle state reaches the passed terminal state
137-
return databaseResponse.LifecycleState != database.AutonomousDatabaseLifecycleStateAvailable ||
138-
*databaseResponse.DisplayName != name
139-
}
140-
return true
141-
}
142-
return generateRetryPolicy(shouldRetry)
143-
}
144-
145-
func NewCPUCoreCountRetryPolicy(count int) common.RetryPolicy {
146-
shouldRetry := func(r common.OCIOperationResponse) bool {
147-
if databaseResponse, ok := r.Response.(database.GetAutonomousDatabaseResponse); ok {
148-
// do the retry until lifecycle state reaches the passed terminal state
149-
return databaseResponse.LifecycleState != database.AutonomousDatabaseLifecycleStateAvailable ||
150-
*databaseResponse.CpuCoreCount != count
151-
}
152-
return true
153-
}
154-
return generateRetryPolicy(shouldRetry)
155-
}
156-
157133
func NewLifecycleStateRetryPolicy(lifecycleState database.AutonomousDatabaseLifecycleStateEnum) common.RetryPolicy {
158134
shouldRetry := func(r common.OCIOperationResponse) bool {
159135
if databaseResponse, ok := r.Response.(database.GetAutonomousDatabaseResponse); ok {

0 commit comments

Comments
 (0)