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

37 lines
839 B
Go
Raw Normal View History

package scopes
import (
"time"
2020-08-10 17:15:02 -04:00
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/internal/cmd/base"
)
func generateScopeTableOutput(in *scopes.Scope) string {
2020-08-28 01:28:26 -04:00
nonAttributeMap := map[string]interface{}{
"ID": in.Id,
"Version": in.Version,
"Created Time": in.CreatedTime.Local().Format(time.RFC1123),
"Updated Time": in.UpdatedTime.Local().Format(time.RFC1123),
}
2020-08-28 01:28:26 -04:00
2020-08-07 12:55:02 -04:00
if in.Name != "" {
2020-08-28 01:28:26 -04:00
nonAttributeMap["Name"] = in.Name
}
2020-08-07 12:55:02 -04:00
if in.Description != "" {
2020-08-28 01:28:26 -04:00
nonAttributeMap["Description"] = in.Description
}
maxLength := base.MaxAttributesLength(nonAttributeMap, nil, nil)
2020-08-28 01:28:26 -04:00
ret := []string{
"",
"Scope information:",
base.WrapMap(2, maxLength+2, nonAttributeMap),
"",
" Scope (parent):",
base.ScopeInfoForOutput(in.Scope, maxLength),
}
2020-08-28 01:28:26 -04:00
return base.WrapForHelpText(ret)
}