Browse Source

env: add []string writer

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/45/head
Alejandro Mery 8 months ago
parent
commit
3ba721bf7f
  1. 29
      pkg/cluster/env.go

29
pkg/cluster/env.go

@ -85,22 +85,29 @@ func (m *Env) writeEnvZone(w io.Writer, z *Zone) {
}
func (m *Env) writeEnvVarInts(w io.Writer, value []int, name string, args ...any) {
var s string
if n := len(value); n > 0 {
var buf bytes.Buffer
var buf bytes.Buffer
for i, v := range value {
if i != 0 {
_, _ = fmt.Fprint(&buf, " ")
}
_, _ = fmt.Fprintf(&buf, "%v", v)
for _, v := range value {
if buf.Len() > 0 {
_, _ = fmt.Fprint(&buf, " ")
}
_, _ = fmt.Fprintf(&buf, "%v", v)
}
m.writeEnvVar(w, buf.String(), name, args...)
}
func (m *Env) writeEnvVarStrings(w io.Writer, value []string, name string, args ...any) {
var buf bytes.Buffer
s = buf.String()
for _, v := range value {
if buf.Len() > 0 {
_, _ = fmt.Fprint(&buf, " ")
}
_, _ = fmt.Fprintf(&buf, "%s", v)
}
m.writeEnvVar(w, s, name, args...)
m.writeEnvVar(w, buf.String(), name, args...)
}
func (m *Env) writeEnvVar(w io.Writer, value string, name string, args ...any) {

Loading…
Cancel
Save