Skip to content

Commit

Permalink
fix: dependent feature toggle evaluation (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus authored Oct 27, 2023
1 parent 0e7a341 commit f4eaa60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Checkout client specifications
with:
repository: Unleash/client-specification
ref: refs/tags/v4.3.1
ref: refs/tags/v4.5.2
path: testdata/client-specification
- uses: actions/setup-go@v2
name: Setup go
Expand Down
10 changes: 5 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,16 @@ func (uc *Client) isParentDependencySatisfied(feature *api.Feature, context cont
return false
}

enabledResult := uc.isEnabled(parent.Feature, WithContext(context))
// According to the schema, if the enabled property is absent we assume it's true.
if parent.Enabled == nil {
if parent.Variants != nil && len(*parent.Variants) > 0 {
variantName := uc.getVariantWithoutMetrics(parent.Feature, WithVariantContext(context)).Name
return contains(*parent.Variants, variantName)
if parent.Variants != nil && len(*parent.Variants) > 0 && enabledResult.Variant != nil {
return enabledResult.Enabled && contains(*parent.Variants, enabledResult.Variant.Name)
}
return uc.isEnabled(parent.Feature, WithContext(context)).Enabled
return enabledResult.Enabled
}

return !uc.isEnabled(parent.Feature, WithContext(context)).Enabled
return !enabledResult.Enabled
}

allDependenciesSatisfied := every(*feature.Dependencies, func(parent interface{}) bool {
Expand Down

0 comments on commit f4eaa60

Please sign in to comment.