utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: EPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTempFile

func CreateTempFile(filePath string) bool

CreateTempFile in the same directory as the binary for docker compose

func CreateTimestamp

func CreateTimestamp() int64

CreateTimestamp : Create a timestamp

func DeleteTempFile

func DeleteTempFile(filePath string) (bool, error)

DeleteTempFile once the the Codewind environment has been created

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 string, destination string) error

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

func DownloadFile

func DownloadFile(URL, destination string) error

DownloadFile from URL to file destination

func DownloadFromRepoURL

func DownloadFromRepoURL(repoURL string, destination string) error

DownloadFromRepoURL downloads a repo from a URL to a destination

func DownloadFromTarGzURL

func DownloadFromTarGzURL(URL string, destination string) error

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

func DownloadFromURLThenExtract

func DownloadFromURLThenExtract(URL string, destination string) error

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

func GetZipURL

func GetZipURL(owner, repo, branch string) (string, error)

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

func IsTarGzURL

func IsTarGzURL(URL string) 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

Types

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 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"`
}

TemplateRepo represents a template repository.

Jump to

Keyboard shortcuts

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