util

package
v0.0.0-...-b698297 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientOptionsDescription = `` /* 1572-byte string literal not displayed */

)
View Source
const (
	ConfigDescription = `

Configuration file for Jenkins Client Launcher (JCL)
`
)
View Source
const (
	JavaOptionsDescription = `` /* 747-byte string literal not displayed */

)
View Source
const (
	JenkinsConnectionDescription = `` /* 834-byte string literal not displayed */

)
View Source
const (
	MaintenanceDescription = `` /* 1561-byte string literal not displayed */

)
View Source
const (
	SSHServerDescription = `
<sshServer>
  Configures the server port of the SSH server (only for run mode 'ssh-server')
</sshServer>
`
)

Variables

View Source
var ClientJar = ""

Points to the absolute path of the Jenkins client jar.

View Source
var Java = ""

Points to the absolute path of the Java executable.

View Source
var JavaArgs = []string{}

Contains additional java args that are added before the configured java args.

View Source
var JnlpArgs = make(map[string]string)

Contains additional arguments that must be injected into the JNLP config file that is downloaded from Jenkins.

View Source
var NodeIsIdle = NewAtomicBoolean()

Is updated by the server monitor with the current node state (IDLE means no build is running). Note: When server side monitoring is disable the node will ALWAYS appear as idle.

View Source
var OutputMutex = &sync.Mutex{}

Functions

func FlatOut

func FlatOut(message string, a ...interface{})

Prints a message to the app's console output with optional Printf styled substitutions and without a JCL prefix.

func GOut

func GOut(group string, message string, a ...interface{})

Prints a message to the app's console output with optional Printf styled substitutions. "group" is used to group messages of the same kind.

func GetFileLastTouched

func GetFileLastTouched(info os.FileInfo) (lastTouched time.Time)

func Hostname

func Hostname() (name string, err error)

Alias to "os.Hostname()".

func Out

func Out(message string, a ...interface{})

Prints a message to the app's console output with optional Printf styled substitutions.

func PrintAllStackTraces

func PrintAllStackTraces()

Prints stack traces of all go routines.

Types

type AnyConfigAcceptor

type AnyConfigAcceptor struct {
}

Helper to use by types that accept any config but require an implementation of ConfigVerifier.

func (*AnyConfigAcceptor) IsConfigAcceptable

func (_ *AnyConfigAcceptor) IsConfigAcceptable(config *Config) bool

type AtomicBoolean

type AtomicBoolean struct {
	// contains filtered or unexported fields
}

Thread save boolean value.

func NewAtomicBoolean

func NewAtomicBoolean() *AtomicBoolean

func (*AtomicBoolean) Get

func (self *AtomicBoolean) Get() bool

func (*AtomicBoolean) Set

func (self *AtomicBoolean) Set(value bool)

type AtomicInt32

type AtomicInt32 struct {
	// contains filtered or unexported fields
}

Thread save boolean value.

func NewAtomicInt32

func NewAtomicInt32() *AtomicInt32

func (*AtomicInt32) AddAndGet

func (self *AtomicInt32) AddAndGet(delta int32) int32

func (*AtomicInt32) Get

func (self *AtomicInt32) Get() int32

func (*AtomicInt32) Set

func (self *AtomicInt32) Set(value int32)

type CleanupSettings

type CleanupSettings struct {
	Enabled       bool     `xml:"enabled"`
	Location      string   `xml:"location"`
	OnlyWhenIDLE  bool     `xml:"onlyWhenIdle"`
	IntervalHours int64    `xml:"interval>hours"`
	TTLHours      int64    `xml:"ttl>hours"`
	Mode          string   `xml:"ttl>mode"`
	Exclusions    []string `xml:"exclusions>exclusion"`
}

type ClientOptions

type ClientOptions struct {
	ClientName                            string `xml:"client>name"`
	SecretKey                             string `xml:"client>secretKey"`
	PassCIAuth                            bool   `xml:"client>passAuth"`
	CreateClientIfMissing                 bool   `xml:"client>createIfMissing"`
	ClientMonitorStateOnServer            bool   `xml:"client>monitoring>stateOnServer>enabled"`
	ClientMonitorStateOnServerMaxFailures int16  `xml:"client>monitoring>stateOnServer>maxFailures"`
	ClientMonitorConsole                  bool   `xml:"client>monitoring>console>enabled"`
	HandleReconnectsInLauncher            bool   `xml:"client>restart>handleReconnects"`
	SleepTimeSecondsBetweenFailures       int64  `xml:"client>restart>sleepOnFailure>seconds"`
	PeriodicClientRestartEnabled          bool   `xml:"client>restart>periodic>enabled"`
	PeriodicClientRestartOnlyWhenIDLE     bool   `xml:"client>restart>periodic>onlyWhenIdle"`
	PeriodicClientRestartIntervalHours    int64  `xml:"client>restart>periodic>interval>hours"`
	OutOfMemoryRestartEnabled             bool   `xml:"client>restart>outOfMemory>enabled"`
	OutOfMemoryRestartOnlyWhenIDLE        bool   `xml:"client>restart>outOfMemory>onlyWhenIdle"`
}

type Config

type Config struct {
	XMLName           xml.Name `xml:"config"`
	RunMode           string   `xml:"runMode,attr"`
	Autostart         bool     `xml:"autostart,attr"`
	ConfigDescription string   `xml:",comment"`

	NeedsSave bool `xml:"-"`

	JenkinsConnection
	ClientOptions
	JavaOptions
	SSHServer
	ConsoleMonitor
	Maintenance
}

func NewConfig

func NewConfig(fileName string) *Config

Returns a new instance that is initialized from the specified file. If the file cannot be loaded the returned config will be similar to what NewDefaultConfig() returns.

func NewDefaultConfig

func NewDefaultConfig() *Config

Returns a new instance of config with default values.

func (*Config) Save

func (self *Config) Save(fileName string)

Saves the config to the specified file.

func (*Config) String

func (self *Config) String() string

Converts the config to a XML string.

type ConfigVerifier

type ConfigVerifier interface {
	// Returns true if the configuration is acceptable, false otherwise.
	IsConfigAcceptable(config *Config) bool
}

Implemented by types that verify if the configuration is valid for them.

type ConsoleMonitor

type ConsoleMonitor struct {
	RestartTriggerTokens []string `xml:"console>errorTokens>token"`
}

Allows to configure console monitoring.

func (*ConsoleMonitor) IsRestartTriggered

func (self *ConsoleMonitor) IsRestartTriggered(line string) bool

Returns true if the given line contains a restart trigger token.

type JavaOptions

type JavaOptions struct {
	JavaArgs                       []string `xml:"java>args>arg"`
	JavaMaxMemory                  string   `xml:"java>maxMemory"`
	ForceFullGC                    bool     `xml:"java>forceFullGC>enabled"`
	ForceFullGCIntervalMinutes     int64    `xml:"java>forceFullGC>interval>minutes"`
	ForceFullGCIDLEIntervalMinutes int64    `xml:"java>forceFullGC>idleInterval>minutes"`
}

type JenkinsConnection

type JenkinsConnection struct {
	CIHostURI              string `xml:"ci>url"`
	CIAcceptAnyCert        bool   `xml:"ci>noCertificateCheck"`
	CIUsername             string `xml:"ci>auth>user"`
	CIPassword             string `xml:"ci>auth>password"`
	CITunnelSSHEnabled     bool   `xml:"ci>tunnel>jnlp>ssh>enabled"`
	CITunnelSSHAddress     string `xml:"ci>tunnel>jnlp>ssh>address"`
	CITunnelSSHPort        uint16 `xml:"ci>tunnel>jnlp>ssh>port"`
	CITunnelSSHFingerprint string `xml:"ci>tunnel>jnlp>ssh>fingerprint"`
	CITunnelSSHUsername    string `xml:"ci>tunnel>jnlp>ssh>auth>user"`
	CITunnelSSHPassword    string `xml:"ci>tunnel>jnlp>ssh>auth>password"`
	// contains filtered or unexported fields
}

func (*JenkinsConnection) CIClient

func (self *JenkinsConnection) CIClient() *http.Client

Returns a HTTP client that is configured to connect with Jenkins.

func (*JenkinsConnection) CIGet

func (self *JenkinsConnection) CIGet(path string) (response *http.Response, err error)

Issues a HTTP-GET request on Jenkins using the specified request path (= path + query string).

func (*JenkinsConnection) CIRequest

func (self *JenkinsConnection) CIRequest(method, path string, body io.Reader) (request *http.Request, err error)

Returns a request object which may be used with CIClient to do a HTTP request.

func (*JenkinsConnection) HasCIConnection

func (self *JenkinsConnection) HasCIConnection() bool

Returns true if the configuration has a Jenkins url.

type Maintenance

type Maintenance struct {
	CleanupSettingsList []CleanupSettings `xml:"maintenance>cleanup"`
}

type SSHServer

type SSHServer struct {
	SSHListenAddress string `xml:"sshServer>address"`
	SSHListenPort    uint16 `xml:"sshServer>port"`
	SSHUsername      string `xml:"sshServer>auth>user"`
	SSHPassword      string `xml:"sshServer>auth>password"`
}

Jump to

Keyboard shortcuts

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