Files
threshold/internal/cmd/commands/hostsets/funcs.go
T

57 lines
1.2 KiB
Go
Raw Normal View History

2020-08-28 01:28:26 -04:00
package hostsets
import (
"time"
"github.com/hashicorp/boundary/api/hostsets"
"github.com/hashicorp/boundary/internal/cmd/base"
)
func generateHostSetTableOutput(in *hostsets.HostSet) string {
nonAttributeMap := map[string]interface{}{
"ID": in.Id,
"Version": in.Version,
"Type": in.Type,
"Created Time": in.CreatedTime.Local().Format(time.RFC1123),
"Updated Time": in.UpdatedTime.Local().Format(time.RFC1123),
2020-08-28 01:28:26 -04:00
"Host Catalog ID": in.HostCatalogId,
}
if in.Name != "" {
nonAttributeMap["Name"] = in.Name
}
if in.Description != "" {
nonAttributeMap["Description"] = in.Description
}
maxLength := base.MaxAttributesLength(nonAttributeMap, in.Attributes, keySubstMap)
2020-08-28 01:28:26 -04:00
ret := []string{
"",
"Host Set information:",
2020-08-28 01:28:26 -04:00
base.WrapMap(2, maxLength+2, nonAttributeMap),
"",
" Scope:",
base.ScopeInfoForOutput(in.Scope, maxLength),
}
2020-08-28 01:28:26 -04:00
if len(in.HostIds) > 0 {
ret = append(ret,
"",
" Host IDs:",
2020-08-28 01:28:26 -04:00
base.WrapSlice(4, in.HostIds),
)
}
if len(in.Attributes) > 0 {
ret = append(ret,
"",
" Attributes:",
2020-08-28 01:28:26 -04:00
base.WrapMap(4, maxLength, in.Attributes),
)
}
return base.WrapForHelpText(ret)
}
var keySubstMap = map[string]string{}