Skip to content

Commit

Permalink
operator: add feature gate for maintenance mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Apr 20, 2022
1 parent 5314b8d commit 46c56c9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
// CentralizedConfiguration feature gate should be removed when the operator
// will no longer support 21.x or older versions
func CentralizedConfiguration(version string) bool {
if version == "dev" {
if version == devVersion {
// development version contains this feature
return true
}
Expand Down
14 changes: 14 additions & 0 deletions src/go/k8s/pkg/resources/featuregates/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2022 Redpanda Data, Inc.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

package featuregates

const (
devVersion = "dev"
)
32 changes: 32 additions & 0 deletions src/go/k8s/pkg/resources/featuregates/maintenance_mode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2022 Redpanda Data, Inc.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

package featuregates

import "github.com/Masterminds/semver/v3"

const (
maintenanceModeMajor = uint64(22)
maintenanceModeMinor = uint64(1)
)

// MaintenanceMode feature gate should be removed when the operator
// will no longer support 21.x or older versions
func MaintenanceMode(version string) bool {
if version == devVersion {
// development version contains this feature
return true
}
v, err := semver.NewVersion(version)
if err != nil {
return false
}

return v.Major() == maintenanceModeMajor && v.Minor() >= maintenanceModeMinor || v.Major() > maintenanceModeMajor
}

0 comments on commit 46c56c9

Please sign in to comment.