Skip to content

Commit 820a3a5

Browse files
authored
Merge branch 'kubernetes-sigs:master' into rate-deadline
2 parents 0ad87ef + 8c2dae2 commit 820a3a5

File tree

87 files changed

+1499
-784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1499
-784
lines changed

.github/workflows/main.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@ jobs:
1414
steps:
1515
-
1616
name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
2020
-
2121
name: Set up Go
22-
uses: actions/setup-go@v3
22+
uses: actions/setup-go@v5
2323
with:
2424
go-version-file: 'go.mod'
2525
-
2626
name: Run GoReleaser
27-
uses: goreleaser/goreleaser-action@v2
27+
uses: goreleaser/goreleaser-action@v4
2828
with:
2929
version: latest
30-
args: release --rm-dist -f release/goreleaser.yml
30+
args: release --clean -f release/goreleaser.yml
3131
env:
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-

.golangci.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
run:
5-
deadline: 30m
5+
timeout: 30m
66

77
linters:
88
# please, do not use `enable-all`: it's deprecated and will be removed soon.
@@ -14,7 +14,7 @@ linters:
1414
- dogsled
1515
- dupl
1616
- errcheck
17-
- exportloopref
17+
- copyloopvar
1818
- gochecknoinits
1919
- goconst
2020
- gocritic
@@ -46,6 +46,8 @@ linters-settings:
4646
line-length: 170
4747
gocyclo:
4848
min-complexity: 30
49+
copyloopvar:
50+
check-alias: true
4951

5052
issues:
5153
# List of regexps of issue texts to exclude, empty list by default.
@@ -54,4 +56,4 @@ issues:
5456
# excluded by default patterns execute `golangci-lint run --help`
5557
exclude:
5658
- "Using the variable on range scope `tc` in function literal"
57-
- "unused-parameter: parameter"
59+
- "unused-parameter: parameter"

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export PATH := $(MYGOBIN):$(PATH)
1010
all: generate license fix vet fmt test lint tidy
1111

1212
"$(MYGOBIN)/stringer":
13-
go install golang.org/x/tools/cmd/stringer@v0.1.10
13+
go install golang.org/x/tools/cmd/stringer@v0.12.0
1414

1515
"$(MYGOBIN)/addlicense":
1616
go install github.com/google/[email protected]
1717

1818
"$(MYGOBIN)/golangci-lint":
19-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
19+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
2020

2121
"$(MYGOBIN)/deepcopy-gen":
2222
go install k8s.io/code-generator/cmd/[email protected]

cmd/apply/cmdapply.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/spf13/cobra"
13-
"k8s.io/cli-runtime/pkg/genericclioptions"
13+
"k8s.io/cli-runtime/pkg/genericiooptions"
1414
cmdutil "k8s.io/kubectl/pkg/cmd/util"
1515
"k8s.io/kubectl/pkg/util/i18n"
1616
"sigs.k8s.io/cli-utils/cmd/flagutils"
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,
25-
loader manifestreader.ManifestLoader, ioStreams genericclioptions.IOStreams) *Runner {
25+
loader manifestreader.ManifestLoader, ioStreams genericiooptions.IOStreams) *Runner {
2626
r := &Runner{
2727
ioStreams: ioStreams,
2828
factory: factory,
@@ -66,13 +66,13 @@ func GetRunner(factory cmdutil.Factory, invFactory inventory.ClientFactory,
6666
}
6767

6868
func Command(f cmdutil.Factory, invFactory inventory.ClientFactory, loader manifestreader.ManifestLoader,
69-
ioStreams genericclioptions.IOStreams) *cobra.Command {
69+
ioStreams genericiooptions.IOStreams) *cobra.Command {
7070
return GetRunner(f, invFactory, loader, ioStreams).Command
7171
}
7272

7373
type Runner struct {
7474
Command *cobra.Command
75-
ioStreams genericclioptions.IOStreams
75+
ioStreams genericiooptions.IOStreams
7676
factory cmdutil.Factory
7777
invFactory inventory.ClientFactory
7878
loader manifestreader.ManifestLoader

cmd/destroy/cmddestroy.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/spf13/cobra"
13-
"k8s.io/cli-runtime/pkg/genericclioptions"
13+
"k8s.io/cli-runtime/pkg/genericiooptions"
1414
cmdutil "k8s.io/kubectl/pkg/cmd/util"
1515
"k8s.io/kubectl/pkg/util/i18n"
1616
"sigs.k8s.io/cli-utils/cmd/flagutils"
@@ -23,7 +23,7 @@ import (
2323

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

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

6464
// Runner encapsulates data necessary to run the destroy command.
6565
type Runner struct {
6666
Command *cobra.Command
67-
ioStreams genericclioptions.IOStreams
67+
ioStreams genericiooptions.IOStreams
6868
factory cmdutil.Factory
6969
invFactory inventory.ClientFactory
7070
loader manifestreader.ManifestLoader

cmd/diff/cmddiff.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88

99
"github.com/spf13/cobra"
10-
"k8s.io/cli-runtime/pkg/genericclioptions"
10+
"k8s.io/cli-runtime/pkg/genericiooptions"
1111
"k8s.io/klog/v2"
1212
"k8s.io/kubectl/pkg/cmd/diff"
1313
"k8s.io/kubectl/pkg/cmd/util"
@@ -20,7 +20,7 @@ const tmpDirPrefix = "diff-cmd"
2020
// NewCommand returns cobra command to implement client-side diff of package
2121
// directory. For each local config file, get the resource in the cluster
2222
// and diff the local config resource against the resource in the cluster.
23-
func NewCommand(f util.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
23+
func NewCommand(f util.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
2424
options := diff.NewDiffOptions(ioStreams)
2525
cmd := &cobra.Command{
2626
Use: "diff (DIRECTORY | STDIN)",
@@ -73,10 +73,7 @@ func Initialize(o *diff.DiffOptions, f util.Factory, args []string) (func(), err
7373
}
7474
o.FilenameOptions = filenameFlags.ToOptions()
7575

76-
o.OpenAPISchema, err = f.OpenAPISchema()
77-
if err != nil {
78-
return cleanupFunc, err
79-
}
76+
o.OpenAPIGetter = f
8077

8178
o.DynamicClient, err = f.DynamicClient()
8279
if err != nil {

cmd/flagutils/utils.go

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const (
1515
InventoryPolicyStrict = "strict"
1616
InventoryPolicyAdopt = "adopt"
1717
InventoryPolicyForceAdopt = "force-adopt"
18+
StatusPolicyFlag = "status-policy"
19+
StatusPolicyAll = "all"
20+
StatusPolicyNone = "none"
1821
)
1922

2023
// ConvertPropagationPolicy converts a propagationPolicy described as a
@@ -47,6 +50,19 @@ func ConvertInventoryPolicy(policy string) (inventory.Policy, error) {
4750
}
4851
}
4952

53+
// ConvertStatusPolicy converts as status policy described as a string to a
54+
// StatusPolicy type that is passed into the Applier.
55+
func ConvertStatusPolicy(policy string) (inventory.StatusPolicy, error) {
56+
switch policy {
57+
case StatusPolicyNone:
58+
return inventory.StatusPolicyNone, nil
59+
case StatusPolicyAll:
60+
return inventory.StatusPolicyAll, nil
61+
default:
62+
return inventory.StatusPolicyAll, fmt.Errorf("status policy must be one of none, all")
63+
}
64+
}
65+
5066
// PathFromArgs returns the path which is a positional arg from args list
5167
// returns "-" if there is length of args is 0, which implies no path is provided
5268
func PathFromArgs(args []string) string {

cmd/initcmd/cmdinit.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package initcmd
55

66
import (
77
"github.com/spf13/cobra"
8-
"k8s.io/cli-runtime/pkg/genericclioptions"
8+
"k8s.io/cli-runtime/pkg/genericiooptions"
99
cmdutil "k8s.io/kubectl/pkg/cmd/util"
1010
"k8s.io/kubectl/pkg/util/i18n"
1111
"sigs.k8s.io/cli-utils/pkg/config"
@@ -19,7 +19,7 @@ type InitRunner struct {
1919

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

4444
// NewCmdInit returns the cobra command for the init command.
45-
func NewCmdInit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
45+
func NewCmdInit(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cobra.Command {
4646
return GetInitRunner(f, ioStreams).Command
4747
}

cmd/main.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import (
1313

1414
"github.com/spf13/cobra"
1515
"k8s.io/cli-runtime/pkg/genericclioptions"
16+
"k8s.io/cli-runtime/pkg/genericiooptions"
17+
18+
// This is here rather than in the libraries because of
19+
// https://github.com/kubernetes-sigs/kustomize/issues/2060
20+
_ "k8s.io/client-go/plugin/pkg/client/auth"
1621
"k8s.io/client-go/rest"
1722
"k8s.io/component-base/cli"
1823
"k8s.io/klog/v2"
@@ -26,10 +31,6 @@ import (
2631
"sigs.k8s.io/cli-utils/pkg/flowcontrol"
2732
"sigs.k8s.io/cli-utils/pkg/inventory"
2833
"sigs.k8s.io/cli-utils/pkg/manifestreader"
29-
30-
// This is here rather than in the libraries because of
31-
// https://github.com/kubernetes-sigs/kustomize/issues/2060
32-
_ "k8s.io/client-go/plugin/pkg/client/auth"
3334
)
3435

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

58-
ioStreams := genericclioptions.IOStreams{
59+
ioStreams := genericiooptions.IOStreams{
5960
In: os.Stdin,
6061
Out: os.Stdout,
6162
ErrOut: os.Stderr,

cmd/preview/cmdpreview.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/spf13/cobra"
13-
"k8s.io/cli-runtime/pkg/genericclioptions"
13+
"k8s.io/cli-runtime/pkg/genericiooptions"
1414
cmdutil "k8s.io/kubectl/pkg/cmd/util"
1515
"k8s.io/kubectl/pkg/util/i18n"
1616
"sigs.k8s.io/cli-utils/cmd/flagutils"
@@ -29,7 +29,7 @@ var (
2929

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

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

@@ -76,7 +76,7 @@ type Runner struct {
7676
factory cmdutil.Factory
7777
invFactory inventory.ClientFactory
7878
loader manifestreader.ManifestLoader
79-
ioStreams genericclioptions.IOStreams
79+
ioStreams genericiooptions.IOStreams
8080

8181
serverSideOptions common.ServerSideOptions
8282
output string

cmd/status/cmdstatus.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

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

261261
// Fetch a printer implementation based on the desired output format as
262262
// specified in the output flag.
263-
printer, err := printers.CreatePrinter(r.output, genericclioptions.IOStreams{
263+
printer, err := printers.CreatePrinter(r.output, genericiooptions.IOStreams{
264264
In: cmd.InOrStdin(),
265265
Out: cmd.OutOrStdout(),
266266
ErrOut: cmd.ErrOrStderr(),

cmd/status/printers/event/printer.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"fmt"
88
"strings"
99

10-
"k8s.io/cli-runtime/pkg/genericclioptions"
10+
"k8s.io/cli-runtime/pkg/genericiooptions"
1111
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
1212
"sigs.k8s.io/cli-utils/pkg/apply/event"
1313
"sigs.k8s.io/cli-utils/pkg/common"
@@ -22,12 +22,12 @@ import (
2222
// status information as a list of events as they happen.
2323
type Printer struct {
2424
Formatter list.Formatter
25-
IOStreams genericclioptions.IOStreams
25+
IOStreams genericiooptions.IOStreams
2626
Data *printer.PrintData
2727
}
2828

2929
// NewPrinter returns a new instance of the eventPrinter.
30-
func NewPrinter(ioStreams genericclioptions.IOStreams, printData *printer.PrintData) *Printer {
30+
func NewPrinter(ioStreams genericiooptions.IOStreams, printData *printer.PrintData) *Printer {
3131
return &Printer{
3232
Formatter: events.NewFormatter(ioStreams, common.DryRunNone),
3333
IOStreams: ioStreams,

cmd/status/printers/json/printer.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"k8s.io/cli-runtime/pkg/genericclioptions"
12+
"k8s.io/cli-runtime/pkg/genericiooptions"
1313
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
1414
"sigs.k8s.io/cli-utils/pkg/apply/event"
1515
"sigs.k8s.io/cli-utils/pkg/common"
@@ -24,12 +24,12 @@ import (
2424
// status information as a list of events as they happen.
2525
type Printer struct {
2626
Formatter list.Formatter
27-
IOStreams genericclioptions.IOStreams
27+
IOStreams genericiooptions.IOStreams
2828
Data *printer.PrintData
2929
}
3030

3131
// NewPrinter returns a new instance of the eventPrinter.
32-
func NewPrinter(ioStreams genericclioptions.IOStreams, printData *printer.PrintData) *Printer {
32+
func NewPrinter(ioStreams genericiooptions.IOStreams, printData *printer.PrintData) *Printer {
3333
return &Printer{
3434
Formatter: jsonprinter.NewFormatter(ioStreams, common.DryRunNone),
3535
IOStreams: ioStreams,

cmd/status/printers/printers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package printers
55

66
import (
7-
"k8s.io/cli-runtime/pkg/genericclioptions"
7+
"k8s.io/cli-runtime/pkg/genericiooptions"
88
"sigs.k8s.io/cli-utils/cmd/status/printers/event"
99
"sigs.k8s.io/cli-utils/cmd/status/printers/json"
1010
"sigs.k8s.io/cli-utils/cmd/status/printers/printer"
@@ -13,7 +13,7 @@ import (
1313

1414
// CreatePrinter return an implementation of the Printer interface. The
1515
// actual implementation is based on the printerType requested.
16-
func CreatePrinter(printerType string, ioStreams genericclioptions.IOStreams, printData *printer.PrintData) (printer.Printer, error) {
16+
func CreatePrinter(printerType string, ioStreams genericiooptions.IOStreams, printData *printer.PrintData) (printer.Printer, error) {
1717
switch printerType {
1818
case "table":
1919
return table.NewPrinter(ioStreams, printData), nil

0 commit comments

Comments
 (0)