-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
capacity: separate flags for mode and immediate binding
`--enable-capacity` was originally designed to be a multi-value boolean map. After removing options from it, replacing it with a single-value string makes more sense.
- Loading branch information
Showing
5 changed files
with
75 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package capacity | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
flag "github.com/spf13/pflag" | ||
) | ||
|
||
// DeploymentMode determines how the capacity controller operates. | ||
type DeploymentMode string | ||
|
||
const ( | ||
// DeploymentModeCentral enables the mode where there is only one | ||
// external-provisioner actively running in the cluster which | ||
// talks to the CSI driver's controller service. | ||
DeploymentModeCentral = DeploymentMode("central") | ||
|
||
// DeploymentModeLocal enables the mode where external-provisioner | ||
// is deployed on each node. Not implemented yet. | ||
DeploymentModeLocal = DeploymentMode("local") | ||
|
||
// DeploymentModeNone disables capacity support. | ||
DeploymentModeNone = DeploymentMode("none") | ||
) | ||
|
||
// Set enables the named features. Multiple features can be listed, separated by commas, | ||
// with optional whitespace. | ||
func (mode *DeploymentMode) Set(value string) error { | ||
switch DeploymentMode(value) { | ||
case DeploymentModeCentral, DeploymentModeNone: | ||
*mode = DeploymentMode(value) | ||
default: | ||
return errors.New("invalid value") | ||
} | ||
return nil | ||
} | ||
|
||
func (mode *DeploymentMode) String() string { | ||
return string(*mode) | ||
} | ||
|
||
func (mode *DeploymentMode) Type() string { | ||
return strings.Join([]string{string(DeploymentModeCentral), string(DeploymentModeNone)}, "|") | ||
} | ||
|
||
var _ flag.Value = new(DeploymentMode) |