Skip to content

Commit

Permalink
Stop using deprecated type
Browse files Browse the repository at this point in the history
This is not a breaking change since types are aliases
  • Loading branch information
ash2k committed Jun 18, 2024
1 parent 20ae0ed commit ce2a947
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 67 deletions.
8 changes: 4 additions & 4 deletions cmd/apply/cmdapply.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"sigs.k8s.io/cli-utils/cmd/flagutils"
Expand All @@ -22,7 +22,7 @@ import (
)

func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,
loader manifestreader.ManifestLoader, ioStreams genericclioptions.IOStreams) *Runner {
loader manifestreader.ManifestLoader, ioStreams genericiooptions.IOStreams) *Runner {
r := &Runner{
ioStreams: ioStreams,
factory: factory,
Expand Down Expand Up @@ -66,13 +66,13 @@ func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,
}

func Command(f cmdutil.Factory, invFactory inventory.ClientFactory, loader manifestreader.ManifestLoader,
ioStreams genericclioptions.IOStreams) *cobra.Command {
ioStreams genericiooptions.IOStreams) *cobra.Command {
return GetRunner(f, invFactory, loader, ioStreams).Command
}

type Runner struct {
Command *cobra.Command
ioStreams genericclioptions.IOStreams
ioStreams genericiooptions.IOStreams
factory cmdutil.Factory
invFactory inventory.ClientFactory
loader manifestreader.ManifestLoader
Expand Down
8 changes: 4 additions & 4 deletions cmd/destroy/cmddestroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"sigs.k8s.io/cli-utils/cmd/flagutils"
Expand All @@ -23,7 +23,7 @@ import (

// GetRunner creates and returns the Runner which stores the cobra command.
func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,
loader manifestreader.ManifestLoader, ioStreams genericclioptions.IOStreams) *Runner {
loader manifestreader.ManifestLoader, ioStreams genericiooptions.IOStreams) *Runner {
r := &Runner{
ioStreams: ioStreams,
factory: factory,
Expand Down Expand Up @@ -57,14 +57,14 @@ func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,

// Command creates the Runner, returning the cobra command associated with it.
func Command(f cmdutil.Factory, invFactory inventory.ClientFactory, loader manifestreader.ManifestLoader,
ioStreams genericclioptions.IOStreams) *cobra.Command {
ioStreams genericiooptions.IOStreams) *cobra.Command {
return GetRunner(f, invFactory, loader, ioStreams).Command
}

// Runner encapsulates data necessary to run the destroy command.
type Runner struct {
Command *cobra.Command
ioStreams genericclioptions.IOStreams
ioStreams genericiooptions.IOStreams
factory cmdutil.Factory
invFactory inventory.ClientFactory
loader manifestreader.ManifestLoader
Expand Down
4 changes: 2 additions & 2 deletions cmd/diff/cmddiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/klog/v2"
"k8s.io/kubectl/pkg/cmd/diff"
"k8s.io/kubectl/pkg/cmd/util"
Expand All @@ -20,7 +20,7 @@ const tmpDirPrefix = "diff-cmd"
// NewCommand returns cobra command to implement client-side diff of package
// directory. For each local config file, get the resource in the cluster
// and diff the local config resource against the resource in the cluster.
func NewCommand(f util.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCommand(f util.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
options := diff.NewDiffOptions(ioStreams)
cmd := &cobra.Command{
Use: "diff (DIRECTORY | STDIN)",
Expand Down
6 changes: 3 additions & 3 deletions cmd/initcmd/cmdinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package initcmd

import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"sigs.k8s.io/cli-utils/pkg/config"
Expand All @@ -19,7 +19,7 @@ type InitRunner struct {

// GetInitRunner builds and returns the InitRunner. Connects the InitOptions.Run
// to the cobra command.
func GetInitRunner(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *InitRunner {
func GetInitRunner(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *InitRunner {
io := config.NewInitOptions(f, ioStreams)
cmd := &cobra.Command{
Use: "init DIRECTORY",
Expand All @@ -42,6 +42,6 @@ func GetInitRunner(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *In
}

// NewCmdInit returns the cobra command for the init command.
func NewCmdInit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
func NewCmdInit(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
return GetInitRunner(f, ioStreams).Command
}
11 changes: 6 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (

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

// This is here rather than in the libraries because of
// https://github.com/kubernetes-sigs/kustomize/issues/2060
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"k8s.io/component-base/cli"
"k8s.io/klog/v2"
Expand All @@ -26,10 +31,6 @@ import (
"sigs.k8s.io/cli-utils/pkg/flowcontrol"
"sigs.k8s.io/cli-utils/pkg/inventory"
"sigs.k8s.io/cli-utils/pkg/manifestreader"

// This is here rather than in the libraries because of
// https://github.com/kubernetes-sigs/kustomize/issues/2060
_ "k8s.io/client-go/plugin/pkg/client/auth"
)

func main() {
Expand All @@ -55,7 +56,7 @@ func main() {
// Update ConfigFlags before subcommands run that talk to the server.
preRunE := newConfigFilerPreRunE(f, kubeConfigFlags)

ioStreams := genericclioptions.IOStreams{
ioStreams := genericiooptions.IOStreams{
In: os.Stdin,
Out: os.Stdout,
ErrOut: os.Stderr,
Expand Down
8 changes: 4 additions & 4 deletions cmd/preview/cmdpreview.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"sigs.k8s.io/cli-utils/cmd/flagutils"
Expand All @@ -29,7 +29,7 @@ var (

// GetRunner creates and returns the Runner which stores the cobra command.
func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,
loader manifestreader.ManifestLoader, ioStreams genericclioptions.IOStreams) *Runner {
loader manifestreader.ManifestLoader, ioStreams genericiooptions.IOStreams) *Runner {
r := &Runner{
factory: factory,
invFactory: invFactory,
Expand Down Expand Up @@ -66,7 +66,7 @@ func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,

// Command creates the Runner, returning the cobra command associated with it.
func Command(f cmdutil.Factory, invFactory inventory.ClientFactory, loader manifestreader.ManifestLoader,
ioStreams genericclioptions.IOStreams) *cobra.Command {
ioStreams genericiooptions.IOStreams) *cobra.Command {
return GetRunner(f, invFactory, loader, ioStreams).Command
}

Expand All @@ -76,7 +76,7 @@ type Runner struct {
factory cmdutil.Factory
invFactory inventory.ClientFactory
loader manifestreader.ManifestLoader
ioStreams genericclioptions.IOStreams
ioStreams genericiooptions.IOStreams

serverSideOptions common.ServerSideOptions
output string
Expand Down
4 changes: 2 additions & 2 deletions cmd/status/cmdstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/slice"
"sigs.k8s.io/cli-utils/cmd/flagutils"
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *Runner) runE(cmd *cobra.Command, args []string) error {

// Fetch a printer implementation based on the desired output format as
// specified in the output flag.
printer, err := printers.CreatePrinter(r.output, genericclioptions.IOStreams{
printer, err := printers.CreatePrinter(r.output, genericiooptions.IOStreams{
In: cmd.InOrStdin(),
Out: cmd.OutOrStdout(),
ErrOut: cmd.ErrOrStderr(),
Expand Down
6 changes: 3 additions & 3 deletions cmd/status/printers/event/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
"sigs.k8s.io/cli-utils/pkg/apply/event"
"sigs.k8s.io/cli-utils/pkg/common"
Expand All @@ -22,12 +22,12 @@ import (
// status information as a list of events as they happen.
type Printer struct {
Formatter list.Formatter
IOStreams genericclioptions.IOStreams
IOStreams genericiooptions.IOStreams
Data *printer.PrintData
}

// NewPrinter returns a new instance of the eventPrinter.
func NewPrinter(ioStreams genericclioptions.IOStreams, printData *printer.PrintData) *Printer {
func NewPrinter(ioStreams genericiooptions.IOStreams, printData *printer.PrintData) *Printer {
return &Printer{
Formatter: events.NewFormatter(ioStreams, common.DryRunNone),
IOStreams: ioStreams,
Expand Down
6 changes: 3 additions & 3 deletions cmd/status/printers/json/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
"sigs.k8s.io/cli-utils/pkg/apply/event"
"sigs.k8s.io/cli-utils/pkg/common"
Expand All @@ -24,12 +24,12 @@ import (
// status information as a list of events as they happen.
type Printer struct {
Formatter list.Formatter
IOStreams genericclioptions.IOStreams
IOStreams genericiooptions.IOStreams
Data *printer.PrintData
}

// NewPrinter returns a new instance of the eventPrinter.
func NewPrinter(ioStreams genericclioptions.IOStreams, printData *printer.PrintData) *Printer {
func NewPrinter(ioStreams genericiooptions.IOStreams, printData *printer.PrintData) *Printer {
return &Printer{
Formatter: jsonprinter.NewFormatter(ioStreams, common.DryRunNone),
IOStreams: ioStreams,
Expand Down
4 changes: 2 additions & 2 deletions cmd/status/printers/printers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package printers

import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"sigs.k8s.io/cli-utils/cmd/status/printers/event"
"sigs.k8s.io/cli-utils/cmd/status/printers/json"
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
Expand All @@ -13,7 +13,7 @@ import (

// CreatePrinter return an implementation of the Printer interface. The
// actual implementation is based on the printerType requested.
func CreatePrinter(printerType string, ioStreams genericclioptions.IOStreams, printData *printer.PrintData) (printer.Printer, error) {
func CreatePrinter(printerType string, ioStreams genericiooptions.IOStreams, printData *printer.PrintData) (printer.Printer, error) {
switch printerType {
case "table":
return table.NewPrinter(ioStreams, printData), nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/status/printers/table/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"
"time"

"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
"sigs.k8s.io/cli-utils/pkg/kstatus/polling/collector"
"sigs.k8s.io/cli-utils/pkg/kstatus/polling/event"
Expand All @@ -24,12 +24,12 @@ const (
// Printer is an implementation of the Printer interface that outputs
// status information about resources in a table format with in-place updates.
type Printer struct {
IOStreams genericclioptions.IOStreams
IOStreams genericiooptions.IOStreams
PrintData *printer.PrintData
}

// NewPrinter returns a new instance of the tablePrinter.
func NewPrinter(ioStreams genericclioptions.IOStreams, printData *printer.PrintData) *Printer {
func NewPrinter(ioStreams genericiooptions.IOStreams, printData *printer.PrintData) *Printer {
return &Printer{
IOStreams: ioStreams,
PrintData: printData,
Expand Down
12 changes: 5 additions & 7 deletions pkg/apply/mutator/apply_time_mutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"context"
"testing"

"github.com/stretchr/testify/require"
// Using gopkg.in/yaml.v3 instead of sigs.k8s.io/yaml on purpose.
// yaml.v3 correctly parses ints:
// https://github.com/kubernetes-sigs/yaml/issues/45
"gopkg.in/yaml.v3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -18,13 +23,6 @@ import (
"sigs.k8s.io/cli-utils/pkg/apply/cache"
ktestutil "sigs.k8s.io/cli-utils/pkg/kstatus/polling/testutil"
"sigs.k8s.io/cli-utils/pkg/object"

// Using gopkg.in/yaml.v3 instead of sigs.k8s.io/yaml on purpose.
// yaml.v3 correctly parses ints:
// https://github.com/kubernetes-sigs/yaml/issues/45
"gopkg.in/yaml.v3"

"github.com/stretchr/testify/require"
)

var expectedReason = "object contained annotation: config.kubernetes.io/apply-time-mutation"
Expand Down
4 changes: 2 additions & 2 deletions pkg/apply/task/apply_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic"
"k8s.io/klog/v2"
"k8s.io/kubectl/pkg/cmd/apply"
cmddelete "k8s.io/kubectl/pkg/cmd/delete"

applyerror "sigs.k8s.io/cli-utils/pkg/apply/error"
"sigs.k8s.io/cli-utils/pkg/apply/event"
"sigs.k8s.io/cli-utils/pkg/apply/filter"
Expand Down Expand Up @@ -193,7 +193,7 @@ func newApplyOptions(taskName string, eventChannel chan<- event.Event, serverSid
Overwrite: true, // Normally set in apply.NewApplyOptions
OpenAPIPatch: true, // Normally set in apply.NewApplyOptions
Recorder: genericclioptions.NoopRecorder{},
IOStreams: genericclioptions.IOStreams{
IOStreams: genericiooptions.IOStreams{
Out: io.Discard,
ErrOut: io.Discard, // TODO: Warning for no lastConfigurationAnnotation
// is printed directly to stderr in ApplyOptions. We
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/initoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/google/uuid"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/klog/v2"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"sigs.k8s.io/cli-utils/pkg/common"
Expand All @@ -31,7 +31,7 @@ const (
type InitOptions struct {
factory cmdutil.Factory

ioStreams genericclioptions.IOStreams
ioStreams genericiooptions.IOStreams
// Template string; must be a valid k8s resource.
Template string
// Package directory argument; must be valid directory.
Expand All @@ -42,7 +42,7 @@ type InitOptions struct {
InventoryID string
}

func NewInitOptions(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *InitOptions {
func NewInitOptions(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *InitOptions {
return &InitOptions{
factory: f,
ioStreams: ioStreams,
Expand Down
3 changes: 1 addition & 2 deletions pkg/flowcontrol/flowcontrol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ package flowcontrol

import (
"bytes"
"context"
"io"
"net/http"
"net/http/httptest"
"testing"
"time"

"context"

"github.com/stretchr/testify/assert"
flowcontrolapi "k8s.io/api/flowcontrol/v1beta2"
"k8s.io/client-go/rest"
Expand Down
3 changes: 1 addition & 2 deletions pkg/jsonpath/jsonpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import (
"encoding/json"
"fmt"

"github.com/spyzhov/ajson"
// Using gopkg.in/yaml.v3 instead of sigs.k8s.io/yaml on purpose.
// yaml.v3 correctly parses ints:
// https://github.com/kubernetes-sigs/yaml/issues/45
// yaml.v3 Node is also used as input to yqlib.
"gopkg.in/yaml.v3"
"k8s.io/klog/v2"

"github.com/spyzhov/ajson"
)

// Get evaluates the JSONPath expression to extract values from the input map.
Expand Down
Loading

0 comments on commit ce2a947

Please sign in to comment.