Skip to content

Commit

Permalink
Replace deprecated genericclioption.IOStreams (#450)
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 authored Oct 23, 2024
1 parent a9748d8 commit 88c1fb1
Show file tree
Hide file tree
Showing 83 changed files with 201 additions and 197 deletions.
3 changes: 2 additions & 1 deletion cmd/clusteradm/clusteradm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
"k8s.io/client-go/tools/clientcmd"
cliflag "k8s.io/component-base/cli/flag"
Expand Down Expand Up @@ -75,7 +76,7 @@ func main() {

f := cmdutil.NewFactory(matchVersionKubeConfigFlags)
root.SetGlobalNormalizationFunc(cliflag.WarnWordSepNormalizeFunc)
streams := genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}
streams := genericiooptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}

clusteradmFlags := genericclioptionsclusteradm.NewClusteradmFlags(f)
clusteradmFlags.AddFlags(flags)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/accept/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)

var example = `
Expand All @@ -19,7 +19,7 @@ var example = `
`

// NewCmd ...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/accept/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package accept

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

Expand All @@ -20,15 +20,15 @@ type Options struct {

Requesters []string

Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams
}

// Values used in the template
type Values struct {
Clusters []string
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
ClusterOptions: genericclioptionsclusteradm.NewClusterOption(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/addon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package addon

import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"open-cluster-management.io/clusteradm/pkg/cmd/addon/create"
"open-cluster-management.io/clusteradm/pkg/cmd/addon/disable"
"open-cluster-management.io/clusteradm/pkg/cmd/addon/enable"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

// NewCmd provides a cobra command wrapping NewCmdImportCluster
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "addon",
Short: "addon options",
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/addon/create/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
clusteradmhelpers "open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)

var example = `
Expand All @@ -17,7 +17,7 @@ Create an addon from manifests by using AddonTemplate
`

// NewCmd creates a cammand to create an addon
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/addon/create/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package create

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/utils/ptr"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)
Expand All @@ -25,10 +26,10 @@ type Options struct {

FileNameFlags genericclioptions.FileNameFlags
//
Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
Streams: streams,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/addon/disable/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
clusteradmhelpers "open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)

var example = `
Expand Down Expand Up @@ -37,7 +37,7 @@ var example = `
`

// NewCmd...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/addon/disable/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"

clusterapiv1 "open-cluster-management.io/api/cluster/v1"

Expand Down Expand Up @@ -51,7 +51,7 @@ var _ = ginkgo.Describe("addon disable", func() {
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "creat cluster error")
}

streams := genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}
streams := genericiooptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}

assertEnableAddon := func(addons []string, clusters []string, o *enable.Options) {
ns := o.Namespace
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/addon/disable/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package disable

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

Expand All @@ -15,10 +15,10 @@ type Options struct {
//The specified namespace for addon to disable
Namespace string

Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
Streams: streams,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/addon/enable/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
clusteradmhelpers "open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)

var example = `
Expand All @@ -35,7 +35,7 @@ var example = `
`

// NewCmd...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/addon/enable/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"

addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
clusterapiv1 "open-cluster-management.io/api/cluster/v1"
Expand Down Expand Up @@ -91,7 +91,7 @@ var _ = ginkgo.Describe("addon enable", func() {
gomega.Expect(err).ToNot(gomega.HaveOccurred())
}

streams := genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}
streams := genericiooptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}

// Generate entries for the `runWithClient` test table
addonTests := []ginkgo.TableEntry{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/addon/enable/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package enable

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

Expand All @@ -20,10 +20,10 @@ type Options struct {
//Annotations to add to the addon
Annotate []string
//
Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
Streams: streams,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clean/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

Expand All @@ -18,7 +18,7 @@ var example = `
`

// NewCmd ...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/clean/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package init

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

Expand All @@ -19,7 +19,7 @@ type Options struct {
//Delete the operator by default
purgeOperator bool

Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams
}

// Values: The values used in the template
Expand All @@ -36,7 +36,7 @@ type Hub struct {
TokenSecret string `json:"tokenSecret"`
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
Streams: streams,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clusterset/bind/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
clusteradmhelpers "open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)

var example = `
Expand All @@ -17,7 +17,7 @@ var example = `
`

// NewCmd...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/clusterset/bind/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
package bind

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

type Options struct {
//ClusteradmFlags: The generic options from the clusteradm cli-runtime.
ClusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags

Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams

Clusterset string

Namespace string
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
Streams: streams,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clusterset/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package clusterset

import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"open-cluster-management.io/clusteradm/pkg/cmd/clusterset/bind"
"open-cluster-management.io/clusteradm/pkg/cmd/clusterset/set"
"open-cluster-management.io/clusteradm/pkg/cmd/clusterset/unbind"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

// NewCmd provides a cobra command wrapping NewCmdImportCluster
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "clusterset",
Short: "clusterset options",
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clusterset/set/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
clusteradmhelpers "open-cluster-management.io/clusteradm/pkg/helpers"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
)

var example = `
Expand All @@ -17,7 +17,7 @@ var example = `
`

// NewCmd...
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *cobra.Command {
func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *cobra.Command {
o := NewOptions(clusteradmFlags, streams)

cmd := &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/clusterset/set/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
package set

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
)

type Options struct {
//ClusteradmFlags: The generic options from the clusteradm cli-runtime.
ClusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags

Streams genericclioptions.IOStreams
Streams genericiooptions.IOStreams

Clusters []string

Clusterset string
}

func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
func NewOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericiooptions.IOStreams) *Options {
return &Options{
ClusteradmFlags: clusteradmFlags,
Streams: streams,
Expand Down
Loading

0 comments on commit 88c1fb1

Please sign in to comment.