cmd

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2020 License: MIT Imports: 36 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// JSONOutputFormat is the format of json
	JSONOutputFormat string = "json"
	// YAMLOutputFormat is the format of yaml
	YAMLOutputFormat string = "yaml"
	// TableOutputFormat is the format of table
	TableOutputFormat string = "table"
)

Variables

View Source
var ShellTypes = []string{
	"zsh", "bash", "powerShell",
}

ShellTypes contains all types of shell

Functions

func ColorResult added in v0.0.24

func ColorResult(cell string) string

ColorResult output the result with color

func Execute

func Execute()

Execute will execute the command

func GetAliasesDel added in v0.0.24

func GetAliasesDel() []string

GetAliasesDel returns the aliases for delete command

func GetCategories added in v0.0.22

func GetCategories(jclient *client.JobClient) (
	typeMap map[string]string, types []string, err error)

GetCategories returns the categories of current Jenkins

func GetConfigFromHome added in v0.0.23

func GetConfigFromHome() (configPath string, homeErr error)

GetConfigFromHome returns the config file path from user home dir

func GetEditorHelpText added in v0.0.27

func GetEditorHelpText() string

GetEditorHelpText returns the help text related a text editor

func GetSystemStdio added in v0.0.25

func GetSystemStdio() terminal.Stdio

GetSystemStdio returns the stdio from system

func RenderTemplate added in v0.0.27

func RenderTemplate(path string, values map[string]string) (result string, err error)

RenderTemplate render a go template to a temporary file

func ResetJobBuildOption added in v0.0.23

func ResetJobBuildOption()

ResetJobBuildOption give it a clean option struct

Types

type BatchOption added in v0.0.18

type BatchOption struct {
	Batch bool

	Stdio terminal.Stdio
}

BatchOption represent the options for a batch operation

func (*BatchOption) Confirm added in v0.0.18

func (b *BatchOption) Confirm(message string) bool

Confirm promote user if they really want to do this

func (*BatchOption) SetFlag added in v0.0.18

func (b *BatchOption) SetFlag(cmd *cobra.Command)

SetFlag the flag for batch option

type CASCApplyOption added in v0.0.24

type CASCApplyOption struct {
	RoundTripper http.RoundTripper
}

CASCApplyOption as the options of apply configuration as code

type CASCExportOption added in v0.0.24

type CASCExportOption struct {
	RoundTripper http.RoundTripper
}

CASCExportOption as the options of reload configuration as code

type CASCOpenOption added in v0.0.24

type CASCOpenOption struct {
	ExecContext util.ExecContext
}

CASCOpenOption is the option of casc open cmd

type CASCOptions added in v0.0.24

type CASCOptions struct {
	CommonOption
}

CASCOptions is the option of casc

func (*CASCOptions) Check added in v0.0.24

func (o *CASCOptions) Check() (err error)

Check do the health check of casc cmd

type CASCReloadOption added in v0.0.24

type CASCReloadOption struct {
	RoundTripper http.RoundTripper
}

CASCReloadOption as the options of reload configuration as code

type CASCSchemaOption added in v0.0.24

type CASCSchemaOption struct {
	RoundTripper http.RoundTripper
}

CASCSchemaOption as the options of reload configuration as code

type CWPOptions added in v0.0.27

type CWPOptions struct {
	CommonOption

	ConfigPath      string
	Version         string
	TmpDir          string
	Environment     string
	BomPath         string
	MvnSettingsFile string

	BatchMode        bool
	Demo             bool
	InstallArtifacts bool

	ShowProgress bool
	MetadataURL  string
	LocalCache   string

	ValueSet map[string]string
}

CWPOptions is the option of custom-war-packager see also https://github.com/jenkinsci/custom-war-packager

func (*CWPOptions) Download added in v0.0.27

func (o *CWPOptions) Download() (err error)

Download get the latest cwp from server into local

func (*CWPOptions) GetCWPURL added in v0.0.27

func (o *CWPOptions) GetCWPURL(version string) string

GetCWPURL returns the download URL of a specific version cwp

func (*CWPOptions) GetLatest added in v0.0.27

func (o *CWPOptions) GetLatest() (version string, err error)

GetLatest returns the latest of cwp

func (*CWPOptions) Run added in v0.0.27

func (o *CWPOptions) Run(cmd *cobra.Command, args []string) (err error)

Run is the main logic of cwp cmd

type CenterDownloadOption added in v0.0.20

type CenterDownloadOption struct {
	LTS     bool
	Mirror  string
	Version string

	Output       string
	ShowProgress bool

	Formula string

	RoundTripper http.RoundTripper
}

CenterDownloadOption as the options of download command

func (*CenterDownloadOption) DownloadJenkins added in v0.0.24

func (c *CenterDownloadOption) DownloadJenkins() (err error)

DownloadJenkins download the Jenkins

type CenterIdentityOption added in v0.0.24

type CenterIdentityOption struct {
	CommonOption
}

CenterIdentityOption option for upgrade Jenkins

type CenterMirrorOption added in v0.0.23

type CenterMirrorOption struct {
	RoundTripper http.RoundTripper

	Enable    bool
	MirrorURL string
}

CenterMirrorOption option for upgrade Jenkins

type CenterOption added in v0.0.18

type CenterOption struct {
	WatchOption

	RoundTripper http.RoundTripper
	CenterStatus string
}

CenterOption is the center cmd option

type CenterStartOption added in v0.0.24

type CenterStartOption struct {
	CommonOption

	Port                      int
	Context                   string
	SetupWizard               bool
	AdminCanGenerateNewTokens bool

	// comes from folder plugin
	ConcurrentIndexing int

	Admin string

	HTTPSEnable      bool
	HTTPSPort        int
	HTTPSCertificate string
	HTTPSPrivateKey  string

	Environments []string
	System       []string

	Download bool
	Version  string
	LTS      bool
	Formula  string

	DryRun bool
}

CenterStartOption option for upgrade Jenkins

type CenterUpgradeOption added in v0.0.20

type CenterUpgradeOption struct {
	RoundTripper http.RoundTripper
}

CenterUpgradeOption option for upgrade Jenkins

type CenterWatchOption added in v0.0.19

type CenterWatchOption struct {
	WatchOption
	UtilNeedRestart     bool
	UtilInstallComplete bool

	RoundTripper  http.RoundTripper
	CeneterStatus string
}

CenterWatchOption as the options of watch command

type CommandHook added in v0.0.24

type CommandHook struct {
	Path    string `yaml:"path"`
	Command string `yaml:"cmd"`
}

CommandHook is a hook

type CommonOption added in v0.0.24

type CommonOption struct {
	ExecContext     util.ExecContext
	SystemCallExec  util.SystemCallExec
	LookPathContext util.LookPathContext
	RoundTripper    http.RoundTripper

	Stdio terminal.Stdio

	// EditFileName allow editor has a better performance base on this
	EditFileName string
}

CommonOption contains the common options

func (*CommonOption) Editor added in v0.0.25

func (o *CommonOption) Editor(defaultContent, message string) (content string, err error)

Editor edit a file than return the content

func (*CommonOption) Select added in v0.0.25

func (o *CommonOption) Select(options []string, message, defaultOpt string) (target string, err error)

Select return a target

type CompletionOptions added in v0.0.25

type CompletionOptions struct {
	Type string
}

CompletionOptions is the option of completion command

type ComputerCreateOption added in v0.0.24

type ComputerCreateOption struct {
	CommonOption
	OutputOption
}

ComputerCreateOption option for config list command

type ComputerDeleteOption added in v0.0.24

type ComputerDeleteOption struct {
	CommonOption
}

ComputerDeleteOption option for agent delete command

type ComputerLaunchOption added in v0.0.24

type ComputerLaunchOption struct {
	CommonOption

	Type         string
	ShowProgress bool

	/** share info between inner functions */
	ComputerClient *client.ComputerClient
	CurrentJenkins *JenkinsServer
	Output         string
}

ComputerLaunchOption option for config list command

func (*ComputerLaunchOption) Launch added in v0.0.24

func (o *ComputerLaunchOption) Launch(name string) (err error)

Launch start a normal agent

func (*ComputerLaunchOption) LaunchJnlp added in v0.0.24

func (o *ComputerLaunchOption) LaunchJnlp(name string) (err error)

LaunchJnlp start a JNLP agent

type ComputerListOption added in v0.0.24

type ComputerListOption struct {
	CommonOption
	OutputOption
}

ComputerListOption option for config list command

type ComputerLogOption added in v0.0.24

type ComputerLogOption struct {
	CommonOption
}

ComputerLogOption option for config list command

type Config

type Config struct {
	Current        string          `yaml:"current"`
	Language       string          `yaml:"language"`
	JenkinsServers []JenkinsServer `yaml:"jenkins_servers"`
	PreHooks       []CommandHook   `yaml:"preHooks"`
	PostHooks      []CommandHook   `yaml:"postHooks"`
	PluginSuites   []PluginSuite   `yaml:"pluginSuites"`
	Mirrors        []JenkinsMirror `yaml:"mirrors"`
}

Config is a global config struct

type ConfigAddOptions added in v0.0.10

type ConfigAddOptions struct {
	JenkinsServer
}

ConfigAddOptions is the config ad option

type ConfigEditOption added in v0.0.25

type ConfigEditOption struct {
	CommonOption
}

ConfigEditOption is the option for edit config command

type ConfigGenerateOption added in v0.0.18

type ConfigGenerateOption struct {
	InteractiveOption
	CommonOption
	BatchOption

	Copy bool
}

ConfigGenerateOption is the config generate cmd option

func (*ConfigGenerateOption) InteractiveWithConfig added in v0.0.25

func (o *ConfigGenerateOption) InteractiveWithConfig(cmd *cobra.Command, data []byte) (err error)

InteractiveWithConfig be friendly for a newer

type ConfigListOption added in v0.0.23

type ConfigListOption struct {
	OutputOption

	Config string
}

ConfigListOption option for config list command

type ConfigOptions added in v0.0.9

type ConfigOptions struct {
	ConfigFileLocation string
}

ConfigOptions is the config cmd option

type ConfigSelectOptions added in v0.0.25

type ConfigSelectOptions struct {
	CommonOption
}

ConfigSelectOptions is the option for select a config

type CredentialCreateOption added in v0.0.24

type CredentialCreateOption struct {
	Description string
	ID          string
	Store       string

	Username string
	Password string

	Secret string

	Scope string
	Type  string

	RoundTripper http.RoundTripper
}

CredentialCreateOption option for credential delete command

type CredentialDeleteOption added in v0.0.24

type CredentialDeleteOption struct {
	BatchOption

	ID    string
	Store string

	RoundTripper http.RoundTripper
}

CredentialDeleteOption option for credential delete command

type CredentialListOption added in v0.0.24

type CredentialListOption struct {
	OutputOption

	Store string

	RoundTripper http.RoundTripper
}

CredentialListOption option for credential list command

type CrumbIssuerOptions

type CrumbIssuerOptions struct {
	RoundTripper http.RoundTripper
}

CrumbIssuerOptions contains the command line options

type EditContent added in v0.0.25

type EditContent interface {
	Editor(defaultContent, message string) (content string, err error)
}

EditContent is the interface for editing content from a file

type FormatOutput added in v0.0.18

type FormatOutput interface {
	Output(obj interface{}, format string) (data []byte, err error)
}

FormatOutput is the interface of format output

type HookOption added in v0.0.20

type HookOption struct {
	SkipPreHook  bool
	SkipPostHook bool
}

HookOption is the option whether skip command hook

type InteractiveOption added in v0.0.18

type InteractiveOption struct {
	Interactive bool
}

InteractiveOption allow user to choose whether the mode is interactive

func (*InteractiveOption) SetFlag added in v0.0.18

func (b *InteractiveOption) SetFlag(cmd *cobra.Command)

SetFlag set the option flag to this cmd

type JenkinsMirror added in v0.0.23

type JenkinsMirror struct {
	Name string
	URL  string
}

JenkinsMirror represents the mirror of Jenkins

type JenkinsServer

type JenkinsServer struct {
	Name               string `yaml:"name"`
	URL                string `yaml:"url"`
	UserName           string `yaml:"username"`
	Token              string `yaml:"token"`
	Proxy              string `yaml:"proxy"`
	ProxyAuth          string `yaml:"proxyAuth"`
	InsecureSkipVerify bool   `yaml:"insecureSkipVerify"`
	Description        string `yaml:"description"`
}

JenkinsServer holds the configuration of your Jenkins

func GetComputerClient added in v0.0.24

func GetComputerClient(option CommonOption) (*client.ComputerClient, *JenkinsServer)

GetComputerClient returns the client of computer

type JobArtifactDownloadOption added in v0.0.21

type JobArtifactDownloadOption struct {
	ID           string
	ShowProgress bool
	DownloadDir  string

	Jenkins      *JenkinsServer
	RoundTripper http.RoundTripper
}

JobArtifactDownloadOption is the options of job artifact download command

type JobArtifactOption added in v0.0.21

type JobArtifactOption struct {
	OutputOption
	CommonOption
}

JobArtifactOption is the options of job artifact command

type JobBuildOption added in v0.0.18

type JobBuildOption struct {
	BatchOption
	CommonOption

	Param      string
	ParamArray []string
}

JobBuildOption is the job build option

type JobCreateOption added in v0.0.18

type JobCreateOption struct {
	Copy string
	Type string

	RoundTripper http.RoundTripper
}

JobCreateOption is the job create option

type JobDeleteOption added in v0.0.18

type JobDeleteOption struct {
	BatchOption
	CommonOption
}

JobDeleteOption is the job delete option

type JobDisableOption added in v0.0.27

type JobDisableOption struct {
	BatchOption
	CommonOption
}

JobDisableOption is the job delete option

type JobEditOption added in v0.0.23

type JobEditOption struct {
	CommonOption

	Filename  string
	Script    string
	URL       string
	Sample    bool
	TrimSpace bool
}

JobEditOption is the option for job create command

type JobEnableOption added in v0.0.27

type JobEnableOption struct {
	BatchOption
	CommonOption
}

JobEnableOption is the job delete option

type JobHistoryOption added in v0.0.18

type JobHistoryOption struct {
	OutputOption

	RoundTripper http.RoundTripper
}

JobHistoryOption is the job history option

type JobInputOption added in v0.0.21

type JobInputOption struct {
	BatchOption

	Action string

	RoundTripper http.RoundTripper
}

JobInputOption is the job delete option

type JobLogOption added in v0.0.10

type JobLogOption struct {
	WatchOption
	History int

	LogText      string
	LastBuildID  int
	LastBuildURL string

	RoundTripper http.RoundTripper
}

JobLogOption is the job log option

type JobOption added in v0.0.10

type JobOption struct {
	OutputOption
}

JobOption is the job cmd option

type JobParamOption added in v0.0.18

type JobParamOption struct {
	OutputOption

	Indent bool

	RoundTripper http.RoundTripper
}

JobParamOption is the job param option

type JobSearchOption added in v0.0.10

type JobSearchOption struct {
	CommonOption
	OutputOption
	Name   string
	Type   string
	Parent string

	Start int
	Limit int
}

JobSearchOption is the options of job search command

func (*JobSearchOption) Check added in v0.0.24

func (o *JobSearchOption) Check() (err error)

Check do the conditions check

type JobStopOption added in v0.0.18

type JobStopOption struct {
	BatchOption
	CommonOption
}

JobStopOption is the job stop option

type JobTypeOption added in v0.0.18

type JobTypeOption struct {
	OutputOption
	CommonOption
}

JobTypeOption is the job type cmd option

type MavenMetadata added in v0.0.27

type MavenMetadata struct {
	XMLName    xml.Name        `xml:"metadata"`
	Versioning MavenVersioning `xml:"versioning"`
}

MavenMetadata is the maven metadata xml root

type MavenVersioning added in v0.0.27

type MavenVersioning struct {
	XMLName xml.Name `xml:"versioning"`
	Latest  string   `xml:"latest"`
	Release string   `xml:"release"`
}

MavenVersioning is the versioning of maven

type MsgConfirm added in v0.0.25

type MsgConfirm interface {
	Confirm(message string) bool
}

MsgConfirm is the interface for confirming a message

type OpenOption added in v0.0.10

type OpenOption struct {
	CommonOption
	InteractiveOption

	Config bool
}

OpenOption is the open cmd option

type OutputOption added in v0.0.9

type OutputOption struct {
	Format string

	Columns        string
	WithoutHeaders bool
	Filter         []string

	Writer        io.Writer
	CellRenderMap map[string]RenderCell
}

OutputOption represent the format of output

func (*OutputOption) GetLine added in v0.0.24

func (o *OutputOption) GetLine(obj reflect.Value) []string

GetLine returns the line of a table

func (*OutputOption) ListFilter added in v0.0.24

func (o *OutputOption) ListFilter(obj interface{}) interface{}

ListFilter filter the data list by fields

func (*OutputOption) Match added in v0.0.24

func (o *OutputOption) Match(item reflect.Value) bool

Match filter an item

func (*OutputOption) Output added in v0.0.18

func (o *OutputOption) Output(obj interface{}) (data []byte, err error)

Output print the object into byte array Deprecated see also OutputV2

func (*OutputOption) OutputV2 added in v0.0.24

func (o *OutputOption) OutputV2(obj interface{}) (err error)

OutputV2 print the data line by line

func (*OutputOption) SetFlag added in v0.0.18

func (o *OutputOption) SetFlag(cmd *cobra.Command)

SetFlag set flag of output format Deprecated, see also SetFlagWithHeaders

func (*OutputOption) SetFlagWithHeaders added in v0.0.24

func (o *OutputOption) SetFlagWithHeaders(cmd *cobra.Command, headers string)

SetFlagWithHeaders set the flags of output

type PluginBuildOptions added in v0.0.27

type PluginBuildOptions struct {
	CommonOption

	DebugOutput bool
}

PluginBuildOptions for the plugin build command

type PluginCheckoutOption added in v0.0.23

type PluginCheckoutOption struct {
	RoundTripper http.RoundTripper
}

PluginCheckoutOption is the option for plugin checkout command

type PluginCreateOptions added in v0.0.23

type PluginCreateOptions struct {
	CommonOption

	DebugOutput bool
}

PluginCreateOptions for the plugin create command

type PluginDownloadOption added in v0.0.23

type PluginDownloadOption struct {
	SkipDependency bool
	SkipOptional   bool
	UseMirror      bool
	ShowProgress   bool

	RoundTripper http.RoundTripper
}

PluginDownloadOption is the option for plugin download command

type PluginInstallOption added in v0.0.23

type PluginInstallOption struct {
	UseMirror    bool
	ShowProgress bool

	RoundTripper http.RoundTripper
}

PluginInstallOption is the option for plugin install

type PluginListOption added in v0.0.18

type PluginListOption struct {
	OutputOption

	RoundTripper http.RoundTripper
}

PluginListOption option for plugin list command

type PluginOpenOption added in v0.0.24

type PluginOpenOption struct {
	ExecContext util.ExecContext
}

PluginOpenOption is the option of plugin open cmd

type PluginOptions

type PluginOptions struct {
	CommonOption

	Suite string
}

PluginOptions contains the command line options

func (*PluginOptions) FindPlugin added in v0.0.24

func (o *PluginOptions) FindPlugin(name string) (plugin *client.InstalledPlugin, err error)

FindPlugin find a plugin by name

type PluginReleaseOptions added in v0.0.24

type PluginReleaseOptions struct {
	CommonOption

	Batch       bool
	Prepare     bool
	Perform     bool
	SkipTests   bool
	DebugOutput bool
}

PluginReleaseOptions for the plugin create command

type PluginSearchOption added in v0.0.18

type PluginSearchOption struct {
	OutputOption

	RoundTripper http.RoundTripper
}

PluginSearchOption is the plugin search option

func (*PluginSearchOption) Output added in v0.0.18

func (o *PluginSearchOption) Output(obj interface{}) (data []byte, err error)

Output output the data into buffer

type PluginSuite added in v0.0.19

type PluginSuite struct {
	Name        string   `yaml:"name"`
	Plugins     []string `yaml:"plugins"`
	Description string   `yaml:"description"`
}

PluginSuite define a suite of plugins

type PluginTreadOption added in v0.0.21

type PluginTreadOption struct {
	RoundTripper http.RoundTripper
}

PluginTreadOption is the option of plugin trend command

type PluginUninstallOption added in v0.0.20

type PluginUninstallOption struct {
	RoundTripper http.RoundTripper
}

PluginUninstallOption the option of uninstall a plugin

type PluginUpgradeOption added in v0.0.20

type PluginUpgradeOption struct {
	Filter []string
	All    bool

	RoundTripper http.RoundTripper
}

PluginUpgradeOption option for plugin list command

type PluginUploadOption added in v0.0.18

type PluginUploadOption struct {
	Remote         string
	RemoteUser     string
	RemotePassword string
	RemoteJenkins  string
	ShowProgress   bool

	RoundTripper http.RoundTripper

	HookOption
	// contains filtered or unexported fields
}

PluginUploadOption will hold the options of plugin cmd

type QueueCancelOption added in v0.0.20

type QueueCancelOption struct {
	RoundTripper http.RoundTripper
}

QueueCancelOption represents the option of queue cancel command

type QueueListOption added in v0.0.20

type QueueListOption struct {
	OutputOption

	RoundTripper http.RoundTripper
}

QueueListOption represents the option of queue list command

type RenderCell added in v0.0.24

type RenderCell = func(string) string

RenderCell render a specific cell in a table

type RestartOption added in v0.0.18

type RestartOption struct {
	BatchOption
	CommonOption

	Safe bool
}

RestartOption holds the options for restart cmd

type RootOptions added in v0.0.9

type RootOptions struct {
	ConfigFile string
	Jenkins    string
	Debug      bool

	URL                string
	Username           string
	Token              string
	InsecureSkipVerify bool
	Proxy              string
	ProxyAuth          string

	Doctor bool

	LoggerLevel string
}

RootOptions is a global option for whole cli

func (*RootOptions) RunDiagnose added in v0.0.24

func (o *RootOptions) RunDiagnose(cmd *cobra.Command) (err error)

RunDiagnose run the diagnose for a specific command

type Selector added in v0.0.25

type Selector interface {
	Select(options []string, message, defaultOpt string) (target string, err error)
}

Selector is the interface for selecting an option

type ShellOptions added in v0.0.24

type ShellOptions struct {
	CommonOption

	TmpDir            string
	TmpConfigFileName string
}

ShellOptions is the option of shell command

type UserCreateOption added in v0.0.18

type UserCreateOption struct {
	RoundTripper http.RoundTripper
}

UserCreateOption is user create cmd option

type UserDeleteOption added in v0.0.18

type UserDeleteOption struct {
	BatchOption

	RoundTripper http.RoundTripper
}

UserDeleteOption is user delete cmd option

type UserEditOption added in v0.0.18

type UserEditOption struct {
	CommonOption

	Description string
}

UserEditOption is the user edit cmd option

type UserOption added in v0.0.18

type UserOption struct {
	OutputOption

	RoundTripper http.RoundTripper
}

UserOption is the user cmd option

type UserTokenOption added in v0.0.18

type UserTokenOption struct {
	Generate   bool
	Name       string
	TargetUser string

	RoundTripper http.RoundTripper
}

UserTokenOption represents a user token cmd option

type VersionOption added in v0.0.26

type VersionOption struct {
	Changelog  bool
	ShowLatest bool

	GitHubClient *github.Client
}

VersionOption is the version option

type WatchOption added in v0.0.18

type WatchOption struct {
	Watch    bool
	Interval int
	Count    int
}

WatchOption for the resources which can be watched

func (*WatchOption) SetFlag added in v0.0.20

func (o *WatchOption) SetFlag(cmd *cobra.Command)

SetFlag for WatchOption

Jump to

Keyboard shortcuts

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