ShowEnabled returns all the features enabled in the Gate contained in ctx.
(ctx context.Context)
| 135 | |
| 136 | // ShowEnabled returns all the features enabled in the Gate contained in ctx. |
| 137 | func ShowEnabled(ctx context.Context) string { |
| 138 | featuresEnabled := []string{} |
| 139 | if gate, ok := ctx.Value(contextKey{}).(interface { |
| 140 | Gate |
| 141 | GetAll() map[Feature]featuregate.FeatureSpec |
| 142 | }); ok { |
| 143 | specs := gate.GetAll() |
| 144 | for feature := range specs { |
| 145 | // `gate.Enabled` first checks if the feature is enabled; |
| 146 | // then (if not explicitly set by the user), |
| 147 | // it checks if the feature is on/true by default |
| 148 | if gate.Enabled(feature) { |
| 149 | featuresEnabled = append(featuresEnabled, fmt.Sprintf("%s=true", feature)) |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | slices.Sort(featuresEnabled) |
| 154 | return strings.Join(featuresEnabled, ",") |
| 155 | } |
| 156 | |
| 157 | // ShowAssigned returns the features enabled or disabled by Set and SetFromMap |
| 158 | // in the Gate contained in ctx. |