Documentation
¶
Index ¶
- Constants
- func ConvertToEntity(entities interface{}) ([]modelAPI.Entity, error)
- func FormatArrayMessage(message string, list []string) string
- func FormatAvailableResourcesMessage() string
- func FormatTime(t time.Time) string
- func GetDefaultConfigPath() string
- func GetKind(res string) (modelV1.Kind, error)
- func GetProject(metadata modelAPI.Metadata, defaultProject string) string
- func HandleOutput(writer io.Writer, output string, obj interface{}) error
- func HandleString(writer io.Writer, msg string) error
- func HandleSuccessResourceMessage(writer io.Writer, kind modelV1.Kind, project string, ...) error
- func HandlerTable(writer io.Writer, column []string, data [][]string)
- func InitGlobalConfig(configPath string)
- func IsGlobalResource(kind modelV1.Kind) bool
- func RunCMD(o CMDOption, cmd *cobra.Command, args []string) error
- func SetProject(project string) error
- func ValidateAndSetOutput(o *string) error
- func WriteConfig(config *CLIConfig) error
- type CLIConfig
- type CMDOption
Constants ¶
const ( JSONOutput = "json" YAMLOutput = "yaml" )
Variables ¶
This section is empty.
Functions ¶
func ConvertToEntity ¶
func FormatArrayMessage ¶
FormatArrayMessage format an array to a list
func FormatAvailableResourcesMessage ¶
func FormatAvailableResourcesMessage() string
FormatAvailableResourcesMessage formats the available resources that the user can use
func FormatTime ¶
FormatTime formats a time with human readable format
func GetDefaultConfigPath ¶
func GetDefaultConfigPath() string
func GetKind ¶
GetKind tries to find the kind from the given string. It returns an error if the kind is not managed, or no alias exists. This method is designed to be called in the cmds improving the readability of the kind arguments parsing.
func GetProject ¶
GetProject determinate the project we should use to perform an action on the current resource with the following logic: if the value is defined in the metadata, then we use this one. If it's not the case we consider the one given through the flag --project. If the flag is not used, then we use the one defined in the global configuration. These two last cases are usually already handled by the command itself during the `Complete` step.
func InitGlobalConfig ¶
func InitGlobalConfig(configPath string)
func IsGlobalResource ¶
IsGlobalResource returns true if the give resource type doesn't belong to a project. Returns false otherwise.
func SetProject ¶
func ValidateAndSetOutput ¶
ValidateAndSetOutput will validate the given output and if it's empty will set it with the default value "yaml"
func WriteConfig ¶
WriteConfig writes the configuration file in the path {USER_HOME}/.perses/config if the directory doesn't exist, the function will create it
Types ¶
type CLIConfig ¶
type CLIConfig struct {
RestClientConfig perseshttp.RestConfigClient `json:"rest_client_config"`
Project string `json:"project"`
// contains filtered or unexported fields
}
var GlobalConfig *CLIConfig
func (*CLIConfig) GetAPIClient ¶
func (c *CLIConfig) GetAPIClient() (api.ClientInterface, error)
func (*CLIConfig) SetAPIClient ¶
func (c *CLIConfig) SetAPIClient(apiClient api.ClientInterface)
type CMDOption ¶
type CMDOption interface {
// Complete is the method where the option is extracting the data from the args and is setting its different attributes.
Complete(args []string) error
// Validate is ensuring that the different value of its attribute are coherent (when it makes sense).
Validate() error
// Execute is the method used by the command to actually run the business logic.
Execute() error
SetWriter(writer io.Writer)
}