utils

package
v0.0.0-...-551b004 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppPath string

AppPath contains the app path of the env

View Source
var GoPath string

GoPath contains the gopath of the env

View Source
var Log = logrus.New()

Log creates a new logrus instance that can be exported and used throughout the project

View Source
var LogFile string

LogFile contains the fully qualified log file location

View Source
var LogPath string

LogPath contains the path to store the logs

View Source
var ReleaseVersion string

ReleaseVersion contains the git tag version

Functions

func ArchiveLogFile

func ArchiveLogFile() error

ArchiveLogFile creates a backup of the current log in the logs directory, creates a new log file, and writes to the new log

func ClearLogFile

func ClearLogFile() error

ClearLogFile empties the log file

func GetAppBranch

func GetAppBranch() (string, error)

GetAppBranch returns the current branch name

func GetAppSHA

func GetAppSHA() (string, error)

GetAppSHA returns the current SHA location

func GetBaseSHA

func GetBaseSHA() (string, error)

GetBaseSHA returns the current base SHA location http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git

func GetRemoteBranchSHA

func GetRemoteBranchSHA(branch string) (string, error)

GetRemoteBranchSHA returns the commit SHA of the remote branch from github

func GetTag

func GetTag() (string, error)

GetTag returns the current tag https://git-scm.com/book/en/v2/Git-Basics-Tagging

func IsAppUpToDate

func IsAppUpToDate() (bool, error)

IsAppUpToDate checks to see if the local status of the git tree is up to date with the remote

func RemoteUpdate

func RemoteUpdate() error

RemoteUpdate updates with origin

func Round

func Round(f float64) int

Round rounds the float to the nearest int

func StatToSeconds

func StatToSeconds(stat string) (float64, error)

StatToSeconds takes in a beego stat param (e.g 20.40us or 15.20ms) and returns the time in seconds

func TimeAgo

func TimeAgo(passedTime time.Time) string

TimeAgo returns the rounded form of amount of time elapsed between now and the passed time

func ToggleDebug

func ToggleDebug()

ToggleDebug toggles the debug level on or off depending on the current state

func UpdateApp

func UpdateApp() (bool, error)

UpdateApp stops the current instance of the app, updates to the latest sha on the branch, and restarts the app

Types

type LogEntry

type LogEntry struct {
	Level   string    `json:"level"`
	Message string    `json:"msg"`
	Time    time.Time `json:"time"`
}

LogEntry contains information unmarshalled from logrus that was logged to a file {"level":"error","msg":"Test","time":"2016-04-10T12:05:30-04:00"}

func ParseLogFile

func ParseLogFile() []LogEntry

ParseLogFile parses the locally stored flat log file that was logged to by logrus

type Ref

type Ref struct {
	Object struct {
		Sha  string `json:"sha"`
		Type string `json:"type"`
		URL  string `json:"url"`
	} `json:"object"`
	Ref string `json:"ref"`
	URL string `json:"url"`
}

Ref contains the response from the github ref request

Jump to

Keyboard shortcuts

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