Skip to content

Commit 802f4c1

Browse files
committed
fix review findings
1 parent dce7674 commit 802f4c1

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

exp/runtime/hooks/api/v1alpha1/common_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const (
8383
// CommonRetryResponse is the data structure which contains all
8484
// common retry fields.
8585
type CommonRetryResponse struct {
86+
// CommonResponse contains Status and Message fields common to all response types.
87+
CommonResponse `json:",inline"`
88+
8689
// RetryAfterSeconds when set to a non-zero value signifies that the hook
8790
// will be called again at a future time.
8891
RetryAfterSeconds int32 `json:"retryAfterSeconds"`

exp/runtime/hooks/api/v1alpha1/lifecyclehooks_types.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ var _ RetryResponseObject = &BeforeClusterCreateResponse{}
3939
type BeforeClusterCreateResponse struct {
4040
metav1.TypeMeta `json:",inline"`
4141

42-
// CommonResponse contains Status and Message fields common to all response types.
43-
CommonResponse `json:",inline"`
44-
4542
// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
4643
CommonRetryResponse `json:",inline"`
4744
}
@@ -95,9 +92,6 @@ var _ RetryResponseObject = &BeforeClusterUpgradeResponse{}
9592
type BeforeClusterUpgradeResponse struct {
9693
metav1.TypeMeta `json:",inline"`
9794

98-
// CommonResponse contains Status and Message fields common to all response types.
99-
CommonResponse `json:",inline"`
100-
10195
// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
10296
CommonRetryResponse `json:",inline"`
10397
}
@@ -125,9 +119,6 @@ var _ RetryResponseObject = &AfterControlPlaneUpgradeResponse{}
125119
type AfterControlPlaneUpgradeResponse struct {
126120
metav1.TypeMeta `json:",inline"`
127121

128-
// CommonResponse contains Status and Message fields common to all response types.
129-
CommonResponse `json:",inline"`
130-
131122
// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
132123
CommonRetryResponse `json:",inline"`
133124
}
@@ -179,9 +170,6 @@ var _ RetryResponseObject = &BeforeClusterDeleteResponse{}
179170
type BeforeClusterDeleteResponse struct {
180171
metav1.TypeMeta `json:",inline"`
181172

182-
// CommonResponse contains Status and Message fields common to all response types.
183-
CommonResponse `json:",inline"`
184-
185173
// CommonRetryResponse contains RetryAfterSeconds field common to all retry response types.
186174
CommonRetryResponse `json:",inline"`
187175
}

exp/runtime/hooks/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/runtime/hooks/api/v1alpha1/zz_generated.openapi.go

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/runtime/client/client.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,17 @@ func aggregateSuccessfulResponses(aggregatedResponse runtimehooksv1.ResponseObje
217217
aggregatedResponse.SetMessage("")
218218
aggregatedResponse.SetStatus(runtimehooksv1.ResponseStatusSuccess)
219219

220-
if _, ok := aggregatedResponse.(runtimehooksv1.RetryResponseObject); !ok {
220+
aggregatedRetryResponse, ok := aggregatedResponse.(runtimehooksv1.RetryResponseObject)
221+
if !ok {
221222
// If the aggregated response is not a RetryResponseObject then we're done.
222223
return
223224
}
224-
225225
// Note: as all responses have the same type we can assume now that
226226
// they all implement the RetryResponseObject interface.
227-
aggregatedRetryableResponse := aggregatedResponse.(runtimehooksv1.RetryResponseObject)
228227

229228
for _, resp := range responses {
230-
aggregatedRetryableResponse.SetRetryAfterSeconds(lowestNonZeroRetryAfterSeconds(
231-
aggregatedRetryableResponse.GetRetryAfterSeconds(),
229+
aggregatedRetryResponse.SetRetryAfterSeconds(lowestNonZeroRetryAfterSeconds(
230+
aggregatedRetryResponse.GetRetryAfterSeconds(),
232231
resp.(runtimehooksv1.RetryResponseObject).GetRetryAfterSeconds(),
233232
))
234233
}

internal/runtime/client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func TestClient_CallExtension(t *testing.T) {
556556
}
557557
}
558558

559-
func Test_client_CallAllExtensions(t *testing.T) {
559+
func TestClient_CallAllExtensions(t *testing.T) {
560560
testHostPort := "127.0.0.1:9090"
561561

562562
fpFail := runtimev1.FailurePolicyFail

0 commit comments

Comments
 (0)