498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"sort"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
"github.com/milvus-io/milvus/pkg/v3/mlog"
|
|
)
|
|
|
|
func ShowYaml(filepath string) {
|
|
data, err := os.ReadFile(filepath) //nolint:gosec // filepath is from CLI args, not untrusted input
|
|
if err != nil {
|
|
mlog.Warn(context.TODO(), "read config failed", mlog.Err(err))
|
|
os.Exit(-3)
|
|
}
|
|
|
|
var raw map[string]interface{}
|
|
if err := yaml.Unmarshal(data, &raw); err != nil {
|
|
mlog.Warn(context.TODO(), "parse config failed", mlog.Err(err))
|
|
os.Exit(-3)
|
|
}
|
|
|
|
flat := make(map[string]string)
|
|
flattenYaml("", raw, flat)
|
|
|
|
keys := make([]string, 0, len(flat))
|
|
for k := range flat {
|
|
keys = append(keys, k)
|
|
}
|
|
sort.Strings(keys)
|
|
for _, key := range keys {
|
|
fmt.Fprintln(os.Stdout, key, "=", flat[key])
|
|
}
|
|
}
|
|
|
|
func flattenYaml(prefix string, m map[string]interface{}, out map[string]string) {
|
|
for k, v := range m {
|
|
fullKey := k
|
|
if prefix != "" {
|
|
fullKey = prefix + "." + k
|
|
}
|
|
switch val := v.(type) {
|
|
case map[string]interface{}:
|
|
flattenYaml(fullKey, val, out)
|
|
case []interface{}:
|
|
for i, item := range val {
|
|
childKey := fmt.Sprintf("%s.%d", fullKey, i)
|
|
if nested, ok := item.(map[string]interface{}); ok {
|
|
flattenYaml(childKey, nested, out)
|
|
} else {
|
|
out[childKey] = fmt.Sprintf("%v", item)
|
|
}
|
|
}
|
|
default:
|
|
if val == nil {
|
|
out[fullKey] = ""
|
|
} else {
|
|
out[fullKey] = fmt.Sprintf("%v", val)
|
|
}
|
|
}
|
|
}
|
|
}
|