utils

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: EPL-2.0 Imports: 15 Imported by: 2

Documentation

Overview

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

* Copyright contributors to the Galasa project * * SPDX-License-Identifier: EPL-2.0

Index

Constants

View Source
const (
	LOWER_CASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"
	DIGITS             = "0123456789"
	SEPARATOR          = "."
)
View Source
const (
	MAVEN_REPO_URL_GALASA_BLEEDING_EDGE = "https://development.galasa.dev/main/maven-repo/obr"
	MAVEN_REPO_URL_MAVEN_CENTRAL        = "https://repo.maven.apache.org/maven2"
)
View Source
const (
	SECONDS_BETWEEN_INTERRUPTED_CHECKS  = 3
	DURATION_BETWEEN_INTERRUPTED_CHECKS = SECONDS_BETWEEN_INTERRUPTED_CHECKS * time.Second
)
View Source
const (
	TOKEN_EXPIRY_BUFFER_MINUTES = 10
)

Variables

This section is empty.

Functions

func AddJavaRuntimeToMock

func AddJavaRuntimeToMock(fileSystem files.FileSystem, baseJavaFolderName string)

func CaptureLog

func CaptureLog(fileSystem files.FileSystem, logFileName string) error

* CaptureLog(logFileName) decides whether to re-direct the log information to the * specified file, or if the file name is "-" or empty, the log information won't be * re-directed, but will appear on stderr.

func GetBearerTokenFromTokenJsonFile added in v0.33.0

func GetBearerTokenFromTokenJsonFile(fileSystem files.FileSystem, galasaHome GalasaHome, timeService TimeService) (string, error)

Gets the JWT from the bearer-token.json file if it exists, errors if the file does not exist or if the token is invalid

func GetGalasaBootJarPath

func GetGalasaBootJarPath(fs files.FileSystem, home GalasaHome) (string, error)

func InitialiseGalasaHomeFolder

func InitialiseGalasaHomeFolder(home GalasaHome, fileSystem files.FileSystem, embeddedFileSystem embedded.ReadOnlyFileSystem) error

func InitialiseM2Folder

func InitialiseM2Folder(fileSystem files.FileSystem, embeddedFileSystem embedded.ReadOnlyFileSystem, isDevelopment bool) error

func IsBearerTokenValid added in v0.33.0

func IsBearerTokenValid(bearerTokenString string, timeService TimeService) bool

Checks whether a given bearer token is valid or not, returning true if it is valid and false otherwise

func UppercaseFirstLetter

func UppercaseFirstLetter(s string) string

UppercaseFirstLetter - takes a string and returns the same string, but with the first letter turned into an uppercase letter.

func ValidateJavaHome

func ValidateJavaHome(fileSystem files.FileSystem, javaHome string) error

validateJavaHome validate that JAVA_HOME is set correctly. If $JAVA_HOME ends with a '/' (or '\' for windows, the trailing slash is removed before checks are made.

Constraints: - It must be set. - JAVA_HOME/bin must be a folder which exists. - JAVA_HOME/bin/java must exist as a file.

func ValidateJavaPackageName

func ValidateJavaPackageName(javaPackageName string) error

To validate the string as a valid java package name before we start to use it.

func WriteBearerTokenJsonFile added in v0.33.0

func WriteBearerTokenJsonFile(fileSystem files.FileSystem, galasaHome GalasaHome, jwt string) error

Writes a new bearer-token.json file containing a JWT in the following format:

{
  "jwt": "<bearer-token-here>"
}

Types

type BearerTokenJson added in v0.33.0

type BearerTokenJson struct {
	Jwt string `json:"jwt"`
}

type BlankTemplateParameters

type BlankTemplateParameters struct{}

type Console

type Console interface {
	WriteString(text string) error
	Write(p []byte) (n int, err error)
}

------------------------------------------------- A console where things can be written to so the user can see them.

type Environment

type Environment interface {
	GetEnv(propertyName string) string
	GetUserName() (string, error)
}

Environment is a thin interface layer above the os package which can be mocked out

func NewEnvironment

func NewEnvironment() Environment

type FileGenerator

type FileGenerator struct {
	// contains filtered or unexported fields
}

func NewFileGenerator

func NewFileGenerator(fileSystem files.FileSystem, embeddedFileSystem embedded.ReadOnlyFileSystem) *FileGenerator

func (*FileGenerator) CreateFile

func (generator *FileGenerator) CreateFile(
	generatedFile GeneratedFileDef,
	forceOverwrite bool,
	isExistsAnError bool) error

createFile creates a file on the file system. If forceOverwrite is false, and there is already a file there, then an error will occur.

func (*FileGenerator) CreateFolder

func (generator *FileGenerator) CreateFolder(targetFolderPath string) error

type GalasaHome

type GalasaHome interface {
	GetNativeFolderPath() string
	GetUrlFolderPath() string
}

func NewGalasaHome

func NewGalasaHome(fs files.FileSystem, env Environment, cmdFlagGalasaHome string) (GalasaHome, error)

type GeneratedFileDef

type GeneratedFileDef struct {
	FileType                 string
	TargetFilePath           string
	EmbeddedTemplateFilePath string
	TemplateParameters       interface{}
}

type JavaClassDef

type JavaClassDef struct {
	PackageName string
	ClassName   string
}

type MavenCoordinates

type MavenCoordinates struct {
	GroupId    string
	ArtifactId string
	Version    string
	Classifier string
}

func ValidateObr

func ValidateObr(obr string) (MavenCoordinates, error)

We expect a parameter to be of the form: mvn:dev.galasa.example.banking/dev.galasa.example.banking.obr/0.0.1-SNAPSHOT/obr Validate that the --obr parameter or portfolio field passed by the user conform to this convention by splitting the input into pieces.

func ValidateObrs

func ValidateObrs(obrInputs []string) ([]MavenCoordinates, error)

We expect a parameter to be of the form: mvn:dev.galasa.example.banking/dev.galasa.example.banking.obr/0.0.1-SNAPSHOT/obr Validate that the --obr parameter or portfolio field passed by the user conform to this convention by splitting the input into pieces.

type MockConsole

type MockConsole struct {
	// contains filtered or unexported fields
}

------------------------------------------------- A mock implementation which writes text to a buffer Useful for unit testing.

func NewMockConsole

func NewMockConsole() *MockConsole

func (*MockConsole) ReadText

func (data *MockConsole) ReadText() string

func (*MockConsole) Write

func (data *MockConsole) Write(p []byte) (n int, err error)

func (*MockConsole) WriteString

func (this *MockConsole) WriteString(text string) error

type MockEnv

type MockEnv struct {
	EnvVars map[string]string
	// contains filtered or unexported fields
}

func NewMockEnv

func NewMockEnv() *MockEnv

func (*MockEnv) GetEnv

func (env *MockEnv) GetEnv(propertyName string) string

func (*MockEnv) GetUserName

func (env *MockEnv) GetUserName() (string, error)

func (*MockEnv) SetEnv

func (env *MockEnv) SetEnv(propertyName string, value string)

func (*MockEnv) SetUserName

func (env *MockEnv) SetUserName(name string)

type MockTimeService

type MockTimeService struct {
	MockNow time.Time
}

func NewMockTimeServiceAsMock

func NewMockTimeServiceAsMock(now time.Time) *MockTimeService

func (*MockTimeService) Interrupt

func (ts *MockTimeService) Interrupt(message string)

func (*MockTimeService) Now

func (ts *MockTimeService) Now() time.Time

func (*MockTimeService) Sleep

func (ts *MockTimeService) Sleep(duration time.Duration)

type OSEnvironment

type OSEnvironment struct {
}

func NewOSEnvironment

func NewOSEnvironment() *OSEnvironment

NewOSEnvironment creates a real wrapper over the os environment

func (OSEnvironment) GetEnv

func (osEnv OSEnvironment) GetEnv(propertyName string) string

func (OSEnvironment) GetUserName

func (osEnv OSEnvironment) GetUserName() (string, error)

type RealConsole

type RealConsole struct {
}

------------------------------------------------- A real implementation which writes text to stdout.

func NewRealConsole

func NewRealConsole() *RealConsole

func (*RealConsole) Write

func (*RealConsole) Write(p []byte) (n int, err error)

func (*RealConsole) WriteString

func (*RealConsole) WriteString(text string) error

type RunsSubmitCmdValues

type RunsSubmitCmdValues struct {
	PollIntervalSeconds           int
	NoExitCodeOnTestFailures      bool
	ReportYamlFilename            string
	ReportJsonFilename            string
	ReportJunitFilename           string
	GroupName                     string
	ProgressReportIntervalMinutes int
	Throttle                      int
	Overrides                     []string
	Trace                         bool
	Requestor                     string
	RequestType                   string
	ThrottleFileName              string
	PortfolioFileName             string
	OverrideFilePath              string
	TestSelectionFlagValues       *TestSelectionFlagValues
}

RunsSubmitCmdParameters - Holds variables set by cobra's command-line parsing. We collect the parameters here so that our unit tests can feed in different values easily.

type TestSelectionFlagValues

type TestSelectionFlagValues struct {
	Bundles     *[]string
	Packages    *[]string
	Tests       *[]string
	Tags        *[]string
	Classes     *[]string
	Stream      string
	RegexSelect *bool
	GherkinUrl  *[]string
}

type TimeService

type TimeService interface {
	Sleep(duration time.Duration)
	Now() time.Time
	Interrupt(message string)
}

func NewMockTimeService

func NewMockTimeService() TimeService

func NewOverridableMockTimeService

func NewOverridableMockTimeService(now time.Time) TimeService

func NewRealTimeService

func NewRealTimeService() TimeService

Jump to

Keyboard shortcuts

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