-
Notifications
You must be signed in to change notification settings - Fork 23
/
installers.go
40 lines (32 loc) · 1.01 KB
/
installers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package print
import (
"github.com/replicatedhq/replicated/pkg/types"
"strings"
"text/tabwriter"
"text/template"
)
var installersTmplSrc = `SEQUENCE CREATED ACTIVE_CHANNELS
{{ range . -}}
{{ .Sequence }} {{ time .CreatedAt.Time }} {{ .ActiveChannels }}
{{ end }}`
var installersTmpl = template.Must(template.New("Installers").Funcs(funcs).Parse(installersTmplSrc))
func Installers(w *tabwriter.Writer, appReleases []types.InstallerSpec) error {
rs := make([]map[string]interface{}, len(appReleases))
for i, r := range appReleases {
// join active channel names like "Stable,Unstable"
activeChans := make([]string, len(r.ActiveChannels))
for j, activeChan := range r.ActiveChannels {
activeChans[j] = activeChan.Name
}
activeChansField := strings.Join(activeChans, ",")
rs[i] = map[string]interface{}{
"Sequence": r.Sequence,
"CreatedAt": r.CreatedAt,
"ActiveChannels": activeChansField,
}
}
if err := installersTmpl.Execute(w, rs); err != nil {
return err
}
return w.Flush()
}