VictoriaMetrics/lib/flagutil
Zakhar Bessarab efb7213f6b
lib/flagutil/dict: properly update default value in case there is no key value set (#7211)
### Describe Your Changes

If a dict flag has only one value without a prefix it is supposed to
replace default value.

Previously, when flag was set to `-flag=2` and the default value in
`NewDictInt` was set to 1 the resulting value for any `flag.Get()` call
would be 1 which is not expected.

This commit updates default value for the flag in case there is only one
entry for flag and the entry is a number without a key.

This affects cluster version and specifically `replicationFactor` flag
usage with vmstorage [node
groups](https://docs.victoriametrics.com/cluster-victoriametrics/#vmstorage-groups-at-vmselect).
Previously, the following configuration would effectively be ignored:
```
/path/to/vmselect \
 -replicationFactor=2 \
 -storageNode=g1/host1,g1/host2,g1/host3 \
 -storageNode=g2/host4,g2/host5,g2/host6 \
 -storageNode=g3/host7,g3/host8,g3/host9
```

Changes from this PR will force default value for `replicationFactor`
flag to be set to `2` which is expected as the result of this
configuration.


---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
2024-10-17 11:11:45 -03:00
..
testdata all: allow dynamically reading *AuthKey flag values from files and urls 2024-01-22 01:23:23 +02:00
array_test.go all: add support for specifying multiple -httpListenAddr options 2024-02-09 03:22:49 +02:00
array.go all: add support for specifying multiple -httpListenAddr options 2024-02-09 03:22:49 +02:00
bytes_test.go docs/CHANGELOG.md: support empty command-line flag values in short array notation 2024-02-07 20:55:01 +02:00
bytes.go app/vmagent: add max_scrape_size to scrape config (#6434) 2024-06-20 14:00:22 +02:00
dict_test.go lib/flagutil/dict: properly update default value in case there is no key value set (#7211) 2024-10-17 11:11:45 -03:00
dict.go lib/flagutil/dict: properly update default value in case there is no key value set (#7211) 2024-10-17 11:11:45 -03:00
duration_test.go lib/flagutil: use month limit for duration flag for parsed duration assessment (#6486) 2024-06-14 15:21:32 +02:00
duration.go lib/flagutil: use month limit for duration flag for parsed duration assessment (#6486) 2024-06-14 15:21:32 +02:00
flag.go lib/flagutil: do not expose sensitive info (passwords, keys and urls) at /flags page 2021-10-20 00:51:15 +03:00
password_test.go fscore: rollback trailing space trim (#7106) 2024-09-29 14:48:36 +02:00
password.go lib/httpserver: skip basic auth check for additional request paths, which should call httpserver.CheckAuthFlag() 2024-07-16 01:08:41 +02:00
secret.go app/vmagent: substitute -remoteWrite.url with secret-url value in logs, since it may contain sensitive info such as passwords or auth tokens 2020-09-16 22:36:18 +03:00
usage.go lib/flagutil: make golangci-lint happy by using strings.TrimPrefix instead of manual prefix removal via strings.HasPrefix 2020-12-03 22:07:26 +02:00