Skip to content

Commit

Permalink
omit empty chilren or override
Browse files Browse the repository at this point in the history
  • Loading branch information
steviebps committed Sep 9, 2021
1 parent 7d7b205 commit 7d88172
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/chamber.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Chamber struct {
IsBuildable bool `json:"isBuildable"`
IsApp bool `json:"isApp"`
Toggles map[string]*Toggle `json:"toggles"`
Children []*Chamber `json:"children"`
Children []*Chamber `json:"children,omitempty"`
}

// // EncodeWith takes a writer and encodes JSON to that writer
Expand Down Expand Up @@ -63,11 +63,11 @@ func (c *Chamber) InheritWith(inherited map[string]*Toggle) {

// TraverseAndBuild will traverse all Chambers while inheriting their parent Toggles and executes a callback on each Chamber node.
// Traversing will stop if callback returns true.
func (c *Chamber) TraverseAndBuild(callback func(*Chamber) bool) {
func (c *Chamber) TraverseAndBuild(callback func(Chamber) bool) {

// if callback returns true, stop traversing
// consumer was only looking to build up to this point
if callback(c) {
if callback(*c) {
return
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/toggle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Toggle struct {
Name string `json:"name"`
ToggleType string `json:"type"`
Value interface{} `json:"value"`
Overrides []*Override `json:"overrides"`
Overrides []*Override `json:"overrides,omitempty"`
}

type toggleAlias Toggle
Expand Down

0 comments on commit 7d88172

Please sign in to comment.