Skip to content

Commit

Permalink
controller: make parameter really work with cli module
Browse files Browse the repository at this point in the history
    - `DefaulText` is real text. That shows on `--help`.
      `Value` does really for the default value. Actually,
      if the `DefaultText` is nil, that would get the `Value`
      for it.

Signed-off-by: Vicente Cheng <[email protected]>
  • Loading branch information
Vicente-Cheng authored and bk201 committed Jul 4, 2022
1 parent 0bd801a commit 97a2564
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ func main() {
},
&cli.StringFlag{
Name: "namespace",
Value: "longhorn-system",
DefaultText: "longhorn-system",
EnvVars: []string{"LONGHORN_NAMESPACE"},
Destination: &opt.Namespace,
},
&cli.IntFlag{
Name: "threadiness",
Value: 2,
DefaultText: "2",
Destination: &opt.Threadiness,
},
Expand All @@ -66,6 +68,7 @@ func main() {
&cli.StringFlag{
Name: "profile-listen-address",
Value: "0.0.0.0:6060",
DefaultText: "0.0.0.0:6060",
Usage: "Address to listen on for profiling",
Destination: &opt.ProfilerAddress,
},
Expand All @@ -80,6 +83,7 @@ func main() {
EnvVars: []string{"NDM_LOG_FORMAT"},
Usage: "Log format",
Value: "text",
DefaultText: "text",
Destination: &opt.LogFormat,
},
&cli.StringFlag{
Expand All @@ -91,6 +95,7 @@ func main() {
&cli.StringFlag{
Name: "vendor-filter",
Value: "longhorn",
DefaultText: "longhorn",
EnvVars: []string{"NDM_VENDOR_FILTER"},
Usage: "A string of comma-separated values that you want to exclude for block device vendor filter",
Destination: &opt.VendorFilter,
Expand Down Expand Up @@ -123,6 +128,7 @@ func main() {
Name: "max-concurrent-ops",
EnvVars: []string{"NDM_MAX_CONCURRENT_OPS"},
Usage: "Specify the maximum concurrent count of disk operations, such as formatting",
Value: 5,
DefaultText: "5",
Destination: &opt.MaxConcurrentOps,
},
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/blockdevice/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func newSemaphore(n uint) *semaphore {

// acquire a semaphore to prevent concurrent update
func (s *semaphore) acquire() bool {
logrus.Debugf("Pre-acquire channel stats: %d/%d", len(s.ch), cap(s.ch))
select {
case s.ch <- struct{}{}:
return true
Expand Down

0 comments on commit 97a2564

Please sign in to comment.