Skip to content

Commit 9de524d

Browse files
authored
Merge pull request #773 from monopole/kvpairToPair
Rename kv.KVPair to kv.Pair
2 parents d720e9e + 7c8db24 commit 9de524d

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

k8sdeps/configmapandsecret/configmapfactory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (f *ConfigMapFactory) makeFreshConfigMap(
5555
// MakeConfigMap returns a new ConfigMap, or nil and an error.
5656
func (f *ConfigMapFactory) MakeConfigMap(
5757
args *types.ConfigMapArgs, options *types.GeneratorOptions) (*corev1.ConfigMap, error) {
58-
var all []kv.KVPair
58+
var all []kv.Pair
5959
var err error
6060
cm := f.makeFreshConfigMap(args)
6161

k8sdeps/configmapandsecret/kv.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ import (
2626
"sigs.k8s.io/kustomize/pkg/ifc"
2727
)
2828

29-
func keyValuesFromLiteralSources(sources []string) ([]kv.KVPair, error) {
30-
var kvs []kv.KVPair
29+
func keyValuesFromLiteralSources(sources []string) ([]kv.Pair, error) {
30+
var kvs []kv.Pair
3131
for _, s := range sources {
3232
k, v, err := parseLiteralSource(s)
3333
if err != nil {
3434
return nil, err
3535
}
36-
kvs = append(kvs, kv.KVPair{Key: k, Value: v})
36+
kvs = append(kvs, kv.Pair{Key: k, Value: v})
3737
}
3838
return kvs, nil
3939
}
4040

41-
func keyValuesFromFileSources(ldr ifc.Loader, sources []string) ([]kv.KVPair, error) {
42-
var kvs []kv.KVPair
41+
func keyValuesFromFileSources(ldr ifc.Loader, sources []string) ([]kv.Pair, error) {
42+
var kvs []kv.Pair
4343
for _, s := range sources {
4444
k, fPath, err := parseFileSource(s)
4545
if err != nil {
@@ -49,12 +49,12 @@ func keyValuesFromFileSources(ldr ifc.Loader, sources []string) ([]kv.KVPair, er
4949
if err != nil {
5050
return nil, err
5151
}
52-
kvs = append(kvs, kv.KVPair{Key: k, Value: string(content)})
52+
kvs = append(kvs, kv.Pair{Key: k, Value: string(content)})
5353
}
5454
return kvs, nil
5555
}
5656

57-
func keyValuesFromEnvFile(l ifc.Loader, path string) ([]kv.KVPair, error) {
57+
func keyValuesFromEnvFile(l ifc.Loader, path string) ([]kv.Pair, error) {
5858
if path == "" {
5959
return nil, nil
6060
}

k8sdeps/configmapandsecret/kv_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func TestKeyValuesFromFileSources(t *testing.T) {
2929
tests := []struct {
3030
description string
3131
sources []string
32-
expected []kv.KVPair
32+
expected []kv.Pair
3333
}{
3434
{
3535
description: "create kvs from file sources",
3636
sources: []string{"files/app-init.ini"},
37-
expected: []kv.KVPair{
37+
expected: []kv.Pair{
3838
{
3939
Key: "app-init.ini",
4040
Value: "FOO=bar",

k8sdeps/configmapandsecret/secretfactory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (f *SecretFactory) makeFreshSecret(args *types.SecretArgs) *corev1.Secret {
5454

5555
// MakeSecret returns a new secret.
5656
func (f *SecretFactory) MakeSecret(args *types.SecretArgs, options *types.GeneratorOptions) (*corev1.Secret, error) {
57-
var all []kv.KVPair
57+
var all []kv.Pair
5858
var err error
5959
s := f.makeFreshSecret(args)
6060

k8sdeps/kv/kv.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ import (
2828
"k8s.io/apimachinery/pkg/util/validation"
2929
)
3030

31-
type KVPair struct {
31+
type Pair struct {
3232
Key string
3333
Value string
3434
}
3535

3636
var utf8bom = []byte{0xEF, 0xBB, 0xBF}
3737

3838
// KeyValuesFromLines parses given content in to a list of key-value pairs.
39-
func KeyValuesFromLines(content []byte) ([]KVPair, error) {
40-
var kvs []KVPair
39+
func KeyValuesFromLines(content []byte) ([]Pair, error) {
40+
var kvs []Pair
4141

4242
scanner := bufio.NewScanner(bytes.NewReader(content))
4343
currentLine := 0
@@ -63,8 +63,8 @@ func KeyValuesFromLines(content []byte) ([]KVPair, error) {
6363

6464
// KeyValuesFromLine returns a kv with blank key if the line is empty or a comment.
6565
// The value will be retrieved from the environment if necessary.
66-
func KeyValuesFromLine(line []byte, currentLine int) (KVPair, error) {
67-
kv := KVPair{}
66+
func KeyValuesFromLine(line []byte, currentLine int) (Pair, error) {
67+
kv := Pair{}
6868

6969
if !utf8.Valid(line) {
7070
return kv, fmt.Errorf("line %d has invalid utf8 bytes : %v", line, string(line))

k8sdeps/kv/kv_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestKeyValuesFromLines(t *testing.T) {
2525
tests := []struct {
2626
desc string
2727
content string
28-
expectedPairs []KVPair
28+
expectedPairs []Pair
2929
expectedErr bool
3030
}{
3131
{
@@ -34,7 +34,7 @@ func TestKeyValuesFromLines(t *testing.T) {
3434
k1=v1
3535
k2=v2
3636
`,
37-
expectedPairs: []KVPair{
37+
expectedPairs: []Pair{
3838
{Key: "k1", Value: "v1"},
3939
{Key: "k2", Value: "v2"},
4040
},
@@ -46,7 +46,7 @@ func TestKeyValuesFromLines(t *testing.T) {
4646
k1=v1
4747
#k2=v2
4848
`,
49-
expectedPairs: []KVPair{
49+
expectedPairs: []Pair{
5050
{Key: "k1", Value: "v1"},
5151
},
5252
expectedErr: false,

0 commit comments

Comments
 (0)