helpers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxBools

func MaxBools(one, two bool) bool

MaxBools takes two bools and returns the max "truthiness". I.E. if bool1 is false and bool2 is true, return true. The only time this function returns false is when both bools are false.

func ModSlugToString

func ModSlugToString(mod string) (string, error)

ModSlugToString converts a module slug "<org>-<module>" to a string "<org>/<module>"

func ModStringToSlug

func ModStringToSlug(mod string) (string, error)

ModStringToSlug converts a module string "<org>/<module> to a slug "<org>-<module>".

func NewFile

func NewFile(path *string, content string) error

NewFile writes given data to a new file at the given path. The function should only be used for creating new files as it does not care if there is a file at the target path already and will not attempt to recover the original file in the event that an error occurs during the write process.

func OverwriteFile

func OverwriteFile(path string, data string) error

OverwriteFile writes given data to the given file that exists already. The function attempts to recover the original file if an error occurs during the write process.

func Parse

func Parse(target string, opts ParseOptions) (*ast.Puppetfile, error)

Parse parses a Puppetfile from either a Git source or a file on disk

func ParseFile

func ParseFile(path string) (*ast.Puppetfile, error)

ParseFile reads a file and parses it using the Puppetfile AST

func PromptConfirmFile

func PromptConfirmFile(path, data string, confirm bool) error

PromptConfirmFile is used with the out-file or write-in-place flags and wraps appropriate user confirmation prompts. If confirm is true, the user prompts are bypassed.

func PromptForInput

func PromptForInput(prompt string) string

PromptForInput prompts a user to enter input in the terminal and returns their input as a string

func PromptNew

func PromptNew(path, data string, confirm bool) error

PromptNew is a wrapper for the OutFile function that gives the user a confirmation prompt before writing.

func PromptOverwrite

func PromptOverwrite(path, data string, confirm bool) error

PromptOverwrite is a wrapper for the WriteInPlace function that gives the user a confirmation prompt before writing.

func ValidatePath

func ValidatePath(path string) error

ValidatePath checks that the file at the given path is a regular file

Types

type ParseOptions

type ParseOptions struct {
	Verbose  bool
	GitRef   string
	SSHKey   string
	Username string
	Password string
	Token    string
}

ParseOptions holds options related to parsing Puppetfiles Specifically, these options are used for parsing Puppetfiles from Git sources.

Jump to

Keyboard shortcuts

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