Skip to content

Commit

Permalink
refine featuregate change output
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k committed Mar 29, 2024
1 parent 40af396 commit 7307170
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
16 changes: 15 additions & 1 deletion pkg/features/feature_diff_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,27 @@ func (i *ReleaseFeatureDiffInfo) GetOrderedFeatureGates() []string {
if strings.HasSuffix(changedFeatureGate, "Unconditional") {
counts[featureGate] = counts[featureGate] - 100
}
if strings.HasSuffix(changedFeatureGate, "Enabled") {
if strings.HasSuffix(changedFeatureGate, "(Changed)") {
switch curr.FeatureSet {
case "Default":
counts[featureGate] = counts[featureGate] - 100
}
counts[featureGate] = counts[featureGate] - 10
}
if strings.HasSuffix(changedFeatureGate, "Enabled (New)") {
switch curr.FeatureSet {
case "Default":
counts[featureGate] = counts[featureGate] - 10
}
counts[featureGate] = counts[featureGate] - 1
}
if strings.HasSuffix(changedFeatureGate, "Disabled (New)") {
switch curr.FeatureSet {
case "Default":
counts[featureGate] = counts[featureGate] - 1
}
counts[featureGate] = counts[featureGate] - 1
}
}
}

Expand Down
32 changes: 20 additions & 12 deletions pkg/features/summarizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,21 @@ func (i *ReleaseFeatureInfo) CalculateDiff(ctx context.Context, from *ReleaseFea
toFeatureInfo := to.FeatureInfoFor(clusterProfile, featureSet)
switch {
case toFeatureInfo == nil && fromFeatureInfo != nil:
currDiffInfo.ChangedFeatureGates[featureGate] = "Not Available"
currDiffInfo.ChangedFeatureGates[featureGate] = "Not Available (Changed)"
continue
case toFeatureInfo == nil && fromFeatureInfo == nil:
currDiffInfo.ChangedFeatureGates[featureGate] = "Remaining Not Available"
currDiffInfo.ChangedFeatureGates[featureGate] = "Not Available"
continue
case toFeatureInfo != nil && fromFeatureInfo == nil:
currDiffInfo.ChangedFeatureGates[featureGate] = "None to Enabled"
toEnabled, toOk := toFeatureInfo.AllFeatureGates[featureGate]
switch {
case !toOk:
currDiffInfo.ChangedFeatureGates[featureGate] = "Unconditional (New)"
case toEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Enabled (New)"
case !toEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Disabled (New)"
}
continue
case toFeatureInfo != nil && fromFeatureInfo != nil:
}
Expand All @@ -132,31 +140,31 @@ func (i *ReleaseFeatureInfo) CalculateDiff(ctx context.Context, from *ReleaseFea
case toOk && !fromOk:
switch {
case toEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Adding as Enabled"
currDiffInfo.ChangedFeatureGates[featureGate] = "Enabled (New)"
case !toEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Adding as Disabled"
currDiffInfo.ChangedFeatureGates[featureGate] = "Disabled (New)"
}
case toOk && fromOk:
switch {
case toEnabled && !fromEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Disabled to Enabled"
currDiffInfo.ChangedFeatureGates[featureGate] = "Enabled (Changed)"
case toEnabled && fromEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Remaining Enabled"
currDiffInfo.ChangedFeatureGates[featureGate] = "Enabled"
case !toEnabled && fromEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Enabled to Disabled"
currDiffInfo.ChangedFeatureGates[featureGate] = "Disabled (Changed)"
changedFeatureGates.Insert(featureGate)
case !toEnabled && !fromEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Remaining Disabled"
currDiffInfo.ChangedFeatureGates[featureGate] = "Disabled"
}
case !toOk && fromOk:
switch {
case fromEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Enabled to Unconditional"
currDiffInfo.ChangedFeatureGates[featureGate] = "Unconditional (Changed)"
case !fromEnabled:
currDiffInfo.ChangedFeatureGates[featureGate] = "Disabled to Unconditional"
currDiffInfo.ChangedFeatureGates[featureGate] = "Unconditional (Changed)"
}
case !toOk && !fromOk:
currDiffInfo.ChangedFeatureGates[featureGate] = "Remaining Unconditional"
currDiffInfo.ChangedFeatureGates[featureGate] = "Unconditional"
}
}
releaseFeatureDiffInfo.featureInfo[clusterProfile][featureSet] = currDiffInfo
Expand Down

0 comments on commit 7307170

Please sign in to comment.