Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cli does not use cli-runtime deprecated method #5406

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/cli/cmd/accounts/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/klog/v2"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

Expand Down Expand Up @@ -61,7 +61,7 @@ var (
errClusterNameorInstName = fmt.Errorf("specify either cluster name or --instance")
)

func NewAccountBaseOptions(f cmdutil.Factory, streams genericclioptions.IOStreams, op lorryutil.OperationKind) *AccountBaseOptions {
func NewAccountBaseOptions(f cmdutil.Factory, streams genericiooptions.IOStreams, op lorryutil.OperationKind) *AccountBaseOptions {
return &AccountBaseOptions{
ExecOptions: exec.NewExecOptions(f, streams),
AccountOp: op,
Expand Down Expand Up @@ -147,7 +147,7 @@ func (o *AccountBaseOptions) Complete(f cmdutil.Factory) error {
return nil
}

func (o *AccountBaseOptions) Run(cmd *cobra.Command, f cmdutil.Factory, streams genericclioptions.IOStreams) error {
func (o *AccountBaseOptions) Run(cmd *cobra.Command, f cmdutil.Factory, streams genericiooptions.IOStreams) error {
var err error
response, err := o.Do()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/cmd/accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes/scheme"
clientfake "k8s.io/client-go/rest/fake"
Expand All @@ -44,14 +44,14 @@ var _ = Describe("Base Account Options", func() {
)

var (
streams genericclioptions.IOStreams
streams genericiooptions.IOStreams
tf *cmdtesting.TestFactory
cluster = testing.FakeCluster(clusterName, namespace)
pods = testing.FakePods(3, namespace, clusterName)
)

BeforeEach(func() {
streams, _, _, _ = genericclioptions.NewTestIOStreams()
streams, _, _, _ = genericiooptions.NewTestIOStreams()
tf = testing.NewTestFactory(namespace)
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
httpResp := func(obj runtime.Object) *http.Response {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cmd/accounts/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package accounts
import (
"github.com/sethvargo/go-password/password"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

lorryutil "github.com/apecloud/kubeblocks/lorry/util"
Expand All @@ -33,7 +33,7 @@ type CreateUserOptions struct {
info lorryutil.UserInfo
}

func NewCreateUserOptions(f cmdutil.Factory, streams genericclioptions.IOStreams) *CreateUserOptions {
func NewCreateUserOptions(f cmdutil.Factory, streams genericiooptions.IOStreams) *CreateUserOptions {
return &CreateUserOptions{
AccountBaseOptions: NewAccountBaseOptions(f, streams, lorryutil.CreateUserOp),
}
Expand Down
7 changes: 4 additions & 3 deletions internal/cli/cmd/accounts/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes/scheme"
clientfake "k8s.io/client-go/rest/fake"
Expand All @@ -44,14 +45,14 @@ var _ = Describe("Create Account Options", func() {
)

var (
streams genericclioptions.IOStreams
streams genericiooptions.IOStreams
tf *cmdtesting.TestFactory
cluster = testing.FakeCluster(clusterName, namespace)
pods = testing.FakePods(3, namespace, clusterName)
)

BeforeEach(func() {
streams, _, _, _ = genericclioptions.NewTestIOStreams()
streams, _, _, _ = genericiooptions.NewTestIOStreams()
tf = testing.NewTestFactory(namespace)
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
httpResp := func(obj runtime.Object) *http.Response {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cmd/accounts/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package accounts

import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

"github.com/apecloud/kubeblocks/internal/cli/util/prompt"
Expand All @@ -34,7 +34,7 @@ type DeleteUserOptions struct {
info lorryutil.UserInfo
}

func NewDeleteUserOptions(f cmdutil.Factory, streams genericclioptions.IOStreams) *DeleteUserOptions {
func NewDeleteUserOptions(f cmdutil.Factory, streams genericiooptions.IOStreams) *DeleteUserOptions {
return &DeleteUserOptions{
AccountBaseOptions: NewAccountBaseOptions(f, streams, lorryutil.DeleteUserOp),
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/cmd/accounts/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes/scheme"
clientfake "k8s.io/client-go/rest/fake"
Expand All @@ -45,15 +45,15 @@ var _ = Describe("Delete Account Options", func() {
)

var (
streams genericclioptions.IOStreams
streams genericiooptions.IOStreams
in *bytes.Buffer
tf *cmdtesting.TestFactory
cluster = testing.FakeCluster(clusterName, namespace)
pods = testing.FakePods(3, namespace, clusterName)
)

BeforeEach(func() {
streams, in, _, _ = genericclioptions.NewTestIOStreams()
streams, in, _, _ = genericiooptions.NewTestIOStreams()
tf = testing.NewTestFactory(namespace)
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
httpResp := func(obj runtime.Object) *http.Response {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cmd/accounts/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package accounts

import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

lorryutil "github.com/apecloud/kubeblocks/lorry/util"
Expand All @@ -32,7 +32,7 @@ type DescribeUserOptions struct {
info lorryutil.UserInfo
}

func NewDescribeUserOptions(f cmdutil.Factory, streams genericclioptions.IOStreams) *DescribeUserOptions {
func NewDescribeUserOptions(f cmdutil.Factory, streams genericiooptions.IOStreams) *DescribeUserOptions {
return &DescribeUserOptions{
AccountBaseOptions: NewAccountBaseOptions(f, streams, lorryutil.DescribeUserOp),
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/cmd/accounts/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes/scheme"
clientfake "k8s.io/client-go/rest/fake"
Expand All @@ -44,14 +44,14 @@ var _ = Describe("Describe Account Options", func() {
)

var (
streams genericclioptions.IOStreams
streams genericiooptions.IOStreams
tf *cmdtesting.TestFactory
cluster = testing.FakeCluster(clusterName, namespace)
pods = testing.FakePods(3, namespace, clusterName)
)

BeforeEach(func() {
streams, _, _, _ = genericclioptions.NewTestIOStreams()
streams, _, _, _ = genericiooptions.NewTestIOStreams()
tf = testing.NewTestFactory(namespace)
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
httpResp := func(obj runtime.Object) *http.Response {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cmd/accounts/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/spf13/cobra"
"golang.org/x/exp/slices"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/klog/v2"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

Expand All @@ -36,7 +36,7 @@ type GrantOptions struct {
info lorryutil.UserInfo
}

func NewGrantOptions(f cmdutil.Factory, streams genericclioptions.IOStreams, op lorryutil.OperationKind) *GrantOptions {
func NewGrantOptions(f cmdutil.Factory, streams genericiooptions.IOStreams, op lorryutil.OperationKind) *GrantOptions {
if (op != lorryutil.GrantUserRoleOp) && (op != lorryutil.RevokeUserRoleOp) {
klog.V(1).Infof("invalid operation kind: %s", op)
return nil
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/cmd/accounts/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes/scheme"
clientfake "k8s.io/client-go/rest/fake"
Expand All @@ -44,14 +44,14 @@ var _ = Describe("Grant Account Options", func() {
)

var (
streams genericclioptions.IOStreams
streams genericiooptions.IOStreams
tf *cmdtesting.TestFactory
cluster = testing.FakeCluster(clusterName, namespace)
pods = testing.FakePods(3, namespace, clusterName)
)

BeforeEach(func() {
streams, _, _, _ = genericclioptions.NewTestIOStreams()
streams, _, _, _ = genericiooptions.NewTestIOStreams()
tf = testing.NewTestFactory(namespace)
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
httpResp := func(obj runtime.Object) *http.Response {
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/cmd/accounts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package accounts

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"

lorryutil "github.com/apecloud/kubeblocks/lorry/util"
Expand All @@ -30,7 +30,7 @@ type ListUserOptions struct {
*AccountBaseOptions
}

func NewListUserOptions(f cmdutil.Factory, streams genericclioptions.IOStreams) *ListUserOptions {
func NewListUserOptions(f cmdutil.Factory, streams genericiooptions.IOStreams) *ListUserOptions {
return &ListUserOptions{
AccountBaseOptions: NewAccountBaseOptions(f, streams, lorryutil.ListUsersOp),
}
Expand Down
7 changes: 4 additions & 3 deletions internal/cli/cmd/accounts/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/kubernetes/scheme"
clientfake "k8s.io/client-go/rest/fake"
Expand All @@ -44,14 +45,14 @@ var _ = Describe("List Account Options", func() {
)

var (
streams genericclioptions.IOStreams
streams genericiooptions.IOStreams
tf *cmdtesting.TestFactory
cluster = testing.FakeCluster(clusterName, namespace)
pods = testing.FakePods(3, namespace, clusterName)
)

BeforeEach(func() {
streams, _, _, _ = genericclioptions.NewTestIOStreams()
streams, _, _, _ = genericiooptions.NewTestIOStreams()
tf = testing.NewTestFactory(namespace)
codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...)
httpResp := func(obj runtime.Object) *http.Response {
Expand Down
14 changes: 7 additions & 7 deletions internal/cli/cmd/addon/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
discoverycli "k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
Expand Down Expand Up @@ -76,7 +76,7 @@ func (r *addonEnableFlags) useDefault() bool {
}

type addonCmdOpts struct {
genericclioptions.IOStreams
genericiooptions.IOStreams

Factory cmdutil.Factory
dynamic dynamic.Interface
Expand All @@ -90,7 +90,7 @@ type addonCmdOpts struct {
}

// NewAddonCmd for addon functions
func NewAddonCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func NewAddonCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "addon COMMAND",
Short: "Addon command.",
Expand All @@ -104,7 +104,7 @@ func NewAddonCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.
return cmd
}

func newListCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func newListCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := list.NewListOptions(f, streams, types.AddonGVR())
cmd := &cobra.Command{
Use: "list",
Expand All @@ -120,7 +120,7 @@ func newListCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
return cmd
}

func newDescribeCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func newDescribeCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := &addonCmdOpts{
Options: patch.NewOptions(f, streams, types.AddonGVR()),
Factory: f,
Expand All @@ -142,7 +142,7 @@ func newDescribeCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cob
return cmd
}

func newEnableCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func newEnableCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := &addonCmdOpts{
Options: patch.NewOptions(f, streams, types.AddonGVR()),
Factory: f,
Expand Down Expand Up @@ -228,7 +228,7 @@ re-enable the addon (More info on how-to resize a PVC: https://kubernetes.io/doc
return cmd
}

func newDisableCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func newDisableCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := &addonCmdOpts{
Options: patch.NewOptions(f, streams, types.AddonGVR()),
Factory: f,
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/cmd/addon/addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/kubernetes/scheme"
Expand All @@ -44,11 +44,11 @@ const (
)

var _ = Describe("Manage applications related to KubeBlocks", func() {
var streams genericclioptions.IOStreams
var streams genericiooptions.IOStreams
var tf *cmdtesting.TestFactory

BeforeEach(func() {
streams, _, _, _ = genericclioptions.NewTestIOStreams()
streams, _, _, _ = genericiooptions.NewTestIOStreams()
tf = cmdtesting.NewTestFactory().WithNamespace(testNamespace)
})

Expand Down
6 changes: 3 additions & 3 deletions internal/cli/cmd/alert/add_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apitypes "k8s.io/apimachinery/pkg/types"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/client-go/kubernetes"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/templates"
Expand Down Expand Up @@ -69,7 +69,7 @@ var (
)

type baseOptions struct {
genericclioptions.IOStreams
genericiooptions.IOStreams
alertConfigMap *corev1.ConfigMap
webhookConfigMap *corev1.ConfigMap
client kubernetes.Interface
Expand All @@ -90,7 +90,7 @@ type addReceiverOptions struct {
webhookAdaptorReceivers []webhookAdaptorReceiver
}

func newAddReceiverCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
func newAddReceiverCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := addReceiverOptions{baseOptions: baseOptions{IOStreams: streams}}
cmd := &cobra.Command{
Use: "add-receiver",
Expand Down
Loading