codegen

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package codegen has code generators for Go projects

This is intended for use with stencil

Builder:Build is the main entry point and this uses the fields of the Manifest and the builder itself to first generate a list of files. This is done by running the template files.json.tpl.

The leaf nodes of the output JSON are expected to be template => local file mappings. These are used to create the corresponding local files.

All the templates have access to the manifest and different formats of the app name (suitable for different purposes)

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAFile           = errors.New("not a file")
	ErrNoHeadBranch       = errors.New("failed to find a head branch, does one exist?")
	ErrNoRemoteHeadBranch = errors.New("failed to get head branch from remote origin")
)

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Branch    string
	Repo      string
	Dir       string
	Manifest  *configuration.ServiceManifest
	GitRepoFs billy.Filesystem

	Processors *processors.Table
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(repo, dir string, s *configuration.ServiceManifest, sshKeyPath string, accessToken cfg.SecretData) *Builder

func (*Builder) FetchTemplate

func (b *Builder) FetchTemplate(ctx context.Context, filePath string) (io.Reader, error)

FetchTemplate fetches a template from a git repository

func (*Builder) FormatFiles

func (b *Builder) FormatFiles(ctx context.Context) error

func (*Builder) GenerateFiles

func (b *Builder) GenerateFiles(ctx context.Context, fs billy.Filesystem) ([]string, error)

GenerateFiles generates local files from the templates inside of the specific git repository from the service.yaml.

func (*Builder) HasDeviations

func (b *Builder) HasDeviations(_ context.Context, filePath string) bool

HasDeviations looks for deviation blocks in a file, returning true if they exist

func (*Builder) Run

func (b *Builder) Run(ctx context.Context, log logrus.FieldLogger) ([]string, error)

Run generates the list of files using the files.json.tpl template and then generates the individual files as well. Returned is a list of warnings and if an error occurred that rendered it impossible to run stencil

func (*Builder) WriteTemplate

func (b *Builder) WriteTemplate(ctx context.Context, filePath, contents string, args map[string]interface{}) ([]string, error)

WriteTemplate writes the template to disk

type Fetcher

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

func NewFetcher

func NewFetcher(log logrus.FieldLogger, m *configuration.ServiceManifest, sshKeyPath string, accessToken cfg.SecretData) *Fetcher

func (*Fetcher) CreateVFS

func (*Fetcher) DownloadRepository

func (f *Fetcher) DownloadRepository(r *configuration.TemplateRepository) (billy.Filesystem, error)

func (*Fetcher) ParseRepositoryManifest

func (f *Fetcher) ParseRepositoryManifest(fs billy.Filesystem) (*configuration.TemplateRepositoryManifest, error)

func (*Fetcher) ResolveDependencies

func (f *Fetcher) ResolveDependencies(filesystems map[string]bool,
	r *configuration.TemplateRepositoryManifest) ([]billy.Filesystem, error)

ResolveDependencies resolved the dependencies of a given template repository. It currently only supports one level dependency resolution and doesn't do any smart logic for ordering other than first wins.

Jump to

Keyboard shortcuts

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