commandhelper

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AcctRepoHelp = `` /* 196-byte string literal not displayed */

)

Variables

View Source
var (
	// inject with -X github.com/shankj3/ocelot/client/commandhelper.AdminHost=my.ocelotadmin.com -X github.com/shankj3/ocelot/client/commandhelper.AdminPort=443
	AdminHost = "localhost"
	AdminPort = "10000"
)

Functions

func BlockingDial

func BlockingDial(ctx context.Context, network, address string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error)

BlockingDial is a helper method to dial the given address, using optional TLS credentials, and blocking until the returned connection is ready. If the given credentials are nil, the connection will be insecure (plain-text).

func CheckConnection

func CheckConnection(cmd GuideOcelotCmd, ctx context.Context) error

CheckConnection calls the CheckConn() method of GuideOcelotClient which is validates a connection exists. if the connection fails, an error will be printed to the UI and the grpc err will be returned (so you can exit 1 on the command line)

func CreateBuildClient added in v0.8.0

func CreateBuildClient(m *pb.BuildRuntimeInfo) (pb.BuildClient, error)

CreateBuildClient dials the grpc server at the werker endpoints

func Debuggit

func Debuggit(ui cli.Ui, msg string)

Debuggit will write given message to WARN of a1 GuideOcelotCmd if there is an environment varible "$DEBUGGIT" maybe make it a flag later, not really worried about the performance of all the lookups though since its for debugging

func FindAcctRepo

func FindAcctRepo() (acctRepo string, credType pb.SubCredType, err error)

FindAcctRepo will attempt to run a git command and parse out the acct/repo from it.

func FindCurrentHash

func FindCurrentHash() string

FindCurrentHash will attempt to grab a hash based on running git commands - see client/output/output.go for usage

func GetClient

func GetClient(serverAddr string, noUseBlockingDial bool, tlsDns string) (client models.GuideOcelotClient, err error)

func IsIPv4Address

func IsIPv4Address(host string) bool

func PrettifyTime

func PrettifyTime(timeInSecs float64, queued bool) string

prettifyTime takes in time in seconds and returns a pretty string representation of it

func PrintStatusOverview

func PrintStatusOverview(color *Color, acctName, repoName, hash, status string, theme *ColorDefs) string

func SelectFromHashes

func SelectFromHashes(build *models.Builds, theme *ColorDefs) string

SelectFromHashes will draw a table that can be displayed if there's multiple matching hashes +------------------------------------------+----------------------------+-------------------+ | HASH | REPO | ACCOUNT NAME | +------------------------------------------+----------------------------+-------------------+ | ee | --- | --- | | ec8ea5f46cdd198c135c1ba73984ac6d6192cc16 | orchestr8-locationservices | level11consulting | +------------------------------------------+----------------------------+-------------------+ It takes in ocelot server's BuildRuntime response

func UIErrFromGrpc

func UIErrFromGrpc(err error, ui cli.Ui, defaultMsg string)

UIErrFromGrpc will attempt to use grpc status package to parse out message from rpc err. if it is unable, it will use the default message and attach the err.Error() text separated by a newline

func UploadSSHKeyFile

func UploadSSHKeyFile(ctx context.Context, ui cli.Ui, oceClient models.GuideOcelotClient, acctName string, buildType models.SubCredType, sshKeyPath string) int

UploadSSHKeyFile will upload the ssh key for a vcs account. This is used by buildcredsadd.go and cred's add.go

Types

type ClientConfig

type ClientConfig struct {
	AdminLocation string
	Client        models.GuideOcelotClient
	OcyDns        string
	Theme         *ColorDefs
}
var Config *ClientConfig

func NewClientConfig

func NewClientConfig() *ClientConfig

func NewTestClientConfig

func NewTestClientConfig(logLines []string) *ClientConfig

type Color

type Color struct {
	*color.Color
}

func PrintStatusStages

func PrintStatusStages(statuses *models.Status, wide bool, theme *ColorDefs) (string, *Color, string)

PrintStatusTable is used in printing out status-es such like this:

mariannefeng/test-ocelot 496b3e3a9b8b6f773a4562a50bb30863471e2adf PASS

setup in 3 seconds
build in 17 seconds

it takes in a boolean argument indicating whether or not the build is running, and a protobuf Status object. It returns a PASS/FAIL/Running status string, a color corresponding with that status, and the string representation of stages, stage messages, and errors if exists

type ColorDefs

type ColorDefs struct {
	Failed           *Color
	Queued           *Color
	Passed           *Color
	Done             *Color
	Running          *Color
	Normal           *Color
	Info             *Color
	Error            *Color
	Warning          *Color
	Status           *Color
	TableHeaderColor *Color
	NoColor          bool
}

func Default

func Default(noColor bool) *ColorDefs

type DontOverwrite

type DontOverwrite struct {
}

func (*DontOverwrite) Error

func (d *DontOverwrite) Error() string

type GuideOcelotCmd

type GuideOcelotCmd interface {
	GetClient() models.GuideOcelotClient
	GetUI() cli.Ui
	GetConfig() *ClientConfig
}

type GuideOcelotCmdStdin

type GuideOcelotCmdStdin interface {
	GuideOcelotCmd
	GetDataFromUiAsk(ui cli.Ui) (interface{}, error)
}

type OcyHelper

type OcyHelper struct {
	Hash       string
	AcctRepo   string
	Repo       string
	Account    string
	VcsTypeStr string
	VcsType    protobuf.SubCredType
	SuppressUI bool
}

This gets embedded inside of ocelot clients and performs helper functions common across all clients. All the helper functions will print things in the UI. Good rule of thumb is if it doesn't print things, then it doesn't take cli.Ui as a param.

func (*OcyHelper) DetectAcctRepo

func (oh *OcyHelper) DetectAcctRepo(ui cli.Ui) error

DetectAcctRepo will find the git remote origin of the repository in the current directory if it exists. It will then use regex to determine what the account and repository names are. The happy path of DetectAcctRepo will end in OcyHelper's AcctRepo field being set. If an error occurs, a user-friendly error will be written to the client UI and the original error will be returned.

func (*OcyHelper) DetectHash

func (oh *OcyHelper) DetectHash(ui cli.Ui) error

func (*OcyHelper) DetectOrConvertVcsType added in v0.8.0

func (oh *OcyHelper) DetectOrConvertVcsType(ui cli.Ui) error

DetectOrConvertVcsType will find the git remote origin of the repository in the current directory if it exists. It will then use regex to determine if the repo is either github or bitbucket. If the VcsTypeStr field is already set, then DetectOrConvertVcsType will attempt to convert it to the SubCredType type. If this fails, then an error will be pretty printed to screen. The happy path of DetectOrConvertVcsType will end in OcyHelper's VcsType field being set. If an error occurs, a user-friendly error will be written to the client UI and the original error will be returned.

func (*OcyHelper) DetectRepo

func (oh *OcyHelper) DetectRepo(ui cli.Ui) error

func (*OcyHelper) HandleStreaming

func (oh *OcyHelper) HandleStreaming(ui cli.Ui, stream grpc.ClientStream) error

handles streaming for grpc clients, ***THIS ASSUMES THAT THE STREAMING SERVER HAS A FIELD CALLED OUTPUTLINE****

func (*OcyHelper) LastFewSummariesErr

func (oh *OcyHelper) LastFewSummariesErr(erro error, ui cli.Ui)

func (*OcyHelper) SetGitHelperFlags added in v0.8.0

func (oh *OcyHelper) SetGitHelperFlags(flagger models.Flagger)

func (*OcyHelper) SplitAndSetAcctRepo

func (oh *OcyHelper) SplitAndSetAcctRepo(ui cli.Ui) (err error)

SplitAndSetAcctRepo will split up the AcctRepo field, and write an error to ui if it doesnt meet spec

func (*OcyHelper) WriteUi

func (oh *OcyHelper) WriteUi(writer func(string), msg string)

type SprintfFunc

type SprintfFunc func(format string, a ...interface{}) string

Jump to

Keyboard shortcuts

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