Skip to content

Commit 32434ae

Browse files
committed
update copyright year and improve error handling in cmdcat
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
1 parent 11acf57 commit 32434ae

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

commands/pkg/pkgcmd.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2026 The kpt Authors
1+
// Copyright 2019,2026 The kpt Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -46,9 +46,12 @@ func GetCommand(ctx context.Context, name string) *cobra.Command {
4646
}
4747

4848
pkg.AddCommand(
49-
get.NewCommand(ctx, name), initialization.NewCommand(ctx, name),
50-
update.NewCommand(ctx, name), diff.NewCommand(ctx, name),
51-
cmdtree.NewCommand(ctx, name), cmdcat.NewCommand(ctx, name),
49+
get.NewCommand(ctx, name),
50+
initialization.NewCommand(ctx, name),
51+
update.NewCommand(ctx, name),
52+
diff.NewCommand(ctx, name),
53+
cmdtree.NewCommand(ctx, name),
54+
cmdcat.NewCommand(ctx, name),
5255
)
5356
return pkg
5457
}

thirdparty/cmdconfig/commands/cmdcat/cmdcat.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2026 The kpt Authors.
1+
// Copyright 2019,2026 The Kubernetes Authors.
22
// SPDX-License-Identifier: Apache-2.0
33

44
package cmdcat
@@ -110,7 +110,7 @@ func (r *CatRunner) ExecuteCmd(w io.Writer, pkgPath string) error {
110110
err := kio.Pipeline{
111111
Inputs: []kio.Reader{input},
112112
Filters: r.catFilters(),
113-
Outputs: r.out(out),
113+
Outputs: r.outputWriter(out),
114114
}.Execute()
115115

116116
if err != nil {
@@ -138,7 +138,7 @@ func (r *CatRunner) catFilters() []kio.Filter {
138138
return fltrs
139139
}
140140

141-
func (r *CatRunner) out(w io.Writer) []kio.Writer {
141+
func (r *CatRunner) outputWriter(w io.Writer) []kio.Writer {
142142
var outputs []kio.Writer
143143
var functionConfig *yaml.RNode
144144

thirdparty/cmdconfig/commands/cmdcat/cmdcat_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2026 The kpt Authors.
1+
// Copyright 2019,2026 The Kubernetes Authors.
22
// SPDX-License-Identifier: Apache-2.0
33

44
package cmdcat
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/kptdev/kpt/pkg/printer"
1616
"github.com/stretchr/testify/assert"
17+
"github.com/stretchr/testify/require"
1718
)
1819

1920
const f1Yaml = "f1.yaml"
@@ -88,7 +89,7 @@ spec:
8889
`)
8990

9091
got, err := runCat(t, d)
91-
assert.NoError(t, err)
92+
require.NoError(t, err)
9293
assert.Equal(t, `kind: Deployment
9394
metadata:
9495
labels:
@@ -149,7 +150,7 @@ spec:
149150
`)
150151

151152
got, err := runCat(t, filepath.Join(d, f1Yaml))
152-
assert.NoError(t, err)
153+
require.NoError(t, err)
153154
assert.Equal(t, `kind: Deployment
154155
metadata:
155156
labels:
@@ -179,7 +180,7 @@ spec:
179180
`)
180181

181182
got, err := runCat(t, filepath.Join(d, f1Yaml), "--annotate")
182-
assert.NoError(t, err)
183+
require.NoError(t, err)
183184
assert.Equal(t, `kind: Deployment
184185
metadata:
185186
labels:
@@ -208,7 +209,7 @@ metadata:
208209
`)
209210

210211
got, err := runCat(t, filepath.Join(d, f1Yaml))
211-
assert.NoError(t, err)
212+
require.NoError(t, err)
212213
assert.NotContains(t, got, "config.kubernetes.io/path",
213214
"config.kubernetes.io/path should be cleared by default")
214215
assert.NotContains(t, got, "internal.config.kubernetes.io/path",
@@ -246,7 +247,7 @@ spec:
246247
`)
247248

248249
got, err := runCat(t, d)
249-
assert.NoError(t, err)
250+
require.NoError(t, err)
250251
assert.Equal(t, `kind: Deployment
251252
metadata:
252253
labels:
@@ -299,7 +300,7 @@ metadata:
299300
`)
300301

301302
got, err := runCat(t, d)
302-
assert.NoError(t, err)
303+
require.NoError(t, err)
303304
// exactly one of each resource, separated by a single ---.
304305
assert.Equal(t, 2, strings.Count(got, "\nkind: ConfigMap\n"),
305306
"each pkg should be emitted exactly once")
@@ -340,7 +341,7 @@ metadata:
340341
}()
341342

342343
got, err := runCat(t, arg)
343-
assert.NoError(t, err)
344+
require.NoError(t, err)
344345
assert.Equal(t, 1, strings.Count(got, "\nkind: ConfigMap\n"),
345346
"arg %q should yield exactly one resource", arg)
346347
})
@@ -371,7 +372,7 @@ metadata:
371372
`)
372373

373374
got, err := runCat(t, d)
374-
assert.NoError(t, err)
375+
require.NoError(t, err)
375376
assert.False(t, strings.HasSuffix(got, "---\n") || strings.HasSuffix(got, "---"),
376377
"output must not end with a stray separator; got %q", got)
377378
assert.Equal(t, 0, strings.Count(got, "\n---\n"),
@@ -477,7 +478,7 @@ metadata:
477478
`)
478479

479480
got, err := runCat(t, d, "-R=false")
480-
assert.NoError(t, err)
481+
require.NoError(t, err)
481482
assert.Contains(t, got, "name: root-cm")
482483
assert.NotContains(t, got, "name: sub-cm",
483484
"sub-pkg should not be traversed when -R=false")
@@ -494,7 +495,7 @@ metadata:
494495
`)
495496

496497
got, err := runCat(t, filepath.Join(d, "f.yaml"), "--strip-comments")
497-
assert.NoError(t, err)
498+
require.NoError(t, err)
498499
assert.NotContains(t, got, "top comment")
499500
assert.NotContains(t, got, "inline comment")
500501
}
@@ -513,7 +514,7 @@ data:
513514
`)
514515

515516
got, err := runCat(t, filepath.Join(d, "f.yaml"), "--format=false")
516-
assert.NoError(t, err)
517+
require.NoError(t, err)
517518
zIdx := strings.Index(got, "z-last")
518519
aIdx := strings.Index(got, "a-first")
519520
assert.True(t, zIdx >= 0 && aIdx >= 0, "both keys should be present")

0 commit comments

Comments
 (0)