-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from mnkg561/bug_trust_role
Bug trust role
- Loading branch information
Showing
22 changed files
with
837 additions
and
75 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,41 @@ | ||
package v1alpha1 | ||
|
||
import "encoding/json" | ||
|
||
//StringOrStrings type accepts one string or multiple strings | ||
// +kubebuilder:object:generate=false | ||
type StringOrStrings []string | ||
|
||
//MarshalJSON function is a custom implementation of json.Marshal for StringOrStrings | ||
func (s StringOrStrings) MarshalJSON() ([]byte, error) { | ||
if len(s) == 1 { | ||
return json.Marshal(s[0]) | ||
} | ||
//I need to convert it to string array | ||
// if i use json.Marshal(s) here it is going to go into infinite loop | ||
// since json.Marshal for type StringOrStrings are overwritten in this very own method | ||
var k []string | ||
for _, str := range s { | ||
k = append(k, str) | ||
} | ||
return json.Marshal(k) | ||
} | ||
|
||
//UnmarshalJson function is a custom implementation of json to unmarshal StringOrStrings | ||
func (s *StringOrStrings) UnmarshalJSON(b []byte) error { | ||
//Try to convert to array | ||
var strings []string | ||
if err := json.Unmarshal(b, &strings); err != nil { | ||
//If err, convert it to string and add it to array | ||
var str string | ||
err = json.Unmarshal(b, &str) | ||
if err != nil { | ||
return err | ||
} | ||
strings = []string{str} | ||
|
||
} | ||
|
||
*s = strings | ||
return nil | ||
} |
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
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
Oops, something went wrong.