Skip to content

Commit

Permalink
fix: correctly marshal RBAC 'actions'
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele authored and rainest committed Feb 14, 2022
1 parent 9fe38c3 commit 3c8d6e1
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions kong/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kong
import (
"encoding/json"
"fmt"
"strings"
)

// Service represents a Service in Kong.
Expand Down Expand Up @@ -364,20 +363,17 @@ func (e *RBACEndpointPermission) MarshalJSON() ([]byte, error) {
CreatedAt *int `json:"created_at,omitempty" yaml:"created_at,omitempty"`
Workspace *string `json:"workspace,omitempty" yaml:"workspace,omitempty"`
Endpoint *string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Actions *string `json:"actions,omitempty" yaml:"actions,omitempty"`
Actions []*string `json:"actions,omitempty" yaml:"actions,omitempty"`
Negative *bool `json:"negative,omitempty" yaml:"negative,omitempty"`
Role *RBACRole `json:"role,omitempty" yaml:"role,omitempty"`
Comment *string `json:"comment,omitempty" yaml:"comment,omitempty"`
}
var actions []string
for _, action := range e.Actions {
actions = append(actions, *action)
}

return json.Marshal(&ep{
CreatedAt: e.CreatedAt,
Workspace: e.Workspace,
Endpoint: e.Endpoint,
Actions: String(strings.Join(actions, ",")),
Actions: e.Actions,
Negative: e.Negative,
Comment: e.Comment,
})
Expand All @@ -403,20 +399,16 @@ func (e *RBACEntityPermission) MarshalJSON() ([]byte, error) {
CreatedAt *int `json:"created_at,omitempty" yaml:"created_at,omitempty"`
EntityID *string `json:"entity_id,omitempty" yaml:"entity_id,omitempty"`
EntityType *string `json:"entity_type,omitempty" yaml:"entity_type,omitempty"`
Actions *string `json:"actions,omitempty" yaml:"actions,omitempty"`
Actions []*string `json:"actions,omitempty" yaml:"actions,omitempty"`
Negative *bool `json:"negative,omitempty" yaml:"negative,omitempty"`
Role *RBACRole `json:"role,omitempty" yaml:"role,omitempty"`
Comment *string `json:"comment,omitempty" yaml:"comment,omitempty"`
}
var actions []string
for _, action := range e.Actions {
actions = append(actions, *action)
}
return json.Marshal(&ep{
CreatedAt: e.CreatedAt,
EntityID: e.EntityID,
EntityType: e.EntityType,
Actions: String(strings.Join(actions, ",")),
Actions: e.Actions,
Negative: e.Negative,
Comment: e.Comment,
})
Expand Down

0 comments on commit 3c8d6e1

Please sign in to comment.