upgrade controller-runtime version from 0.14 to 0.16 #110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Upgrading the
controller-runtime
has introduced several changes, particularly to theclient.Client
interface and related components. Here's a breakdown of the changes and adaptations required:Issue 1: New Methods in
client.Client
After upgrading, the
client.Client
interface now includes two additional methods,GroupVersionKindFor
andIsObjectNamespaced
. Since your package implements several clients, you will need to implement these new methods for each client.Issue 2: Function Parameter Changes
Functions like
apiutil.NewDiscoveryRESTMapper
now require an external client to be passed in. To adapt, you can userest.HttpClientFor
to construct the new parameter using the first parameterconfig
.Issue 3: Refactoring Related to
cache.Options
Current State (version 0.14.x)
In version 0.14.x, the package has a
BuildCacheWithOptions
function, which directly usescache.BuilderWithOptions
to customize aNewCacheFunc
. ThisNewCacheFunc
is used in the vela main repository as theNewCacheFunc
for the manager to customize the cache. This customization is necessary because older versions of the manager could not directly customize the cache, requiring a custom function to handle cache options.Changes in 0.15.x
manager
options now include aCache
struct forcache.Options
.NewCacheFunc
now processes the cache options configured in the manager options, and it's no longer recommended to pass a customNewCacheFunc
.cache.Options
structure.Refactoring
To adapt to these changes, the following adjustments have been made on the package side:
BuildCacheWithOptions
andBuildCache
.BuildCacheOptionsWithShardingObjects
, which executes the original logic up to the construction ofcache.Options
and returns them directly.BuildCacheWithOptions
, the logic has been changed to first useBuildCacheOptionsWithShardingObjects
to construct the options, and then usecache.New
to construct the cache object. After verification, the test logic works correctly.Follow-up in Vela
The following adjustments need to be made in Vela:
NewCacheFunc
to usecache.Options
.Issue 4: Unit Testing
In version 0.15.0, the serialization logic for
unstructured
has been optimized. Previously, values likereplicas
were represented asint64
, but now they usefloat64
. As a result, unit tests have been modified to check for value equality rather than strict equality. For example:has been changed to:
In version 0.16.0, some shortcut functions were removed from the testing framework. These have been migrated according to the Deprecated documentation without affecting the test logic.