Documentation
¶
Index ¶
- Constants
- Variables
- func AggregateClientIDs(reqCtx []*policy.RequestContext) []string
- func AskForInput(message string) string
- func AskForSecret(message string) string
- func CommaSeparated(values []string) string
- func ConfirmAction(action, resource, id string, force bool)
- func ConfirmActionSubtext(action, resource, id, subtext string, force bool)
- func ConfirmTextInput(action, resource, inputName, shouldMatchValue string)
- func ConstructMetadata(m *common.Metadata) map[string]string
- func DebugJSON(msg string) interface{}
- func DebugMessage(msg string) string
- func ErrorJSON(msg string, err error) interface{}
- func ErrorMessage(msg string, err error) string
- func ExitWithError(errMsg string, err error)
- func ExitWithNotFoundError(errMsg string, err error)
- func ExitWithWarning(warnMsg string)
- func FooterMessage(msg string) string
- func GetJSONInput(data string) (string, error)
- func GetSimpleObligationValues(v []*policy.ObligationValue) []string
- func GetSimpleRegisteredResourceActionAttributeValues(v []*policy.RegisteredResourceValue_ActionAttributeValue) []string
- func GetSimpleRegisteredResourceValues(v []*policy.RegisteredResourceValue) []string
- func GetState(cmd *cobra.Command) common.ActiveStateEnum
- func KeyAlgToEnum(alg string) (policy.Algorithm, error)
- func KeyEnumToAlg(enum policy.Algorithm) (string, error)
- func MessageJSON(status string, msg string) interface{}
- func NewTable(cols ...table.Column) table.Model
- func NewTabular(rows ...[]string) table.Model
- func NewUUIDColumn() table.Column
- func PrettyList(values []string) string
- func PrintSuccessTable(cmd *cobra.Command, id string, t table.Model)
- func ReadFromArgsOrPipe(args []string, pipe *os.File) []byte
- func ReadFromFile(filePath string) []byte
- func ReadFromPipe(in *os.File) []byte
- func SuccessJSON(msg string) interface{}
- func SuccessMessage(msg string) string
- func TermWidth() int
- func WarningJSON(msg string) interface{}
- func WarningMessage(msg string) string
- func WithListPaginationFooter(t table.Model, p *policy.PageResponse) table.Model
- func WithPrintJSON() cliVariadicOption
- type Cli
- func (c *Cli) Cmd() *cobra.Command
- func (c *Cli) Context() context.Context
- func (c *Cli) ExitWith(styledMsg string, jsonMsg interface{}, code int, w io.Writer)
- func (c *Cli) ExitWithError(errMsg string, err error)
- func (c *Cli) ExitWithJSON(v interface{}, code int)
- func (c *Cli) ExitWithMessage(msg string, code int)
- func (c *Cli) ExitWithNotFoundError(errMsg string, err error)
- func (c *Cli) ExitWithSuccess(msg string)
- func (c *Cli) ExitWithWarning(warnMsg string)
- func (c *Cli) SetJSONOutput(enabled bool)
- type Color
- type FlagsStringSliceOptions
- type Printer
- type SimpleAttribute
- type SimpleAttributeValue
Constants ¶
View Source
const ( // top level actions ActionGet = "get" ActionList = "list" ActionCreate = "create" ActionUpdate = "update" ActionUpdateUnsafe = "unsafely update" ActionDeactivate = "deactivate" ActionReactivate = "reactivate" ActionDelete = "delete" // text input names InputNameFQN = "fully qualified name (FQN)" InputNameFQNUpdated = "deprecated fully qualified name (FQN) being altered" )
View Source
const ( ExitCodeSuccess = 0 ExitCodeError = 1 )
View Source
const ( FlexColumnWidthOne = 1 FlexColumnWidthTwo = 2 FlexColumnWidthThree = 3 FlexColumnWidthFour = 4 FlexColumnWidthFive = 5 )
Variables ¶
View Source
var ErrPrinterExpectsCommand = fmt.Errorf("printer expects a command")
Functions ¶
func AggregateClientIDs ¶ added in v0.25.0
func AggregateClientIDs(reqCtx []*policy.RequestContext) []string
func AskForInput ¶ added in v0.10.0
func AskForSecret ¶ added in v0.10.0
func CommaSeparated ¶
func ConfirmAction ¶
func ConfirmActionSubtext ¶ added in v0.24.0
func ConfirmTextInput ¶
func ConfirmTextInput(action, resource, inputName, shouldMatchValue string)
func DebugMessage ¶ added in v0.13.0
func ErrorMessage ¶
func ExitWithError ¶
func ExitWithNotFoundError ¶
func ExitWithWarning ¶
func ExitWithWarning(warnMsg string)
func FooterMessage ¶
func GetJSONInput ¶ added in v0.25.0
Gets JSON from either a file path or a JSON string
func GetSimpleObligationValues ¶ added in v0.25.0
func GetSimpleObligationValues(v []*policy.ObligationValue) []string
func GetSimpleRegisteredResourceActionAttributeValues ¶ added in v0.21.0
func GetSimpleRegisteredResourceActionAttributeValues(v []*policy.RegisteredResourceValue_ActionAttributeValue) []string
func GetSimpleRegisteredResourceValues ¶ added in v0.21.0
func GetSimpleRegisteredResourceValues(v []*policy.RegisteredResourceValue) []string
func GetState ¶
func GetState(cmd *cobra.Command) common.ActiveStateEnum
Transforms into enum value and defaults to active state
func MessageJSON ¶ added in v0.28.0
func NewTabular ¶
func NewUUIDColumn ¶
func PrettyList ¶ added in v0.16.0
func ReadFromFile ¶
func ReadFromPipe ¶
func SuccessJSON ¶ added in v0.28.0
func SuccessJSON(msg string) interface{}
func SuccessMessage ¶
func TermWidth ¶
func TermWidth() int
Returns the terminal width (overridden by env var for testing)
func WarningJSON ¶ added in v0.28.0
func WarningJSON(msg string) interface{}
func WarningMessage ¶
func WithListPaginationFooter ¶ added in v0.17.0
Adds the page information to the table footer
func WithPrintJSON ¶ added in v0.27.0
func WithPrintJSON() cliVariadicOption
WithPrintJSON is a variadic option that enforces JSON output for the printer
Types ¶
type Cli ¶ added in v0.13.0
type Cli struct {
// Helpers
Flags *flagHelper
FlagHelper *flagHelper
// contains filtered or unexported fields
}
func (*Cli) ExitWith ¶ added in v0.28.0
exitWith is the core exit function that handles both JSON and styled output It writes to the appropriate stream (stdout for success, stderr for errors/warnings)
func (*Cli) ExitWithError ¶ added in v0.13.0
ExitWithError prints an error message and exits with a non-zero status code.
func (*Cli) ExitWithJSON ¶ added in v0.13.0
func (*Cli) ExitWithMessage ¶ added in v0.13.0
func (*Cli) ExitWithNotFoundError ¶ added in v0.13.0
ExitWithNotFoundError prints an error message and exits with a non-zero status code if the error is a NotFound error.
func (*Cli) ExitWithSuccess ¶ added in v0.13.0
func (*Cli) ExitWithWarning ¶ added in v0.13.0
func (*Cli) SetJSONOutput ¶ added in v0.28.0
type Color ¶
type Color struct {
Foreground lipgloss.CompleteAdaptiveColor
Background lipgloss.CompleteAdaptiveColor
}
func ColorYellow ¶ added in v0.22.0
func ColorYellow() Color
type FlagsStringSliceOptions ¶ added in v0.13.0
type SimpleAttribute ¶
type SimpleAttribute struct {
ID string
Name string
Rule string
Values []string
Namespace string
Active string
Metadata map[string]string
}
func GetSimpleAttribute ¶
func GetSimpleAttribute(a *policy.Attribute) SimpleAttribute
type SimpleAttributeValue ¶
func GetSimpleAttributeValue ¶
func GetSimpleAttributeValue(v *policy.Value) SimpleAttributeValue
Click to show internal directories.
Click to hide internal directories.