-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-4.7] Bug 2024614: Anonymize identity provider attributes in …
…the (#520) (#527) (#541) (#549) * Anonymize identity provider attributes in the authentication.operator.openshift.io definition * More robust way....
- Loading branch information
Showing
3 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package anonymize | ||
|
||
import "strings" | ||
|
||
func String(s string) string { | ||
return strings.Repeat("x", len(s)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
) | ||
|
||
func NestedStringWrapper(obj map[string]interface{}, fields ...string) (string, error) { | ||
s, ok, err := unstructured.NestedString(obj, fields...) | ||
if !ok { | ||
return "", fmt.Errorf("can't find %s", formatSlice(fields...)) | ||
} | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return s, nil | ||
} | ||
|
||
func NestedSliceWrapper(obj map[string]interface{}, fields ...string) ([]interface{}, error) { | ||
s, ok, err := unstructured.NestedSlice(obj, fields...) | ||
if !ok { | ||
return nil, fmt.Errorf("can't find %s", formatSlice(fields...)) | ||
} | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return s, nil | ||
} | ||
|
||
func NestedInt64Wrapper(obj map[string]interface{}, fields ...string) (int64, error) { | ||
i, ok, err := unstructured.NestedInt64(obj, fields...) | ||
if !ok { | ||
return 0, fmt.Errorf("can't find %s", formatSlice(fields...)) | ||
} | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
return i, nil | ||
} | ||
|
||
func formatSlice(s ...string) string { | ||
var str string | ||
for _, f := range s { | ||
str += fmt.Sprintf("%s.", f) | ||
} | ||
str = strings.TrimRight(str, ".") | ||
return str | ||
} |