Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert use of upstream yaml parsing #455

Merged
merged 1 commit into from May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 5 additions & 15 deletions pkg/mapper/configmap/configmap.go
Expand Up @@ -2,19 +2,19 @@ package configmap

import (
"context"
"encoding/json"
"errors"
"sync"

"fmt"

"strings"
"sync"
"time"

"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
core_v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
Expand Down Expand Up @@ -115,27 +115,17 @@ func ParseMap(m map[string]string) (userMappings []config.UserMapping, roleMappi
errs := make([]error, 0)
userMappings = make([]config.UserMapping, 0)
if userData, ok := m["mapUsers"]; ok {
userJson, err := utilyaml.ToJSON([]byte(userData))
err := yaml.Unmarshal([]byte(userData), &userMappings)
if err != nil {
errs = append(errs, err)
} else {
err = json.Unmarshal(userJson, &userMappings)
if err != nil {
errs = append(errs, err)
}
}
}

roleMappings = make([]config.RoleMapping, 0)
if roleData, ok := m["mapRoles"]; ok {
roleJson, err := utilyaml.ToJSON([]byte(roleData))
err := yaml.Unmarshal([]byte(roleData), &roleMappings)
if err != nil {
errs = append(errs, err)
} else {
err = json.Unmarshal(roleJson, &roleMappings)
if err != nil {
errs = append(errs, err)
}
}
}

Expand Down
19 changes: 0 additions & 19 deletions pkg/mapper/configmap/yaml/aws-auth-crazy-case-keys.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions pkg/mapper/configmap/yaml/aws-auth-open-source-case-keys.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/mapper/configmap/yaml_test.go
Expand Up @@ -56,16 +56,6 @@ func TestConfigMap(t *testing.T) {
// Valid aws-auth.yaml based on one in EKS documentation.
"aws-auth.yaml", validRoleMappings, validUserMappings, validAWSAccounts, false,
},
{
// RoLeArN instead of rolearn
// parsing succeeds, values are case-insensitive for compatibility with upstream
"aws-auth-crazy-case-keys.yaml", validRoleMappings, validUserMappings, validAWSAccounts, false,
},
{
// roleARN instead of rolearn
// parsing succeeds, values are case-insensitive for compatibility with upstream
"aws-auth-open-source-case-keys.yaml", validRoleMappings, validUserMappings, validAWSAccounts, false,
},
// Fail cases -- ideally, validation should reject these before they reach us
{
// mapusers instead of mapUsers
Expand Down