-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add self modifier support (#856)
* feat: add self modifier support Signed-off-by: Charles-Edouard Brétéché <[email protected]> * bump kyverno-json Signed-off-by: Charles-Edouard Brétéché <[email protected]> * fix tests Signed-off-by: Charles-Edouard Brétéché <[email protected]> --------- Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
ed3ee28
commit 55c2f65
Showing
9 changed files
with
59 additions
and
40 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
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 |
---|---|---|
@@ -1,17 +1,35 @@ | ||
package mutate | ||
|
||
func convert(in any) map[string]any { | ||
func convertSlice(in any) []any { | ||
data, ok := in.([]any) | ||
if !ok { | ||
return nil | ||
} | ||
out := []any{} | ||
for _, v := range data { | ||
out = append(out, convert(v)) | ||
} | ||
return out | ||
} | ||
|
||
func convertMap(in any) map[string]any { | ||
data, ok := in.(map[any]any) | ||
if !ok { | ||
return nil | ||
} | ||
out := map[string]any{} | ||
for k, v := range data { | ||
if c := convert(v); c != nil { | ||
out[k.(string)] = c | ||
} else { | ||
out[k.(string)] = v | ||
} | ||
out[k.(string)] = convert(v) | ||
} | ||
return out | ||
} | ||
|
||
func convert(in any) any { | ||
if result := convertSlice(in); result != nil { | ||
return result | ||
} | ||
if result := convertMap(in); result != nil { | ||
return result | ||
} | ||
return in | ||
} |
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
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
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