This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply go 1.18 generics across reconciler-runtime (#349)
This is a major breaking change that will affect all users of reconciler-runtime. There does not appear to be a way to transparently apply generics to an existing API that allows users to opt-in over time. User defined functions are now compile-time type checked, and IDEs will be able to offer completion for method signatures. At runtime these functions are directly invoked and are no longer called by reflection. Runtime type checking has been removed. Changes: - All existing deprecations are removed - All Reconcilers and SubReconcilers now operate on generic types of client.Object. - All reconciler Type/ChildType/ChildListType fields are now optional. They are only required if the generic type is an interface, or to define the apiVersion/kind for an Unstructured type. - SyncReconciler#Sync and #Finalize methods are split into two fields, one that is _WithResult and the default method which only returns an error. Signed-off-by: Scott Andrews <andrewssc@vmware.com>
- Loading branch information
Showing
21 changed files
with
1,165 additions
and
2,432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2023 VMware, Inc. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package internal | ||
|
||
import "reflect" | ||
|
||
// IsNil returns true if the value is nilable and nil | ||
func IsNil(val interface{}) bool { | ||
// return val == nil | ||
v := reflect.ValueOf(val) | ||
switch v.Kind() { | ||
case reflect.Chan: | ||
return v.IsNil() | ||
case reflect.Func: | ||
return v.IsNil() | ||
case reflect.Interface: | ||
return v.IsNil() | ||
case reflect.Map: | ||
return v.IsNil() | ||
case reflect.Ptr: | ||
return v.IsNil() | ||
case reflect.Slice: | ||
return v.IsNil() | ||
default: | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.