template

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRootUndefined = errors.Errorf("project root is undefined")
)

Functions

func DefaultFilter

func DefaultFilter(value string) (string, error)

func FindTokens

func FindTokens(document []byte, optionsMap map[string]string) ([]byte, error)

func LowerCaseFilter

func LowerCaseFilter(value string) (string, error)

func RecursiveReplace

func RecursiveReplace(document []byte, optionsMap map[string]string) ([]byte, error)

func ReplaceGenesisVariable

func ReplaceGenesisVariable(rawKey, rawValue string) (string, error)

func StringRecursiveReplace

func StringRecursiveReplace(str string, optionsMap map[string]string) (string, error)

func UpperCaseFilter

func UpperCaseFilter(value string) (string, error)

Types

type DisplayOptionType

type DisplayOptionType string
const (
	LANGUAGE             DisplayOptionType = "LANGUAGE"
	FRAMEWORK            DisplayOptionType = "FRAMEWORK"
	DEPLOYMENT_TYPE      DisplayOptionType = "DEPLOYMENT_TYPE"
	CLOUD_PROVIDER       DisplayOptionType = "CLOUD_PROVIDER"
	SOURCE_CONTROL       DisplayOptionType = "SOURCE_CONTROL"
	CI_SERVER            DisplayOptionType = "CI_SERVER"
	CD_SERVER            DisplayOptionType = "CD_SERVER"
	MODULE               DisplayOptionType = "MODULE"
	DEPENDENCY           DisplayOptionType = "DEPENDENCY"
	CONTAINER_MANAGEMENT DisplayOptionType = "CONTAINER_MANAGEMENT"
)

type Filter

type Filter func(value string) (string, error)

func GetFilterMap

func GetFilterMap(filterKey string) Filter

temporary solution for mapping filter names to filter functions

type FormField

type FormField struct {
	Type                   FormFieldType  `json:"type" yaml:"type"`
	Label                  string         `json:"label" yaml:"label"`
	Placeholder            string         `json:"placeholder" yaml:"placeholder"`
	FormControlName        string         `yaml:"formControlName" json:"formControlName"`
	Hint                   string         `json:"hint" yaml:"hint"`
	Icon                   string         `json:"icon" yaml:"icon"`
	IsCheckedByDefault     bool           `json:"isCheckedByDefault" yaml:"isCheckedByDefault"`
	OptionsUrl             string         `json:"optionsUrl" yaml:"optionsUrl"`
	SelectOptions          []SelectOption `json:"selectOptions" yaml:"selectOptions"`
	Validation             string         `json:"validation" yaml:"validation"`
	ValidationErrorMessage string         `json:"validationErrorMessage" yaml:"validationErrorMessage"`
	MaxCharacters          string         `json:"maxCharacters" yaml:"maxCharacters"`
	ImageButtons           []ImageButton  `yaml:"imageButtons" json:"imageButtons"`
}

type FormFieldType

type FormFieldType string

approximate an Enum

const (
	TEXT               FormFieldType = "TEXT"
	NUMBER             FormFieldType = "NUMBER"
	EMAIL              FormFieldType = "EMAIL"
	CHECKBOX           FormFieldType = "CHECKBOX"
	SELECT             FormFieldType = "SELECT"
	SELECT_TEMPLATE    FormFieldType = "SELECT_TEMPLATE"
	AUTOCOMPLETE       FormFieldType = "AUTOCOMPLETE"
	TEXT_AREA          FormFieldType = "TEXT AREA"
	COLOR              FormFieldType = "COLOR"
	DATE               FormFieldType = "DATE"
	DATETIME_LOCAL     FormFieldType = "DATETIME_LOCAL"
	MONTH              FormFieldType = "MONTH"
	PASSWORD           FormFieldType = "PASSWORD"
	SEARCH             FormFieldType = "SEARCH"
	TEL                FormFieldType = "TEL"
	TIME               FormFieldType = "TIME"
	URL                FormFieldType = "URL"
	WEEK               FormFieldType = "WEEK"
	SECTION            FormFieldType = "SECTION"
	IMAGE_BUTTON       FormFieldType = "IMAGE_BUTTON"
	IMAGE_BUTTON_GROUP FormFieldType = "IMAGE_BUTTON_GROUP"
)

type FormGroup

type FormGroup struct {
	DisplayName string      `yaml:"displayName" json:"displayName"`
	FormFields  []FormField `yaml:"formFields" json:"formFields"`
	ImageGroup  bool        `yaml:"imageGroup" json:"imageGroup"`
}

genesis front-end objects

type GenesisGitRepository

type GenesisGitRepository struct {
	Domain string `yaml:"domain" json:"domain"`
	Name   string `yaml:"name" json:"name"`
}

type GenesisProject

type GenesisProject struct {
	Projects []GenesisTemplate `yaml:"projects"`
	// contains filtered or unexported fields
}

func (GenesisProject) GetClonedDirectoryPath

func (p GenesisProject) GetClonedDirectoryPath() (string, error)

func (GenesisProject) GetTemplateFileName

func (p GenesisProject) GetTemplateFileName() string

func (*GenesisProject) SetClonedDirectoryPath

func (p *GenesisProject) SetClonedDirectoryPath(directoryPath string) error

type GenesisTemplate

type GenesisTemplate struct {
	Name          string               `yaml:"name" json:"name"`
	Root          string               `yaml:"root" json:"root"`
	Language      Language             `yaml:"language" json:"language"`
	Runtime       Runtime              `yaml:"runtime" json:"runtime"`
	GitRepository GenesisGitRepository `yaml:"git,omitempty" json:"git,omitempty"`
	Options       []Option             `yaml:"options,omitempty" json:"options,omitempty"`
	FormGroups    []FormGroup          `yaml:"formGroups" json:"formGroups"`
	// contains filtered or unexported fields
}

func (*GenesisTemplate) GetName

func (p *GenesisTemplate) GetName() string

func (*GenesisTemplate) GetRequiredOptions

func (p *GenesisTemplate) GetRequiredOptions() []Option

func (*GenesisTemplate) GetRoot

func (p *GenesisTemplate) GetRoot() (string, error)

func (*GenesisTemplate) GetValidatedOptions

func (p *GenesisTemplate) GetValidatedOptions() (map[string]string, error)

func (*GenesisTemplate) OrganizeGroups

func (p *GenesisTemplate) OrganizeGroups() error

func (*GenesisTemplate) SetValidatedOptions

func (p *GenesisTemplate) SetValidatedOptions(args map[string]string) error

type GenesisTemplateApi

type GenesisTemplateApi struct {
	DirectoryPath string
}

Implement the ProjectTemplateApi

func NewGenesisTemplateApi

func NewGenesisTemplateApi(directoryPath string) *GenesisTemplateApi

func (*GenesisTemplateApi) Cleanup

func (gTemplateApi *GenesisTemplateApi) Cleanup() error

func (*GenesisTemplateApi) GenerateFromTemplate

func (gTemplateApi *GenesisTemplateApi) GenerateFromTemplate(project ProjectTemplate, variableReplacementMap map[string]string) error

func (*GenesisTemplateApi) GetProjectFromRepo

func (gTemplateApi *GenesisTemplateApi) GetProjectFromRepo(projectName string) (ProjectTemplate, error)

func (*GenesisTemplateApi) GetProjectNames

func (gTemplateApi *GenesisTemplateApi) GetProjectNames() ([]string, error)

func (*GenesisTemplateApi) GetProjectsFromRepo

func (gTemplateApi *GenesisTemplateApi) GetProjectsFromRepo() (GenesisProject, error)

func (*GenesisTemplateApi) Replace

func (gTemplateApi *GenesisTemplateApi) Replace(validateOptions map[string]string) error

func (*GenesisTemplateApi) ValidateGenesisProject

func (gTemplateApi *GenesisTemplateApi) ValidateGenesisProject() (bool, error)

type GenesisVariable

type GenesisVariable struct {
	RawKey        string
	RawValue      string
	ParsedKey     string
	ParsedValue   string
	ParsedFilters []string
	Filters       []Filter
}

variable replacement

func NewGenesisVariable

func NewGenesisVariable(rawKey, rawValue string) (GenesisVariable, error)

func (*GenesisVariable) GetParsedValue

func (gVar *GenesisVariable) GetParsedValue() (string, error)

type ImageButton

type ImageButton struct {
	Type        DisplayOptionType `yaml:"type" json:"type"`
	Name        string            `yaml:"name" json:"name"`
	DisplayName string            `yaml:"displayName" json:"displayName"`
	Description string            `yaml:"description" json:"description"`
	IconUrl     string            `yaml:"iconUrl" json:"iconUrl"`
	ImageUrl    string            `yaml:"imageUrl" json:"imageUrl"`
}

type Language

type Language struct {
	Name    string `yaml:"name" json:"name"`
	Version string `yaml:"version" json:"version"`
}

type Option

type Option struct {
	Name      string    `yaml:"name" json:"name"`
	Default   string    `yaml:"default,omitempty" json:"default,omitempty"`
	Required  bool      `yaml:"required,omitempty" json:"required,omitempty"`
	GroupName string    `yaml:"groupName" json:"groupName"`
	FormField FormField `yaml:"formField,omitempty" json:"formField,omitempty"`
}

type Project

type Project interface {
	// GetTemplateFileName returns the name of the file to read as a template for the project.
	// This is effectively a contract that guarantees a constant value for a particular implementation of ProjectTemplate.
	GetTemplateFileName() string

	// GetClonedDirectoryPath
	GetClonedDirectoryPath() (string, error)

	// Set the directory path where this project instance has been cloned
	SetClonedDirectoryPath(directoryPath string) error
}

type ProjectTemplate

type ProjectTemplate interface {
	// Get the options that are required to be provided for this ProjectTemplate instance
	GetRequiredOptions() []Option

	// Set all required options in a key-value map
	SetValidatedOptions(args map[string]string) error

	// Get the validated options map
	GetValidatedOptions() (map[string]string, error)

	// Get the root directory name
	GetRoot() (string, error)

	// Get the name of the template
	GetName() string

	// Add formFields to groups
	OrganizeGroups() error
}

ProjectTemplate interface definition

type ProjectTemplateApi

type ProjectTemplateApi interface {
	// GetProjectNames returns the available template names in a Genesis template project.
	// The gitRepositoryUrl tells the function where to look for a .yml file.
	// It returns a slice of strings with each Project name, and any errors encountered
	GetProjectNames() ([]string, error)

	// GetProjectFromRepo retrieves a single template project from the Git repo at the given URL,
	// and any errors encountered.
	GetProjectFromRepo(projectName string) (ProjectTemplate, error)

	// GetProjectsFromRepo retrieves a list of genesis template projects from the Git repo at the
	// given URL, and any errors encountered.
	GetProjectsFromRepo() (GenesisProject, error)

	// GenerateFromTemplate creates a new project from the provided template, using the
	// variableReplacementMap to customize the Project, as needed.
	GenerateFromTemplate(project ProjectTemplate, variableReplacementMap map[string]string) error

	// ValidateGenesisProject goes out to gitRepositoryUrl and looks for a .yml file.
	// If it exists, then the method returns true. If not, false.
	// Also returns any errors encountered.
	ValidateGenesisProject() (bool, error)

	// Cleanup deletes temporary files and folders
	Cleanup() error
}

The ProjectTemplateApi interface defines the behavior needed to retrieve, parse, and package a Genesis Template project.

type Runtime

type Runtime struct {
	Names     []string  `yaml:"names"`
	GroupName string    `yaml:"groupName" json:"groupName"`
	FormField FormField `yaml:"formField,omitempty" json:"formField,omitempty"`
}

type SelectOption

type SelectOption struct {
	Value        string `yaml:"value" json:"value"`
	DisplayValue string `yaml:"displayValue" json:"displayValue"`
	IconUrl      string `yaml:"iconUrl" json:"iconUrl"`
}

Jump to

Keyboard shortcuts

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