Skip to content

Commit 1f1d524

Browse files
parrneetcodycushing
authored andcommitted
Refactor waitTillCondition to rename WaitConditionFunc and condition
1 parent 0fefaf3 commit 1f1d524

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

oci/test_helpers.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ func TestCheckResourceAttributesEqual(name1, key1, name2, key2 string) resource.
9797
}
9898

9999
// Function to be implemented by resources that wish to wait on a certain condition and this function is responsible for evaluating the specific condition for that resource
100-
type WaitConditionFunc func(response oci_common.OCIOperationResponse) bool
100+
type ShouldWaitFunc func(response oci_common.OCIOperationResponse) bool
101101

102102
// Function to be implemented by resources that wish to wait on a certain condition and this function is responsible for fetching the latest state using the resourceId
103103
type FetchOperationFunc func(client *OracleClients, resourceId *string, retryPolicy *oci_common.RetryPolicy) error
104104

105-
// This function waits for the given time and retries the WaitConditionFunc and periodically invokes the FetchOperationFunc to fetch the latest response
106-
func waitTillCondition(testAccProvider *schema.Provider, resourceId *string, condition WaitConditionFunc, timeout time.Duration,
105+
// This function waits for the given time and retries the ShouldWaitFunc and periodically invokes the FetchOperationFunc to fetch the latest response
106+
func waitTillCondition(testAccProvider *schema.Provider, resourceId *string, shouldWait ShouldWaitFunc, timeout time.Duration,
107107
fetchOperationFunc FetchOperationFunc, service string, disableNotFoundRetries bool) func() {
108108
return func() {
109109
client := testAccProvider.Meta().(*OracleClients)
110110
log.Printf("[INFO] start of waitTillCondition for resource %s ", *resourceId)
111111
retryPolicy := getRetryPolicy(disableNotFoundRetries, service)
112-
retryPolicy.ShouldRetryOperation = conditionShouldRetry(timeout, condition, service, disableNotFoundRetries)
112+
retryPolicy.ShouldRetryOperation = conditionShouldRetry(timeout, shouldWait, service, disableNotFoundRetries)
113113

114114
err := fetchOperationFunc(client, resourceId, retryPolicy)
115115
if err != nil {
@@ -120,8 +120,8 @@ func waitTillCondition(testAccProvider *schema.Provider, resourceId *string, con
120120
}
121121
}
122122

123-
// This function is responsible for the actual check for WaitConditionFunc and the aborting
124-
func conditionShouldRetry(timeout time.Duration, condition WaitConditionFunc, service string, disableNotFoundRetries bool) func(response oci_common.OCIOperationResponse) bool {
123+
// This function is responsible for the actual check for ShouldWaitFunc and the aborting
124+
func conditionShouldRetry(timeout time.Duration, shouldWait ShouldWaitFunc, service string, disableNotFoundRetries bool) func(response oci_common.OCIOperationResponse) bool {
125125
startTime := time.Now()
126126
stopTime := startTime.Add(timeout)
127127
return func(response oci_common.OCIOperationResponse) bool {
@@ -136,7 +136,7 @@ func conditionShouldRetry(timeout time.Duration, condition WaitConditionFunc, se
136136
return true
137137
}
138138

139-
return condition(response)
139+
return shouldWait(response)
140140
}
141141
}
142142

0 commit comments

Comments
 (0)