Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpk: display float values as float in cluster config get #18841

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/go/rpk/pkg/cli/cluster/config/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package config

import (
"fmt"
"math"

"github.com/redpanda-data/redpanda/src/go/rpk/pkg/adminapi"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
Expand Down Expand Up @@ -48,10 +49,14 @@ output, use the 'edit' and 'export' commands respectively.`,
} else {
// currentConfig is the result of json.Unmarshal into a
// map[string]interface{}. Due to json rules, all numbers
// are float64. We do not want to print floats, especially
// for large numbers.
// are float64. We do not want to print floats for large
// numbers.
if f64, ok := val.(float64); ok {
val = int64(f64)
if math.Mod(f64, 1.0) == 0 {
val = int64(f64)
} else {
val = f64
}
}
// Intentionally bare output, so that the output can be readily
// consumed in a script.
Expand Down
3 changes: 2 additions & 1 deletion tests/rptest/tests/cluster_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,8 @@ class Example(NamedTuple):
Example("kafka_qdc_enable", "true", True),
Example("append_chunk_size", "32768", 32768),
Example("superusers", "['bob','alice']", ["bob", "alice"]),
Example("storage_min_free_bytes", "1234567890", 1234567890)
Example("storage_min_free_bytes", "1234567890", 1234567890),
Example("kafka_memory_share_for_fetch", "0.6", 0.6)
]

def yamlize(input) -> str:
Expand Down
Loading