Browse Source

env: add []string writer

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

21
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) { 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 { for _, v := range value {
if i != 0 { if buf.Len() > 0 {
_, _ = fmt.Fprint(&buf, " ") _, _ = fmt.Fprint(&buf, " ")
} }
_, _ = fmt.Fprintf(&buf, "%v", v) _, _ = fmt.Fprintf(&buf, "%v", v)
} }
s = buf.String() m.writeEnvVar(w, buf.String(), name, args...)
}
func (m *Env) writeEnvVarStrings(w io.Writer, value []string, name string, args ...any) {
var buf bytes.Buffer
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) { func (m *Env) writeEnvVar(w io.Writer, value string, name string, args ...any) {

Loading…
Cancel
Save