mirror of
https://github.com/rancher/os.git
synced 2025-09-09 10:40:30 +00:00
Refactor build
This commit is contained in:
32
pkg/config/write.go
Normal file
32
pkg/config/write.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/rancher/wrangler/pkg/data/convert"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
func PrintInstall(cfg Config) ([]byte, error) {
|
||||
if cfg.Elemental.Install.Password != "" {
|
||||
cfg.Elemental.Install.Password = "******"
|
||||
}
|
||||
data, err := convert.EncodeToMap(cfg.Elemental.Install)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toYAMLKeys(data)
|
||||
return yaml.Marshal(data)
|
||||
}
|
||||
|
||||
func toYAMLKeys(data map[string]interface{}) {
|
||||
for k, v := range data {
|
||||
if sub, ok := v.(map[string]interface{}); ok {
|
||||
toYAMLKeys(sub)
|
||||
}
|
||||
newK := convert.ToYAMLKey(k)
|
||||
if newK != k {
|
||||
delete(data, k)
|
||||
data[newK] = v
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user