Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion pkg/brood/data.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package brood

import (
"encoding/json"
)

type User struct {
Id string `json:"id"`
Username string `json:"username"`
Expand Down Expand Up @@ -83,11 +87,37 @@ type resourceUpdateRequest struct {
}

type ResourceHolder struct {
Id string `json:"id"`
Id string `json:"holder_id"`
HolderType string `json:"holder_type"`
Permissions []string `json:"permissions"`
}

func (r *ResourceHolder) UnmarshalJSON(data []byte) error {
// Define an alias to avoid recursion in custom unmarshaling
type Alias ResourceHolder
aux := &struct {
Id string `json:"id"`
HolderId string `json:"holder_id"`
*Alias
}{
Alias: (*Alias)(r),
}

// Unmarshal into the auxiliary struct
if err := json.Unmarshal(data, &aux); err != nil {
return err
}

// Populate the Id field based on available data
if aux.Id != "" {
r.Id = aux.Id
} else {
r.Id = aux.HolderId
}

return nil
}

type ResourceHolders struct {
ResourceId string `json:"resource_id"`
Holders []ResourceHolder `json:"holders"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package bugout

const Version string = "0.4.5"
const Version string = "0.4.6"