cli

package
v0.0.0-...-8fecd41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCliCommands

func NewCliCommands(ad ArgsData, plChan chan models.OpenshiftAuditResults, completedChan chan bool, fi []utils.FilesInfo) []cli.Command

NewCliCommands return cli openshift obj commands accept cli args data , completion chan , result chan , spec files and return artay of cli commands

func NewCommandArgs

func NewCommandArgs(ad ArgsData) []string

NewCommandArgs return new cli command args accept cli args and return command args

func NewCompletionChan

func NewCompletionChan() chan bool

NewCompletionChan return plugin Completion chan

func NewOpenshiftResultChan

func NewOpenshiftResultChan() chan models.OpenshiftAuditResults

NewOpenshiftResultChan return plugin test result chan

func StartCLI

func StartCLI()

StartCLI start ldx-prob audit tester

func StartCLICommand

func StartCLICommand(fm utils.FolderMgr, plChan chan models.OpenshiftAuditResults, completedChan chan bool, ad ArgsData, cmdArgs []string, commands map[string]cli.CommandFactory, log *logger.OsOrdealLogger)

StartCLICommand invoke cli openshift command openshift-ordeal cli

Types

type ArgsData

type ArgsData struct {
	Filters     []string
	Help        bool
	SpecType    string
	SpecVersion string
}

ArgsData hold cli args data

func NewCliArgs

func NewCliArgs(sa SanitizeArgs) ArgsData

NewCliArgs return cli args

type SanitizeArgs

type SanitizeArgs func(str []string) ArgsData

SanitizeArgs sanitizer func

var ArgsSanitizer SanitizeArgs = func(str []string) ArgsData {
	ad := ArgsData{SpecType: "openshift"}
	args := make([]string, 0)
	if len(str) == 0 {
		args = append(args, "")
	}
	for _, arg := range str {
		arg = strings.Replace(arg, "--", "", -1)
		arg = strings.Replace(arg, "-", "", -1)
		switch {
		case arg == "help", arg == "h":
			ad.Help = true
			args = append(args, arg)
		case strings.HasPrefix(arg, "s="):
			ad.SpecType = arg[len("s="):]
		case strings.HasPrefix(arg, "spec="):
			ad.SpecType = arg[len("spec="):]
		case strings.HasPrefix(arg, "v="):
			ad.SpecVersion = fmt.Sprintf("v%s", arg[len("v="):])
		case strings.HasPrefix(arg, "version="):
			ad.SpecVersion = fmt.Sprintf("v%s", arg[len("version="):])
		default:
			args = append(args, arg)
		}
	}
	if ad.SpecType == "openshift" && len(ad.SpecVersion) == 0 {
		ad.SpecVersion = "v1.0.0"
	}
	ad.Filters = args
	return ad
}

ArgsSanitizer sanitize CLI arguments

func NewArgFunc

func NewArgFunc() SanitizeArgs

NewArgFunc return args func

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL