mirror of
https://github.com/fluxcd/flux2.git
synced 2026-04-29 06:38:50 +00:00
Update to controller-runtime 0.7.0
controller-runtime methods now accept `client.Object` and `client.ObjectList` rather than `runtime.Object`. This means the adapter interfaces need to change signature, but happily, little else. Since the list adapter is now distinct to the object adapter, `len()` can go there instead of the command-specific interfaces. Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
parent
b30ef523f8
commit
d03280a12f
6 changed files with 75 additions and 19 deletions
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
// Most commands need one or both of the kind (e.g.,
|
||||
|
|
@ -35,16 +35,24 @@ type apiType struct {
|
|||
// use values of the wrapper with `client.Client`, which only deals
|
||||
// with types that have been added to the schema.
|
||||
type adapter interface {
|
||||
asRuntimeObject() runtime.Object
|
||||
asRuntimeObject() client.Object
|
||||
}
|
||||
|
||||
// universalAdapter is an adapter for any runtime.Object. Use this if
|
||||
// listAdapater is the analogue to adapter, but for lists; the
|
||||
// controller runtime distinguishes between methods dealing with
|
||||
// objects and lists.
|
||||
type listAdapter interface {
|
||||
asRuntimeList() client.ObjectList
|
||||
len() int
|
||||
}
|
||||
|
||||
// universalAdapter is an adapter for any client.Object. Use this if
|
||||
// there are no other methods needed.
|
||||
type universalAdapter struct {
|
||||
obj runtime.Object
|
||||
obj client.Object
|
||||
}
|
||||
|
||||
func (c universalAdapter) asRuntimeObject() runtime.Object {
|
||||
func (c universalAdapter) asRuntimeObject() client.Object {
|
||||
return c.obj
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue