mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-09-02 07:44:39 +00:00
Add listToOutput misc func
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
@@ -3,7 +3,9 @@ package utils
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gopkg.in/yaml.v3"
|
||||
"image"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -183,3 +185,16 @@ func Version() string {
|
||||
v = strings.ReplaceAll(v, "+k3s-Kairos", "-")
|
||||
return strings.ReplaceAll(v, "Kairos", "")
|
||||
}
|
||||
|
||||
func ListToOutput(rels []string, output string) []string {
|
||||
switch strings.ToLower(output) {
|
||||
case "yaml":
|
||||
d, _ := yaml.Marshal(rels)
|
||||
return []string{string(d)}
|
||||
case "json":
|
||||
d, _ := json.Marshal(rels)
|
||||
return []string{string(d)}
|
||||
default:
|
||||
return rels
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user