Skip to content
Closed
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
3 changes: 2 additions & 1 deletion featuregate/gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (g *Gate) FromVersion() string {
return fmt.Sprintf("v%s", g.fromVersion)
}

// ToVersion returns the version information when Gate's in StageStable.
// ToVersion specifies the version in which a feature gate in StageStable
Comment thread
johnmichaelll238-cloud marked this conversation as resolved.
// is scheduled to be removed. This is only applicable for features in StageStable and should be set to nil for features in other stages.
Comment thread
johnmichaelll238-cloud marked this conversation as resolved.
func (g *Gate) ToVersion() string {
return fmt.Sprintf("v%s", g.toVersion)
}
7 changes: 6 additions & 1 deletion featuregate/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ func (r *Registry) Register(id string, stage Stage, opts ...RegisterOption) (*Ga
return nil, fmt.Errorf("failed to apply option: %w", err)
}
}
switch g.stage {
if g.ToVersion != nil {
Comment thread
johnmichaelll238-cloud marked this conversation as resolved.
if g.Stage != StageStable && !g.Stage.IsDeprecated(){
return fmt.Errorf("ToVersion can only be set for stable or deprecated stages")
}
}
switch g.stage {
case StageAlpha, StageDeprecated:
g.enabled = &atomic.Bool{}
case StageBeta, StageStable:
Expand Down