Skip to content

Commit 4ceeccb

Browse files
authored
Support kyaml output (#242)
* Support kyaml output * Bump golangci-lint and fix configs * Add the supported printers directly to the flag
1 parent ef08fb8 commit 4ceeccb

File tree

8 files changed

+180
-160
lines changed

8 files changed

+180
-160
lines changed

.golangci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ run:
22
timeout: 10m
33
issues-exit-code: 1
44
tests: true
5-
skip-dirs-use-default: true
5+
exclude-dirs-use-default: true
66
modules-download-mode: readonly
77
allow-parallel-runners: false
88

@@ -14,7 +14,6 @@ linters:
1414
- revive
1515
- govet
1616
- misspell
17-
- exportloopref
1817
disable-all: false
1918
presets:
2019
- bugs
@@ -32,6 +31,10 @@ linters-settings:
3231
shadow: true
3332
misspell:
3433
locale: US
34+
# (rkatz) - Added as we have a couple of APIs conversion (eg Istio, Kong) that convert uint->int and there's no solution
35+
gosec:
36+
excludes:
37+
- G115
3538

3639
issues:
3740
exclude-rules:

cmd/print.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/spf13/cobra"
2828
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2929
"k8s.io/apimachinery/pkg/runtime/serializer/json"
30-
"k8s.io/cli-runtime/pkg/genericclioptions"
3130
"k8s.io/cli-runtime/pkg/printers"
3231
"k8s.io/client-go/tools/clientcmd"
3332

@@ -264,6 +263,9 @@ func (pr *PrintRunner) initializeResourcePrinter() error {
264263
case "yaml", "":
265264
pr.resourcePrinter = &printers.YAMLPrinter{}
266265
return nil
266+
case "kyaml":
267+
pr.resourcePrinter = &printers.KYAMLPrinter{}
268+
return nil
267269
case "json":
268270
pr.resourcePrinter = &printers.JSONPrinter{}
269271
return nil
@@ -305,8 +307,6 @@ func (pr *PrintRunner) initializeNamespaceFilter() error {
305307

306308
func newPrintCommand() *cobra.Command {
307309
pr := &PrintRunner{}
308-
var printFlags genericclioptions.JSONYamlPrintFlags
309-
allowedFormats := printFlags.AllowedFormats()
310310

311311
// printCmd represents the print command. It prints Gateway API resources
312312
// generated from Ingress resources.
@@ -324,7 +324,7 @@ func newPrintCommand() *cobra.Command {
324324
}
325325

326326
cmd.Flags().StringVarP(&pr.outputFormat, "output", "o", "yaml",
327-
fmt.Sprintf(`Output format. One of: (%s).`, strings.Join(allowedFormats, ", ")))
327+
"Output format. One of: (yaml, json, kyaml).")
328328

329329
cmd.Flags().StringVar(&pr.inputFile, "input-file", "",
330330
`Path to the manifest file. When set, the tool will read ingresses from the file instead of reading from the cluster. Supported files are yaml and json.`)

cmd/print_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ func Test_getResourcePrinter(t *testing.T) {
4747
expectedPrinter: &printers.YAMLPrinter{},
4848
expectingError: false,
4949
},
50+
{
51+
name: "KYAML format",
52+
outputFormat: "kyaml",
53+
expectedPrinter: &printers.KYAMLPrinter{},
54+
expectingError: false,
55+
},
5056
{
5157
name: "Default to YAML format",
5258
outputFormat: "",

go.mod

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
11
module github.com/kubernetes-sigs/ingress2gateway
22

3-
go 1.22.0
3+
go 1.24.0
4+
5+
toolchain go1.24.6
46

57
require (
68
github.com/GoogleCloudPlatform/gke-gateway-api v1.3.0
79
github.com/getkin/kin-openapi v0.124.0
8-
github.com/google/go-cmp v0.6.0
10+
github.com/google/go-cmp v0.7.0
911
github.com/kong/kubernetes-ingress-controller/v2 v2.12.3
1012
github.com/olekukonko/tablewriter v0.0.5
1113
github.com/samber/lo v1.39.0
12-
github.com/spf13/cobra v1.8.0
13-
github.com/stretchr/testify v1.9.0
14+
github.com/spf13/cobra v1.9.1
15+
github.com/stretchr/testify v1.10.0
1416
istio.io/api v1.20.0
15-
k8s.io/api v0.30.1
16-
k8s.io/apimachinery v0.30.1
17-
k8s.io/cli-runtime v0.29.0
18-
k8s.io/client-go v0.30.0
17+
k8s.io/api v0.34.0
18+
k8s.io/apimachinery v0.34.0
19+
k8s.io/cli-runtime v0.34.0
20+
k8s.io/client-go v0.34.0
1921
k8s.io/ingress-gce v1.30.0
20-
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
21-
sigs.k8s.io/controller-runtime v0.18.0
22+
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
23+
sigs.k8s.io/controller-runtime v0.22.0
2224
sigs.k8s.io/gateway-api v1.1.0
2325
)
2426

2527
require (
26-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
28+
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
29+
github.com/blang/semver/v4 v4.0.0 // indirect
30+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
2731
github.com/invopop/yaml v0.2.0 // indirect
2832
github.com/mattn/go-runewidth v0.0.15 // indirect
29-
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
33+
github.com/moby/term v0.5.0 // indirect
3034
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
31-
github.com/onsi/gomega v1.33.0 // indirect
3235
github.com/perimeterx/marshmallow v1.1.5 // indirect
3336
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3437
github.com/rivo/uniseg v0.2.0 // indirect
35-
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
38+
github.com/x448/float16 v0.8.4 // indirect
39+
go.yaml.in/yaml/v2 v2.4.2 // indirect
40+
go.yaml.in/yaml/v3 v3.0.4 // indirect
41+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
42+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
43+
sigs.k8s.io/randfill v1.0.0 // indirect
44+
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
3645
)
3746

3847
require (
3948
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
40-
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
41-
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
42-
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
49+
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
50+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
4351
github.com/go-errors/errors v1.5.1 // indirect
44-
github.com/go-logr/logr v1.4.1 // indirect
52+
github.com/go-logr/logr v1.4.2 // indirect
4553
github.com/go-openapi/jsonpointer v0.21.0 // indirect
4654
github.com/go-openapi/jsonreference v0.21.0 // indirect
4755
github.com/go-openapi/swag v0.23.0 // indirect
4856
github.com/gogo/protobuf v1.3.2 // indirect
4957
github.com/golang/protobuf v1.5.4 // indirect
50-
github.com/google/btree v1.1.2 // indirect
51-
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
52-
github.com/google/gofuzz v1.2.0 // indirect
53-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
58+
github.com/google/btree v1.1.3 // indirect
59+
github.com/google/gnostic-models v0.7.0 // indirect
5460
github.com/google/uuid v1.6.0 // indirect
5561
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
56-
github.com/imdario/mergo v0.3.16 // indirect
5762
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5863
github.com/josharian/intern v1.0.0 // indirect
5964
github.com/json-iterator/go v1.1.12 // indirect
6065
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
6166
github.com/mailru/easyjson v0.7.7 // indirect
6267
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
63-
github.com/modern-go/reflect2 v1.0.2 // indirect
68+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
6469
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
6570
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6671
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
6772
github.com/pkg/errors v0.9.1 // indirect
68-
github.com/spf13/pflag v1.0.5 // indirect
73+
github.com/spf13/pflag v1.0.6 // indirect
6974
github.com/xlab/treeprint v1.2.0 // indirect
70-
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect
71-
golang.org/x/net v0.25.0 // indirect
72-
golang.org/x/oauth2 v0.19.0 // indirect
73-
golang.org/x/sync v0.7.0 // indirect
74-
golang.org/x/sys v0.20.0 // indirect
75-
golang.org/x/term v0.20.0 // indirect
76-
golang.org/x/text v0.15.0 // indirect
77-
golang.org/x/time v0.5.0 // indirect
78-
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
79-
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
80-
google.golang.org/protobuf v1.33.0
81-
gopkg.in/evanphx/json-patch.v5 v5.7.0 // indirect
75+
golang.org/x/net v0.38.0 // indirect
76+
golang.org/x/oauth2 v0.27.0 // indirect
77+
golang.org/x/sync v0.12.0 // indirect
78+
golang.org/x/sys v0.31.0 // indirect
79+
golang.org/x/term v0.30.0 // indirect
80+
golang.org/x/text v0.23.0 // indirect
81+
golang.org/x/time v0.9.0 // indirect
82+
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
83+
google.golang.org/protobuf v1.36.5
8284
gopkg.in/inf.v0 v0.9.1 // indirect
83-
gopkg.in/yaml.v2 v2.4.0 // indirect
8485
gopkg.in/yaml.v3 v3.0.1 // indirect
8586
istio.io/client-go v1.19.0-alpha.1.0.20231130185426-9f1859c8ff42
86-
k8s.io/klog/v2 v2.120.1
87-
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 // indirect
88-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
89-
sigs.k8s.io/kustomize/api v0.15.0 // indirect
90-
sigs.k8s.io/kustomize/kyaml v0.15.0 // indirect
91-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
92-
sigs.k8s.io/yaml v1.4.0 // indirect
87+
k8s.io/klog/v2 v2.130.1
88+
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
89+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
90+
sigs.k8s.io/kustomize/api v0.20.1 // indirect
91+
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
92+
sigs.k8s.io/yaml v1.6.0 // indirect
9393
)

0 commit comments

Comments
 (0)