Documentation ¶
Index ¶
- Variables
- func AskUserQuestion(question string, osTarget string) (bool, error)
- func Cd(dir string)
- func CpFile(src string, dst string)
- func CreateFolders(folders []string) bool
- func File2lines(filePath string) ([]string, error)
- func FileExists(fileLoc string) bool
- func FindFile(fileName string, dirs []string) (bool, string)
- func FindFiles(locations []string, extensionList []string, fileNames []string, ...) ([]string, []string)
- func GetFileAndDirList(searchDirs []string) ([]string, []string)
- func GetHostname() string
- func GetLocalIP() (string, error)
- func GrepFile(filePath string, regex *regexp.Regexp) []string
- func InsertStringToFile(path, str string, index int) error
- func LinesFromReader(r io.Reader) ([]string, error)
- func RemoveTracker(filePath string, osTarget string, destroy bool)
- func ReplLineInFile(filePath string, delim string, replStr string) (bool, string)
- func SliceUniqMap(s []string) []string
- func StartServer(port int, webDir string, ssl bool, cert string, key string, ...) *http.Server
- func StringInSlice(a string, list []string) bool
- func TarFiles(files []string, tarLocation string)
- func TrackChanges(filePath string, content string) (bool, error)
- type CliArgs
- type Settings
- type UserInput
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMsg outputs red text to signify an error ErrMsg = color.Red // Info outputs yellow text to signify an informational message Info = color.Yellow // Msg outputs green text to signify success Msg = color.Green )
var ( // Cli contains input from the command line Cli CliArgs // JSONSettings contains settings that are specified in settings.json JSONSettings Settings )
Functions ¶
func AskUserQuestion ¶
AskUserQuestion takes a question from a user and returns true or false based on the input. The operating system must be specified as an input in order to handle the line ending properly; Windows uses a different line ending scheme than Unix systems Loosely based on https://tutorialedge.net/golang/reading-console-input-golang/
func CreateFolders ¶
CreateFolders creates folders specified in an input slice (folders) It returns true if it is able to create all of the folders Otherwise it returns false
func File2lines ¶
File2lines returns a slice that contains all of the lines of the file specified with filePath Resource: https://siongui.github.io/2017/01/30/go-insert-line-or-string-to-file/
func FileExists ¶
FileExists returns true if a file input (fileLoc) exists on the filesystem Otherwise it returns false
func FindFile ¶
FindFile locates a file (fileName) in a list of input directories (dir) If the file is found, then it returns true along with the file location Otherwise it returns false with an empty string
func FindFiles ¶
func FindFiles(locations []string, extensionList []string, fileNames []string, dirNames []string, debug bool) ([]string, []string)
FindFiles finds based on their file extension in specified directories locations: slice with locations to search for files extensionList: slice with file extensions to check for fileNames: slice with filenames to search for Returns files found that meet the input criteria
func GetFileAndDirList ¶
GetFileAndDirList gets all of the files and directories specified the initial search location (searchDirs) It returns a list of files and a list of directories found
func GetLocalIP ¶
GetLocalIP returns the IP address of the local system
func GrepFile ¶
GrepFile looks for patterns in a file (filePath) using an input regex (regex) It will return any matches that are found in the file in a slice
func InsertStringToFile ¶
InsertStringToFile with insert a string (str) into the n-th line (index) of a specified file (path) Resource: https://siongui.github.io/2017/01/30/go-insert-line-or-string-to-file/
func LinesFromReader ¶
LinesFromReader will return the lines read from a reader Resource: https://siongui.github.io/2017/01/30/go-insert-line-or-string-to-file/
func RemoveTracker ¶
RemoveTracker removes a file created with TrackChanges
func ReplLineInFile ¶
ReplLineInFile will replace a line in a file (filePath) with the specified replStr and delimiter (delim) It will return true with the path to the file if successful Otherwise it will return false and an empty string
func SliceUniqMap ¶
SliceUniqMap is an idiomatic way to remove duplicates in a slice Resource: https://www.reddit.com/r/golang/comments/5ia523/idiomatic_way_to_remove_duplicates_in_a_slice/
func StartServer ¶
func StartServer(port int, webDir string, ssl bool, cert string, key string, waitTime time.Duration, singleServe bool) *http.Server
StartServer stands up a web server that can be used to serve files
func StringInSlice ¶
StringInSlice can be used to determine if a string exists in a slice
Types ¶
type CliArgs ¶
type CliArgs struct { OSArch string Cmd string Debug bool ExfilPort int FilePath string FileUpload string LocalIP string PayloadName string OSTarget string WebSrvPort int RemoteUploadFilePath string SettingsPath string ServeSSL bool CMTarget string TimeToServe int Rhost string }
CliArgs holds command line arguments specified through user input
func ParseCLIArgs ¶
func ParseCLIArgs() CliArgs
ParseCLIArgs parses all specified command line arguments
type Settings ¶
type Settings struct { AnsibleBackupLoc string ChefClientKey string ChefNodeName string ChefValidationKey string CleanupFile string ContainerName string ImageName string PuppetBackupLoc string RemoteHost string SSLCertPath string SSLKeyPath string SaltBackupLoc string TargetChefServer string TargetOrgName string TargetValidatorName string UploadFilePath string }
Settings represents the configuration information found in settings.json
type UserInput ¶
type UserInput struct { // CLI OSArch string Cmd string Debug bool ExfilPort int FilePath string FileUpload string LocalIP string PayloadName string NoServe bool OSTarget string WebSrvPort int RemoteUploadFilePath string Rhost string SettingsPath string ServeSSL bool CMTarget string TimeToServe int // Settings AnsibleBackupLoc string ChefClientKey string ChefNodeName string ChefValidationKey string CleanupFile string ContainerName string ImageName string PuppetBackupLoc string RemoteHost string SaltBackupLoc string SSLCertPath string SSLKeyPath string TargetChefServer string TargetOrgName string TargetValidatorName string UploadFilePath string }
UserInput holds all values from command line arguments and the settings.json This is a necessity resulting from templates needing to take values from a single struct, and MOSE taking user input from multiple sources
func GetUserInput ¶
func GetUserInput() UserInput
GetUserInput returns all user input parameters specified through command line arguments and the settings.json file