templatecache

package
v0.0.0-...-2be5db1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrCreateMassDir

func GetOrCreateMassDir() (string, error)

func GithubTemplatesFetcher

func GithubTemplatesFetcher(writePath string) error

Function for fetching templates from multiple Github repositories.

Types

type BundleTemplateCache

type BundleTemplateCache struct {
	TemplatePath string
	Fetch        Fetcher
}

func (*BundleTemplateCache) GetTemplatePath

func (b *BundleTemplateCache) GetTemplatePath() (string, error)

Get the path to the template directory

func (*BundleTemplateCache) ListTemplates

func (b *BundleTemplateCache) ListTemplates() ([]TemplateList, error)

List all templates available in cache

func (*BundleTemplateCache) RefreshTemplates

func (b *BundleTemplateCache) RefreshTemplates() error

Refresh available templates from Massdriver official Github repository.

func (*BundleTemplateCache) RenderTemplate

func (b *BundleTemplateCache) RenderTemplate(data *TemplateData) error

Clones the desired template to the directory specified by the user and renders the massdriver YAML with user supplied values.

type CloneError

type CloneError struct {
	Repository string
	Error      string
}

type Commit

type Commit struct {
	SHA string `json:"sha,omitempty"`
}

Comit represents a commit from the github API, however, we only need the sha at this point

type Connection

type Connection struct {
	Name               string `json:"name"`
	ArtifactDefinition string `json:"artifact_definition"`
}

type Fetcher

type Fetcher func(writePath string) error

type TemplateCache

type TemplateCache interface {
	RefreshTemplates() error
	ListTemplates() ([]TemplateList, error)
	GetTemplatePath() (string, error)
	RenderTemplate(*TemplateData) error
}

func NewBundleTemplateCache

func NewBundleTemplateCache(fetch Fetcher) (TemplateCache, error)

Template cache factory which will create a new instance of BundleTemplateCache. Requires a function as a dependency to handle retreival of templates which can in turn be mocked for testing.

func NewMockClient

func NewMockClient(rootTemplateDir string) TemplateCache

type TemplateData

type TemplateData struct {
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Access       string            `json:"access"`
	Location     string            `json:"location"`
	TemplateName string            `json:"templateName"`
	TemplateRepo string            `json:"templateRepo"`
	OutputDir    string            `json:"outputDir"`
	Type         string            `json:"type"`
	Connections  []Connection      `json:"connections"`
	Envs         map[string]string `json:"envs"`

	// ParamsSchema is a YAML formatted string
	ParamsSchema string `json:"paramsSchema"`

	// Path to a terraform-module or helm-chart to parse for params
	ExistingParamsPath string `json:"existingParamsPath"`
	// Specificaly for the README
	CloudAbbreviation string `json:"cloudAbbreviation"`
	RepoName          string `json:"repoName"`
	RepoNameEncoded   string `json:"repoNameEncoded"`
}

type TemplateList

type TemplateList struct {
	Repository string
	Templates  []string
}

Jump to

Keyboard shortcuts

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