Skip to content

Commit 596a043

Browse files
revert use of upstream yaml parsing
1 parent 2a9ee95 commit 596a043

File tree

4 files changed

+5
-63
lines changed

4 files changed

+5
-63
lines changed

pkg/mapper/configmap/configmap.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ package configmap
22

33
import (
44
"context"
5-
"encoding/json"
65
"errors"
6+
"sync"
7+
78
"fmt"
9+
810
"strings"
9-
"sync"
1011
"time"
1112

1213
"github.com/sirupsen/logrus"
1314
"gopkg.in/yaml.v2"
1415
core_v1 "k8s.io/api/core/v1"
1516
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1617
"k8s.io/apimachinery/pkg/fields"
17-
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
1818
"k8s.io/apimachinery/pkg/watch"
1919
"k8s.io/client-go/kubernetes"
2020
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
@@ -115,27 +115,17 @@ func ParseMap(m map[string]string) (userMappings []config.UserMapping, roleMappi
115115
errs := make([]error, 0)
116116
userMappings = make([]config.UserMapping, 0)
117117
if userData, ok := m["mapUsers"]; ok {
118-
userJson, err := utilyaml.ToJSON([]byte(userData))
118+
err := yaml.Unmarshal([]byte(userData), &userMappings)
119119
if err != nil {
120120
errs = append(errs, err)
121-
} else {
122-
err = json.Unmarshal(userJson, &userMappings)
123-
if err != nil {
124-
errs = append(errs, err)
125-
}
126121
}
127122
}
128123

129124
roleMappings = make([]config.RoleMapping, 0)
130125
if roleData, ok := m["mapRoles"]; ok {
131-
roleJson, err := utilyaml.ToJSON([]byte(roleData))
126+
err := yaml.Unmarshal([]byte(roleData), &roleMappings)
132127
if err != nil {
133128
errs = append(errs, err)
134-
} else {
135-
err = json.Unmarshal(roleJson, &roleMappings)
136-
if err != nil {
137-
errs = append(errs, err)
138-
}
139129
}
140130
}
141131

pkg/mapper/configmap/yaml/aws-auth-crazy-case-keys.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

pkg/mapper/configmap/yaml/aws-auth-open-source-case-keys.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

pkg/mapper/configmap/yaml_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ func TestConfigMap(t *testing.T) {
5656
// Valid aws-auth.yaml based on one in EKS documentation.
5757
"aws-auth.yaml", validRoleMappings, validUserMappings, validAWSAccounts, false,
5858
},
59-
{
60-
// RoLeArN instead of rolearn
61-
// parsing succeeds, values are case-insensitive for compatibility with upstream
62-
"aws-auth-crazy-case-keys.yaml", validRoleMappings, validUserMappings, validAWSAccounts, false,
63-
},
64-
{
65-
// roleARN instead of rolearn
66-
// parsing succeeds, values are case-insensitive for compatibility with upstream
67-
"aws-auth-open-source-case-keys.yaml", validRoleMappings, validUserMappings, validAWSAccounts, false,
68-
},
6959
// Fail cases -- ideally, validation should reject these before they reach us
7060
{
7161
// mapusers instead of mapUsers

0 commit comments

Comments
 (0)