Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pohly committed Jul 6, 2020
1 parent e13dcaf commit 5f82e32
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 6 additions & 2 deletions cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
"github.com/kubernetes-csi/external-provisioner/pkg/capacity"
"github.com/kubernetes-csi/external-provisioner/pkg/capacity/topology"
ctrl "github.com/kubernetes-csi/external-provisioner/pkg/controller"
"github.com/kubernetes-csi/external-provisioner/pkg/features"
snapclientset "github.com/kubernetes-csi/external-snapshotter/v2/pkg/client/clientset/versioned"
)

Expand Down Expand Up @@ -79,6 +78,11 @@ var (

defaultFSType = flag.String("default-fstype", "", "The default filesystem type of the volume to provision when fstype is unspecified in the StorageClass. If the default is not set and fstype is unset in the StorageClass, then no fstype will be set")

capacityFeatures = func() *capacity.Features {
capacity := &capacity.Features{}
flag.Var(capacity, "enable-capacity", "Enables producing CSIStorageCapacity objects with capacity information the driver's GetCapacity call. Currently supported: -enable-capacity=central.")
return capacity
}()
featureGates map[string]bool
provisionController *controller.ProvisionController
version = "unknown"
Expand Down Expand Up @@ -265,7 +269,7 @@ func main() {
)

var capacityController *capacity.Controller
if featureGates[string(features.CentralCapacity)] {
if (*capacityFeatures)[capacity.FeatureCentral] {
// TODO: use parameters instead?
podName := os.Getenv("POD_NAME")
namespace := os.Getenv("POD_NAMESPACE")
Expand Down
9 changes: 7 additions & 2 deletions pkg/capacity/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package capacity

import (
"flag"
"fmt"
"strings"

flag "github.com/spf13/pflag"
)

// Feature is the type for named features supported by the capacity
Expand Down Expand Up @@ -68,4 +69,8 @@ func (features *Features) String() string {
return strings.Join(parts, ",")
}

var _ = flag.Value(&Features{})
func (features *Features) Type() string {
return "enumeration"
}

var _ flag.Value = &Features{}
7 changes: 1 addition & 6 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ const (
// alpha: v0.4
// beta: v1.2
Topology featuregate.Feature = "Topology"

// owner: @pohly
// alpha: 2.0.0
CentralCapacity featuregate.Feature = "CentralCapacity"
)

func init() {
Expand All @@ -39,6 +35,5 @@ func init() {
// defaultKubernetesFeatureGates consists of all known feature keys specific to external-provisioner.
// To add a new feature, define a key for it above and add it here.
var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
Topology: {Default: false, PreRelease: featuregate.Beta},
CentralCapacity: {Default: false, PreRelease: featuregate.Alpha},
Topology: {Default: false, PreRelease: featuregate.Beta},
}

0 comments on commit 5f82e32

Please sign in to comment.