Add delete image-policy and refactor
This adds a command for deleting ImagePolicy objects. Since the control flow for the command needs only a runtime.Object (and a name for the type), it can be factored out. I have made the argument (field in the deleteCommand struct) an interface `objectContainer`, through which the command code gets a `runtime.Object` to deserialise into (and delete). It could be simply a `runtime.Object` here; however things like `getCommand` require other methods, so it's convenient to have an interface for it. Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
@@ -46,7 +45,7 @@ func init() {
|
||||
}
|
||||
|
||||
type summarisable interface {
|
||||
AsObject() runtime.Object
|
||||
objectContainer
|
||||
Len() int
|
||||
SummariseAt(i int, includeNamespace bool) []string
|
||||
Headers(includeNamespace bool) []string
|
||||
@@ -93,7 +92,7 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error {
|
||||
if !allNamespaces {
|
||||
listOpts = append(listOpts, client.InNamespace(namespace))
|
||||
}
|
||||
err = kubeClient.List(ctx, get.list.AsObject(), listOpts...)
|
||||
err = kubeClient.List(ctx, get.list.AsClientObject(), listOpts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user