Update IAM Policy Principal.Service to stringorset

This commit is contained in:
Peter Rifel 2024-02-13 18:16:16 -06:00
parent 8f71e68d68
commit 3f74f21b7e
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -278,12 +278,12 @@ func (s *Statement) MarshalJSON() ([]byte, error) {
} }
type Principal struct { type Principal struct {
Federated string `json:",omitempty"` Federated string `json:",omitempty"`
Service string `json:",omitempty"` Service *stringorset.StringOrSet `json:",omitempty"`
} }
func (p *Principal) IsEmpty() bool { func (p *Principal) IsEmpty() bool {
return *p == Principal{} return p.Federated == "" && (p.Service == nil || p.Service.IsEmpty())
} }
// Equal compares two IAM Statements and returns a bool // Equal compares two IAM Statements and returns a bool

View File

@ -64,7 +64,7 @@ func TestRoundTrip(t *testing.T) {
{ {
IAM: &Statement{ IAM: &Statement{
Effect: StatementEffectDeny, Effect: StatementEffectDeny,
Principal: Principal{Service: "service"}, Principal: Principal{Service: fi.PtrTo(stringorset.Of("service"))},
Condition: map[string]interface{}{ Condition: map[string]interface{}{
"bar": "baz", "bar": "baz",
}, },