utils

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: EPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile added in v0.14.0

func CopyFile(sourceFilePath, targetFilePath string) error

CopyFile - copies the contents of the source file to a target file

func CreateTempFile

func CreateTempFile(filePath string) error

CreateTempFile in the same directory as the binary for docker compose

func CreateTimestamp

func CreateTimestamp() int64

CreateTimestamp : Create a timestamp

func DirIsEmpty

func DirIsEmpty(path string) (bool, error)

DirIsEmpty returns true if the directory at the given path if empty

func DownloadAndExtractZip

func DownloadAndExtractZip(zipURL *url.URL, destination string) error

DownloadAndExtractZip downloads a zip file from a URL and extracts it to a destination

func DownloadFile

func DownloadFile(URL *url.URL, destination string) error

DownloadFile from URL to file destination

func DownloadFromRepoURL

func DownloadFromRepoURL(URL *url.URL, destination string, gitCredentials *GitCredentials) error

DownloadFromRepoURL downloads a repo from a URL to a destination

func DownloadFromTarGzURL

func DownloadFromTarGzURL(URL *url.URL, destination string, gitCredentials *GitCredentials) error

DownloadFromTarGzURL downloads a tar.gz file from a URL and extracts it to a destination

func DownloadFromURLThenExtract

func DownloadFromURLThenExtract(inURL, destination string, gitCredentials *GitCredentials) error

DownloadFromURLThenExtract downloads files from a URL to a destination, extracting them if necessary

func ExtractTarToFileSystem added in v0.14.0

func ExtractTarToFileSystem(tarReader *tar.Reader, destination string) error

ExtractTarToFileSystem reads a tar Reader to a filesystem

func GetZipURL

func GetZipURL(owner, repo, branch string, client *github.Client) (*url.URL, error)

GetZipURL from github api /repos/:owner/:repo/:archive_format/:ref

func IsTarGzURL

func IsTarGzURL(URL *url.URL) bool

IsTarGzURL returns whether the provided URL is a tar.gz file

func OnAddTemplateRepo

func OnAddTemplateRepo(extensions []Extension, url string, repos []TemplateRepo)

OnAddTemplateRepo runs any extension command associated with a repo add

func OnDeleteTemplateRepo

func OnDeleteTemplateRepo(extensions []Extension, url string, repos []TemplateRepo)

OnDeleteTemplateRepo runs any extension command associated with a repo delete

func PathExists

func PathExists(path string) bool

PathExists returns whether a path exists on the local file system.

func PrettyPrintJSON

func PrettyPrintJSON(i interface{})

PrettyPrintJSON : Format JSON output for display

func RemoveDuplicateEntries

func RemoveDuplicateEntries(inputArr []string) []string

RemoveDuplicateEntries elements

func ReplaceInFiles

func ReplaceInFiles(projectPath string, oldStr string, newStr string) error

ReplaceInFiles the placeholder string "[PROJ_NAME_PLACEHOLDER]" with a generated name based on the project directory

func RunCommand

func RunCommand(projectPath string, command ExtensionCommand, params map[string]string) error

RunCommand runs a command defined by an extension

func UnTar

func UnTar(pathToTarFile, destination string) error

UnTar unpacks a tar.gz file to a destination

func UnZip

func UnZip(filePath, destination string) error

UnZip unzips a file to a destination

func WaitForService

func WaitForService(url string, successStatusCode int, maxRetries int) error

WaitForService : Wait for service to start

func Zip added in v0.14.0

func Zip(zipFileName, targetDirectory string) error

Zip - creates a zip file in the target directory and populates it with the contents of that directory

Types

type Authentication added in v0.14.0

type Authentication struct {
	Username string `json:"username,omitempty"`
}

Authentication represents a template respository's authentication.

type Extension

type Extension struct {
	ProjectType string             `json:"projectType"`
	Detection   string             `json:"detection"`
	Commands    []ExtensionCommand `json:"commands"`
	Config      ExtensionConfig    `json:"config"`
}

Extension represents a project extension defined by codewind.yaml

type ExtensionCommand

type ExtensionCommand struct {
	Name    string   `json:"name"`
	Command string   `json:"command"`
	Args    []string `json:"args"`
}

ExtensionCommand represents a command defined by a project extension

type ExtensionConfig

type ExtensionConfig struct {
	Style string `json:"style"`
}

ExtensionConfig represents a project extension's config element

type GitCredentials added in v0.14.0

type GitCredentials struct {
	Username            string `json:"username,omitempty"`
	Password            string `json:"password,omitempty"`
	PersonalAccessToken string `json:"personalAccessToken,omitempty"`
}

GitCredentials : credentials to access GitHub or GitHubEnterprise

func ExtractGitCredentials added in v0.14.0

func ExtractGitCredentials(username, password, personalAccessToken string) (*GitCredentials, error)

ExtractGitCredentials extracts and formats git credentials from the provided arguments

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient : An net HTTP Client to simplify testing

type TemplateRepo

type TemplateRepo struct {
	Description    string          `json:"description"`
	URL            string          `json:"url"`
	Name           string          `json:"name"`
	ID             string          `json:"id"`
	Enabled        bool            `json:"enabled"`
	Protected      bool            `json:"protected"`
	ProjectStyles  []string        `json:"projectStyles"`
	Authentication *Authentication `json:"authentication,omitempty"`
}

TemplateRepo represents a template repository.

Jump to

Keyboard shortcuts

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