Documentation ¶
Index ¶
- Constants
- Variables
- func AskFromList(msg, promptPrefix string, allowVars bool, options []prompt.Suggest, ...) string
- func AskFromListWithMismatchConfirmation(promptPrefix, misMatchMsg string, options []prompt.Suggest) string
- func AskString(msg, promptPrefix string, allowEmpty bool, allowVars bool) string
- func AskStringWithDefault(msg, promptPrefix, defaultValue string) string
- func BackupFile(filePath, backupPath string) (restore func() error, err error)
- func ConvertTemplateToMap(tuc TemplateUserCommand) (map[string]interface{}, error)
- func ConvertToSuggests(options []string) []prompt.Suggest
- func CreateBuildConfig(c *cli.Context, confType utils.ProjectType) (err error)
- func ExtractNpmOptionsFromArgs(args []string) (threads int, detailedSummary bool, cleanArgs []string, ...)
- func GetArtifactoryNpmRepoDetails(repo string, authArtDetails *auth.ServiceDetails) (npmAuth, registry string, err error)
- func GetBoolSuggests() []prompt.Suggest
- func GetDependenciesFromLatestBuild(servicesManager artifactory.ArtifactoryServicesManager, buildName string) (map[string]*buildinfo.Dependency, error)
- func GetDependencyInfo(name, ver string, previousBuildDependencies map[string]*buildinfo.Dependency, ...) (checksum buildinfo.Checksum, fileType string, err error)
- func GetSuggestsFromKeys(keys []string, SuggestionMap map[string]prompt.Suggest) []prompt.Suggest
- func GetWorkingDirectory() (string, error)
- func OptionalKeyCallback(iq *InteractiveQuestionnaire, key string) (value string, err error)
- func PrepareBuildInfo(workingDirectory string, buildConfiguration *utils.BuildConfiguration, ...) (collectBuildInfo bool, packageInfo *npmutils.PackageInfo, err error)
- func PrintMissingDependencies(missingDependencies []buildinfo.Dependency)
- func SaveDependenciesData(dependencies []buildinfo.Dependency, ...) error
- func ValidateMapEntry(key string, value interface{}, writersMap map[string]AnswerWriter) error
- func ValidateTemplatePath(templatePath string) error
- func WriteBoolAnswer(resultMap *map[string]interface{}, key, value string) error
- func WriteIntAnswer(resultMap *map[string]interface{}, key, value string) error
- func WriteStringAnswer(resultMap *map[string]interface{}, key, value string) error
- func WriteStringArrayAnswer(resultMap *map[string]interface{}, key, value string) error
- type AnswerWriter
- type ConfigFile
- type InteractiveQuestionnaire
- type QuestionInfo
- type Result
- type TemplateUserCommand
Constants ¶
const ( InsertValuePromptMsg = "Insert the value for " DummyDefaultAnswer = "-" )
const ( PressTabMsg = " (press Tab for options):" InvalidAnswerMsg = "Invalid answer. Please select value from the suggestions list." VariableUseMsg = " You may use dynamic variable in the form of ${key}." EmptyValueMsg = "The value cannot be empty. Please enter a valid value." OptionalKey = "OptionalKey" SaveAndExit = ":x" // Boolean answers True = "true" False = "false" CommaSeparatedListMsg = "The value should be a comma separated list" )
const PathErrorSuffixMsg = " please enter a path, in which the new template file will be created"
Variables ¶
var BoolQuestionInfo = QuestionInfo{ Options: GetBoolSuggests(), AllowVars: true, Writer: WriteBoolAnswer, }
var FreeStringQuestionInfo = QuestionInfo{ Options: nil, AllowVars: false, Writer: WriteStringAnswer, }
Common questions
var IntQuestionInfo = QuestionInfo{ Options: nil, AllowVars: true, Writer: WriteIntAnswer, }
var StringListQuestionInfo = QuestionInfo{ Msg: CommaSeparatedListMsg, Options: nil, AllowVars: true, Writer: WriteStringArrayAnswer, }
var VarPattern = regexp.MustCompile(`^\$\{\w+\}+$`)
Var can be inserted in the form of ${key}
Functions ¶
func AskFromList ¶
func AskFromList(msg, promptPrefix string, allowVars bool, options []prompt.Suggest, defaultValue string) string
Ask question with list of possible answers. If answer is empty and defaultValue isn't, return defaultValue. Otherwise, the answer must be chosen from the list, but can be a variable if allowVars set to true.
func AskFromListWithMismatchConfirmation ¶
func AskFromListWithMismatchConfirmation(promptPrefix, misMatchMsg string, options []prompt.Suggest) string
Ask question with list of possible answers. If the provided answer does not appear in list, confirm the choice.
func AskStringWithDefault ¶
Ask question with free string answer. If answer is empty and defaultValue isn't, return defaultValue. Otherwise, answer cannot be empty. Variable aren't checked and can be part of the answer.
func BackupFile ¶ added in v1.9.1
BackupFile creates a backup of the file in filePath. The backup will be found at backupPath. The returned restore function can be called to restore the file's state - the file in filePath will be replaced by the backup in backupPath. If there is no file at filePath, a backup file won't be created, and the restore function will delete the file at filePath.
func ConvertTemplateToMap ¶
func ConvertTemplateToMap(tuc TemplateUserCommand) (map[string]interface{}, error)
func ConvertToSuggests ¶
func ConvertToSuggests(options []string) []prompt.Suggest
func CreateBuildConfig ¶
func CreateBuildConfig(c *cli.Context, confType utils.ProjectType) (err error)
func ExtractNpmOptionsFromArgs ¶ added in v1.7.0
func GetArtifactoryNpmRepoDetails ¶ added in v1.7.0
func GetArtifactoryNpmRepoDetails(repo string, authArtDetails *auth.ServiceDetails) (npmAuth, registry string, err error)
func GetBoolSuggests ¶
func GetBoolSuggests() []prompt.Suggest
func GetDependenciesFromLatestBuild ¶ added in v1.7.0
func GetDependenciesFromLatestBuild(servicesManager artifactory.ArtifactoryServicesManager, buildName string) (map[string]*buildinfo.Dependency, error)
func GetDependencyInfo ¶ added in v1.7.0
func GetDependencyInfo(name, ver string, previousBuildDependencies map[string]*buildinfo.Dependency, servicesManager artifactory.ArtifactoryServicesManager, threadId int) (checksum buildinfo.Checksum, fileType string, err error)
Get dependency's checksum and type.
func GetSuggestsFromKeys ¶
func GetWorkingDirectory ¶ added in v1.7.0
func OptionalKeyCallback ¶
func OptionalKeyCallback(iq *InteractiveQuestionnaire, key string) (value string, err error)
After an optional value was chosen we'll ask for its value.
func PrepareBuildInfo ¶ added in v1.7.0
func PrepareBuildInfo(workingDirectory string, buildConfiguration *utils.BuildConfiguration, npmVersion *version.Version) (collectBuildInfo bool, packageInfo *npmutils.PackageInfo, err error)
func PrintMissingDependencies ¶ added in v1.7.0
func PrintMissingDependencies(missingDependencies []buildinfo.Dependency)
func SaveDependenciesData ¶ added in v1.7.0
func SaveDependenciesData(dependencies []buildinfo.Dependency, buildConfiguration *utils.BuildConfiguration) error
func ValidateMapEntry ¶
func ValidateMapEntry(key string, value interface{}, writersMap map[string]AnswerWriter) error
func ValidateTemplatePath ¶
func WriteBoolAnswer ¶
func WriteIntAnswer ¶
func WriteStringAnswer ¶
Common writers
func WriteStringArrayAnswer ¶
Types ¶
type AnswerWriter ¶
Each question can have the following properties:
- Msg - will be printed in separate line
- PromptPrefix - will be printed before the input cursor in the answer line
- Options - In case the answer must be selected from a predefined list
- AllowVars - a flag indicates whether a variable (in form of ${var}) is an acceptable answer despite the predefined list
- Writer - how to write the answer to the final config map
- MapKey - the key under which the answer will be written to the configMap
- Callback - optional function can be executed after the answer was inserted. Can be used to implement some dependencies between questions.
type ConfigFile ¶
type ConfigFile struct { Interactive bool `yaml:"-"` Version int `yaml:"version,omitempty"` ConfigType string `yaml:"type,omitempty"` Resolver utils.Repository `yaml:"resolver,omitempty"` Deployer utils.Repository `yaml:"deployer,omitempty"` UsePlugin bool `yaml:"usePlugin,omitempty"` UseWrapper bool `yaml:"useWrapper,omitempty"` }
func NewConfigFile ¶
func NewConfigFile(confType utils.ProjectType, c *cli.Context) *ConfigFile
func (*ConfigFile) VerifyConfigFile ¶
func (configFile *ConfigFile) VerifyConfigFile(configFilePath string) error
Verify config file doesn't exist or prompt to override it
type InteractiveQuestionnaire ¶
type InteractiveQuestionnaire struct { QuestionsMap map[string]QuestionInfo MandatoryQuestionsKeys []string OptionalKeysSuggests []prompt.Suggest AnswersMap map[string]interface{} }
The interactive questionnaire works as follows:
We have to provide a map of QuestionInfo which include all possible questions may be asked. 1. Mandatory Questions: * We will ask all the questions in MandatoryQuestionsKeys list one after the other. 2. Optional questions: * We have to provide a slice of prompt.Suggest, in which each suggest.Text is a key of a question in the map. * After a suggest was chosen from the list, the corresponding question from the map will be asked. * Each answer is written to to the configMap using its writer, under the MapKey specified in the questionInfo. * We will execute the previous step until the SaveAndExit string was inserted.
func (*InteractiveQuestionnaire) AskQuestion ¶
func (iq *InteractiveQuestionnaire) AskQuestion(question QuestionInfo) (value string, err error)
Ask question steps:
- Ask for string/from list
- Write the answer to answersMap (if writer provided)
- Run callback (if provided)
func (*InteractiveQuestionnaire) Perform ¶
func (iq *InteractiveQuestionnaire) Perform() error
The main function to perform the questionnaire
type QuestionInfo ¶
type QuestionInfo struct { Msg string PromptPrefix string Options []prompt.Suggest AllowVars bool Writer AnswerWriter MapKey string Callback questionCallback }
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func UnmarshalDeployableArtifacts ¶ added in v1.7.2
func UnmarshalDeployableArtifacts(deployableArtifactsFilePath, ProjectConfigPath string) (*Result, error)
UnmarshalDeployableArtifacts reads and parses the deployed artifacts details from the provided file. The details were written by Buildinfo project while deploying artifacts to maven and gradle repositories. deployableArtifactsFilePath - path to deployableArtifacts file written by buildinfo project. ProjectConfigPath - path to gradle/maven config yaml path.
func (*Result) Reader ¶
func (r *Result) Reader() *content.ContentReader
func (*Result) SetFailCount ¶
func (*Result) SetReader ¶
func (r *Result) SetReader(reader *content.ContentReader)