Skip to content

Commit

Permalink
Merge pull request #826 from go-kivik/sec
Browse files Browse the repository at this point in the history
Apply fix to security document marshaling
  • Loading branch information
flimzy authored Oct 17, 2023
2 parents 60bab64 + ad6feb8 commit f765c02
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,23 @@ type Security struct {
// MarshalJSON satisfies the json.Marshaler interface.
func (s Security) MarshalJSON() ([]byte, error) {
var v struct {
Admins *Members `json:"admins,omitempty"`
Members *Members `json:"members,omitempty"`
Admins *Members `json:"admins,omitempty"`
Members *Members `json:"members,omitempty"`
Cloudant map[string][]string `json:"cloudant,omitempty"`
CouchdbAuthOnly *bool `json:"couchdb_auth_only,omitempty"`
}
if len(s.Admins.Names) > 0 || len(s.Admins.Roles) > 0 {
v.Admins = &s.Admins
}
if len(s.Members.Names) > 0 || len(s.Members.Roles) > 0 {
v.Members = &s.Members
}
if len(s.Cloudant) > 0 {
v.Cloudant = s.Cloudant
}
if s.CouchdbAuthOnly != nil {
v.CouchdbAuthOnly = s.CouchdbAuthOnly
}
return json.Marshal(v)
}

Expand Down

0 comments on commit f765c02

Please sign in to comment.