Documentation ¶
Overview ¶
Package options some common options for cli
Index ¶
- Constants
- Variables
- func NotEmptyKeyValueOptionValidation(path *field.Path, option KeyValueListOption) (errs field.ErrorList)
- func RegisterFlags(obj interface{}, flags *pflag.FlagSet)
- func RegisterSetup(obj interface{}, ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func RequiredKeyValueOptionValidation(path *field.Path, option KeyValueListOption) (errs field.ErrorList)
- func ValuesValidationOptionsFrom(ctx context.Context) ([]pkgargs.ValuesValidateOption, bool)
- func WithValuesValidationOpts(parent context.Context, opts []pkgargs.ValuesValidateOption) context.Context
- type CLIPathOption
- type CodeLinterOption
- func (c *CodeLinterOption) AddFlags(flags *pflag.FlagSet)
- func (c *CodeLinterOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func (c *CodeLinterOption) Validate(path *field.Path) (errs field.ErrorList)
- func (c *CodeLinterOption) ValidateQualityGate(ctx context.Context) (errs field.ErrorList)
- func (c *CodeLinterOption) WriteResult(err error, w io.Writer)
- type CommandOption
- type ContainerImagesOption
- func (m *ContainerImagesOption) AddFlags(flags *pflag.FlagSet)
- func (m *ContainerImagesOption) GetParseError() field.ErrorList
- func (m *ContainerImagesOption) GetReferences() []artifacts.URI
- func (m *ContainerImagesOption) SetTagRequired(required bool) *ContainerImagesOption
- func (m *ContainerImagesOption) SetValueRequired(required bool) *ContainerImagesOption
- func (m *ContainerImagesOption) SetWithoutDigest(required bool) *ContainerImagesOption
- func (m *ContainerImagesOption) Setup(ctx context.Context, _ *cobra.Command, args []string) (err error)
- func (m *ContainerImagesOption) Validate(path *field.Path) (errs field.ErrorList)
- func (m *ContainerImagesOption) ValidateReferences(path *field.Path, references []artifacts.URI) (errs field.ErrorList)
- func (m *ContainerImagesOption) WriteResult(artfactList []artifacts.URI) (err error)
- type ContextOption
- type DependencyReposOption
- type DeployRepositoryOption
- type EnvFlagsOption
- type ExitCodeOption
- type FlagRegister
- type KatanomiPathOption
- type KeyValueListOption
- type KeyValueOptionValidationFunc
- type Log
- type MetricType
- type QualityGateOption
- type QualityGateRulesOption
- func (m *QualityGateRulesOption) GetRuleValue(key string) (value string, exist bool)
- func (m *QualityGateRulesOption) GetRuleValueFloat(key string) (value float64, exist bool, err error)
- func (m *QualityGateRulesOption) GetRuleValueInt(key string) (value int, exist bool, err error)
- func (m *QualityGateRulesOption) Setup(ctx context.Context, _ *cobra.Command, args []string) (err error)
- type RESTClientGetterOption
- type ReportPathOption
- type ReportPathsByTypesOption
- func (r *ReportPathsByTypesOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func (r *ReportPathsByTypesOption) TestSummariesByType(parentPath string) (summaries report.SummariesByType, err error)
- func (m *ReportPathsByTypesOption) Validate(path *field.Path) (errs field.ErrorList)
- type ReportTypeOption
- func (m *ReportTypeOption) AddFlags(flags *pflag.FlagSet)
- func (m *ReportTypeOption) Parse(path string) (result interface{}, err error)
- func (m *ReportTypeOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func (m *ReportTypeOption) Validate(path *field.Path) (errs field.ErrorList)
- type ResultPathOption
- type ResultsOCIContainerImageBuildURLOption
- type ScanFlagsOption
- type SetupRegister
- type SourcePathOption
- type ToolImageOption
- type UnitTestQuaityGateOption
- func (m *UnitTestQuaityGateOption) AddFlags(flags *pflag.FlagSet)
- func (m *UnitTestQuaityGateOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func (m *UnitTestQuaityGateOption) Validate(path *field.Path) (errs field.ErrorList)
- func (m *UnitTestQuaityGateOption) ValidateQualityGate(ctx context.Context, testResults *v1alpha1.UnitTestsResult) (errs field.ErrorList)
- type UnitTestReportOption
- func (m *UnitTestReportOption) AddFlags(flags *pflag.FlagSet)
- func (m *UnitTestReportOption) ParseReport() (interface{}, error)
- func (m *UnitTestReportOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func (m *UnitTestReportOption) Validate(path *field.Path) (errs field.ErrorList)
- func (c *UnitTestReportOption) WriteResult(obj interface{}) error
- type VulnScanMetricsOption
- type VulnScanOption
- func (c *VulnScanOption) AddFlags(flags *pflag.FlagSet)
- func (c *VulnScanOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
- func (c *VulnScanOption) Validate(path *field.Path) (errs field.ErrorList)
- func (c *VulnScanOption) ValidateQualityGate(ctx context.Context) (errs field.ErrorList)
- func (c *VulnScanOption) WriteMetricsResult(err error, w io.Writer)
- func (c *VulnScanOption) WriteResult(err error, w io.Writer)
Constants ¶
const ( // LinesCoverageMetric coverage lines rule. LinesCoverageMetric = "lines-coverage" // BranchesCoverageMetric coverage branches rule. BranchesCoverageMetric = "branches-coverage" // PassedTestsRateMetric test result passed rate rule. PassedTestsRateMetric = "passed-tests-rate" )
const (
PathKtnSettingCli = "ktn-task"
)
Variables ¶
var AutomatedTestResultDefaultParser = map[report.ReportType]report.ReportParser{report.TypeJunitXml: &report.JunitParser{}}
AutomatedTestResultDefaultParser AutomatedTestResult default parser
Functions ¶
func NotEmptyKeyValueOptionValidation ¶
func NotEmptyKeyValueOptionValidation(path *field.Path, option KeyValueListOption) (errs field.ErrorList)
NotEmptyKeyValueOptionValidation require to have at least one key/value pair
func RegisterFlags ¶
RegisterFlags register flags
func RegisterSetup ¶
func RegisterSetup(obj interface{}, ctx context.Context, cmd *cobra.Command, args []string) (err error)
RegisterSetup register setup function
func RequiredKeyValueOptionValidation ¶
func RequiredKeyValueOptionValidation(path *field.Path, option KeyValueListOption) (errs field.ErrorList)
RequiredKeyValueOptionValidation requires a non-empty values for key and value in all pairs for KeyValueOption
func ValuesValidationOptionsFrom ¶
func ValuesValidationOptionsFrom(ctx context.Context) ([]pkgargs.ValuesValidateOption, bool)
ValuesValidationOptionsFrom returns the value of the envValuesValidationKey key on the ctx
func WithValuesValidationOpts ¶
func WithValuesValidationOpts(parent context.Context, opts []pkgargs.ValuesValidateOption) context.Context
WithValuesValidationOpts returns a copy of parent in which the []ValuesValidateOption is set
Types ¶
type CLIPathOption ¶
type CLIPathOption struct { // CLIPath direct path for CLI // used to store the default value // i.e /bin/helm CLIPath string // FlagName to be used to store FlagName string }
CLIPathOption adds a generic option to store different cli paths
func (*CLIPathOption) AddFlags ¶
func (p *CLIPathOption) AddFlags(flags *pflag.FlagSet)
AddFlags adds flags for option
type CodeLinterOption ¶
type CodeLinterOption struct { v1alpha1.CodeLintResult `json:",inline"` QualityGateOption QualityGateRulesOption }
CodeLinterOption quality gate options for tasks of codeLinter type
func (*CodeLinterOption) AddFlags ¶
func (c *CodeLinterOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
func (*CodeLinterOption) Setup ¶
func (c *CodeLinterOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
Setup init quality gate rules from args
func (*CodeLinterOption) Validate ¶
func (c *CodeLinterOption) Validate(path *field.Path) (errs field.ErrorList)
Validate validate params
func (*CodeLinterOption) ValidateQualityGate ¶
func (c *CodeLinterOption) ValidateQualityGate(ctx context.Context) (errs field.ErrorList)
func (*CodeLinterOption) WriteResult ¶
func (c *CodeLinterOption) WriteResult(err error, w io.Writer)
WriteResult save quality gate result
type CommandOption ¶
type CommandOption struct {
Command string
}
CommandOption describe command option
func (*CommandOption) AddFlags ¶
func (m *CommandOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type ContainerImagesOption ¶
type ContainerImagesOption struct { ContainerImages []string Type artifacts.ArtifactType ResultPath string // contains filtered or unexported fields }
ContainerImagesOption describe container images option
func (*ContainerImagesOption) AddFlags ¶
func (m *ContainerImagesOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags for ContainerImageOption
func (*ContainerImagesOption) GetParseError ¶
func (m *ContainerImagesOption) GetParseError() field.ErrorList
GetParseError returns references of the container-images.
func (*ContainerImagesOption) GetReferences ¶
func (m *ContainerImagesOption) GetReferences() []artifacts.URI
GetReferences returns references of the container-images.
func (*ContainerImagesOption) SetTagRequired ¶
func (m *ContainerImagesOption) SetTagRequired(required bool) *ContainerImagesOption
SetTagRequired set tag is not an empty tag.
func (*ContainerImagesOption) SetValueRequired ¶
func (m *ContainerImagesOption) SetValueRequired(required bool) *ContainerImagesOption
SetValueRequired set container-images as a required flag.
func (*ContainerImagesOption) SetWithoutDigest ¶
func (m *ContainerImagesOption) SetWithoutDigest(required bool) *ContainerImagesOption
SetWithoutDigest set tag is not an empty tag.
func (*ContainerImagesOption) Setup ¶
func (m *ContainerImagesOption) Setup(ctx context.Context, _ *cobra.Command, args []string) (err error)
Setup init container images from args
func (*ContainerImagesOption) Validate ¶
func (m *ContainerImagesOption) Validate(path *field.Path) (errs field.ErrorList)
Validate check if the container images is valid
func (*ContainerImagesOption) ValidateReferences ¶
func (m *ContainerImagesOption) ValidateReferences(path *field.Path, references []artifacts.URI) (errs field.ErrorList)
ValidateReferences check if the container images is valid
func (*ContainerImagesOption) WriteResult ¶
func (m *ContainerImagesOption) WriteResult(artfactList []artifacts.URI) (err error)
WriteResult writes a result to the provided path if given
type ContextOption ¶
ContextOption describe the work dir to execute the command
func (*ContextOption) AddFlags ¶
func (p *ContextOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type DependencyReposOption ¶
DependencyReposOption describe dependency repo option
type DeployRepositoryOption ¶
type DeployRepositoryOption struct { // DeployRepository deploy registry url DeployRepository string // Required define DeployRepository is required Required bool // DeployArgs save deloy agrs. DeployArgs map[string]string }
DeployRepositoryOption describe deploy repo option
func (*DeployRepositoryOption) AddFlags ¶
func (m *DeployRepositoryOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type EnvFlagsOption ¶
EnvFlagsOption describe env flags option
func (*EnvFlagsOption) WriteEnvFile ¶
func (p *EnvFlagsOption) WriteEnvFile(filename string) error
WriteEnvFile writes env variables to target file
type ExitCodeOption ¶
type ExitCodeOption struct { // ExitCodePath direct path for exitCodefile ExitCodePath string // FlagName to be used to store FlagName string }
ExitCodeOption adds a generic option to store different cli paths
func (*ExitCodeOption) AddFlags ¶
func (p *ExitCodeOption) AddFlags(flags *pflag.FlagSet)
AddFlags adds flags for option
type FlagRegister ¶
FlagRegister flag register interface
type KatanomiPathOption ¶
KatanomiPathOption describe katanomi path option
func (*KatanomiPathOption) AddFlags ¶
func (p *KatanomiPathOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type KeyValueListOption ¶
type KeyValueListOption struct { // FlagName used to declare the flag name when interpreting arguments // "abc" will expect "--abc key1=value1 key2=value2" argument FlagName string // KeyValues stored after step KeyValues map[string]string // Validations stores a list of validation functions to be executed // during validation Validations []KeyValueOptionValidationFunc }
KeyValueListOption describe a key=value array set
func (*KeyValueListOption) AddValidation ¶
func (m *KeyValueListOption) AddValidation(validationFunc ...KeyValueOptionValidationFunc)
AddValidation adds a validation function for this option
type KeyValueOptionValidationFunc ¶
type KeyValueOptionValidationFunc func(path *field.Path, option KeyValueListOption) (errs field.ErrorList)
KeyValueOptionValidationFunc simple validation function to check the whole
type Log ¶
type Log struct { Logger *zap.SugaredLogger // contains filtered or unexported fields }
Log Log related options
type QualityGateOption ¶
QualityGateOption describe quality gate option
func (*QualityGateOption) AddFlags ¶
func (m *QualityGateOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type QualityGateRulesOption ¶
QualityGateRulesOption describe quality gate rules option
func (*QualityGateRulesOption) GetRuleValue ¶
func (m *QualityGateRulesOption) GetRuleValue(key string) (value string, exist bool)
GetRuleValue get rule value
func (*QualityGateRulesOption) GetRuleValueFloat ¶
func (m *QualityGateRulesOption) GetRuleValueFloat(key string) (value float64, exist bool, err error)
GetRuleValueFloat get rule value as float64
func (*QualityGateRulesOption) GetRuleValueInt ¶
func (m *QualityGateRulesOption) GetRuleValueInt(key string) (value int, exist bool, err error)
GetRuleValueInt get rule value as int
type RESTClientGetterOption ¶ added in v0.10.0
type RESTClientGetterOption struct { // ConfigFlags for interface of genericclioptions.ConfigFlags ConfigFlag genericclioptions.RESTClientGetter }
RESTClientGetterOption is the generic client option for k8s client
func (*RESTClientGetterOption) GetClusterToken ¶ added in v0.10.0
func (m *RESTClientGetterOption) GetClusterToken(ctx context.Context) (string, error)
GetClusterToken get token for kubeconfig.
func (*RESTClientGetterOption) GetNamespace ¶ added in v0.10.0
func (m *RESTClientGetterOption) GetNamespace() (string, error)
GetNamespace get namespace from environment or incluster kubeconfig
type ReportPathOption ¶
ReportPathOption describe report path option
func (*ReportPathOption) AddFlags ¶
func (m *ReportPathOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type ReportPathsByTypesOption ¶
type ReportPathsByTypesOption struct { ReportPathByTypes map[report.ReportType]string ReportParsers map[report.ReportType]report.ReportParser }
ReportPathsByTypesOption is the option for multiple report types with its report paths
func (*ReportPathsByTypesOption) Setup ¶
func (r *ReportPathsByTypesOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
Setup defines how to start up with report-configs option
func (*ReportPathsByTypesOption) TestSummariesByType ¶
func (r *ReportPathsByTypesOption) TestSummariesByType(parentPath string) (summaries report.SummariesByType, err error)
TestSummariesByType gets test summaries by report type
type ReportTypeOption ¶
type ReportTypeOption struct { ReportType string Required bool FlagName string SupportedType map[report.ReportType]report.ReportParser }
ReportTypeOption describe report type option
func (*ReportTypeOption) AddFlags ¶
func (m *ReportTypeOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
func (*ReportTypeOption) Parse ¶
func (m *ReportTypeOption) Parse(path string) (result interface{}, err error)
Parse parse according to the message type value row, if the message type is empty, perform any operation.
type ResultPathOption ¶
type ResultPathOption struct { // FlagName defines the name when adding the flag // defaults to result-path FlagName string // ResultPath stores the value read from the flag ResultPath string }
ResultPathOption describe result path option
func (*ResultPathOption) AddFlags ¶
func (p *ResultPathOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type ResultsOCIContainerImageBuildURLOption ¶
type ResultsOCIContainerImageBuildURLOption struct {
OciContainerImageBuildUrl string
}
ResultsOCIContainerImageBuildURLOption describe ociContainerImageBuild-url option Deprecated: use ContainerImageOption result store mechanism instead
func (*ResultsOCIContainerImageBuildURLOption) AddFlags ¶
func (m *ResultsOCIContainerImageBuildURLOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type ScanFlagsOption ¶
ScanFlagsOption describe scan flags option
type SetupRegister ¶
type SetupRegister interface {
Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
}
SetupRegister setup register interface
type SourcePathOption ¶
type SourcePathOption struct {
SourcePath string
}
SourcePathOption describe source path option
func (*SourcePathOption) AddFlags ¶
func (p *SourcePathOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type ToolImageOption ¶
type ToolImageOption struct {
ToolImage string
}
ToolImageOption describe tool image option
func (*ToolImageOption) AddFlags ¶
func (p *ToolImageOption) AddFlags(flags *pflag.FlagSet)
type UnitTestQuaityGateOption ¶
type UnitTestQuaityGateOption struct { QualityGateOption QualityGateRulesOption }
UnitTestQuaityGateOption unittest quaity gate option
func (*UnitTestQuaityGateOption) AddFlags ¶
func (m *UnitTestQuaityGateOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
func (*UnitTestQuaityGateOption) Setup ¶
func (m *UnitTestQuaityGateOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
Setup init quality gate rules from args
func (*UnitTestQuaityGateOption) Validate ¶
func (m *UnitTestQuaityGateOption) Validate(path *field.Path) (errs field.ErrorList)
Validate verify that the input rules are legal.
func (*UnitTestQuaityGateOption) ValidateQualityGate ¶
func (m *UnitTestQuaityGateOption) ValidateQualityGate(ctx context.Context, testResults *v1alpha1.UnitTestsResult) (errs field.ErrorList)
ValidateQualityGate verify that the UnitTestsResult satisfy the quality gate.
type UnitTestReportOption ¶
type UnitTestReportOption struct { ReportPathOption ReportTypeOption ResultPathOption }
UnitTestReportOption unittest report option
func (*UnitTestReportOption) AddFlags ¶
func (m *UnitTestReportOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
func (*UnitTestReportOption) ParseReport ¶
func (m *UnitTestReportOption) ParseReport() (interface{}, error)
ParseReport parse report
func (*UnitTestReportOption) Setup ¶
func (m *UnitTestReportOption) Setup(ctx context.Context, cmd *cobra.Command, args []string) (err error)
Setup init quality gate rules from args
func (*UnitTestReportOption) Validate ¶
func (m *UnitTestReportOption) Validate(path *field.Path) (errs field.ErrorList)
func (*UnitTestReportOption) WriteResult ¶
func (c *UnitTestReportOption) WriteResult(obj interface{}) error
WriteResult save data to result path
type VulnScanMetricsOption ¶ added in v0.12.0
type VulnScanMetricsOption struct { // FlagName is the name of the flag FlagName string // ResultLimit is the maximum number of metrics results to write ResultLimit int }
VulnScanMetricsOption describe quality gate option
func (*VulnScanMetricsOption) AddFlags ¶ added in v0.12.0
func (m *VulnScanMetricsOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
type VulnScanOption ¶
type VulnScanOption struct { securityv1alpha1.VulnScanResult `json:",inline"` QualityGateOption QualityGateRulesOption VulnScanMetricsOption }
VulnScanOption quality gate options for tasks of vulnerability type
func (*VulnScanOption) AddFlags ¶
func (c *VulnScanOption) AddFlags(flags *pflag.FlagSet)
AddFlags add flags to options
func (*VulnScanOption) Validate ¶
func (c *VulnScanOption) Validate(path *field.Path) (errs field.ErrorList)
Validate validate params
func (*VulnScanOption) ValidateQualityGate ¶
func (c *VulnScanOption) ValidateQualityGate(ctx context.Context) (errs field.ErrorList)
func (*VulnScanOption) WriteMetricsResult ¶
func (c *VulnScanOption) WriteMetricsResult(err error, w io.Writer)
WriteMetricsResult save metrics result
func (*VulnScanOption) WriteResult ¶
func (c *VulnScanOption) WriteResult(err error, w io.Writer)
WriteResult save quality gate result
Source Files ¶
- cli_path.go
- code_linter.go
- command.go
- container_images.go
- context.go
- dependency_repos.go
- deploy_repository.go
- doc.go
- env_flags.go
- exit_code_option.go
- keyvalues_flag.go
- log.go
- oci_container_image_build.go
- path.go
- quality_gate.go
- quality_gate_rules.go
- register.go
- report.go
- report_type_option.go
- rest_client_getter.go
- scan_flags.go
- tool_image.go
- unittest_quaity_gate_option.go
- unittest_report_option.go
- vuln_scan.go
- vuln_scan_metrics.go