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 ¶
- Variables
- type Builder
- func (b *Builder) FetchTemplate(ctx context.Context, filePath string) (io.Reader, error)
- func (b *Builder) FormatFiles(ctx context.Context) error
- func (b *Builder) GenerateFiles(ctx context.Context, fs billy.Filesystem) ([]string, error)
- func (b *Builder) HasDeviations(_ context.Context, filePath string) bool
- func (b *Builder) Run(ctx context.Context, log logrus.FieldLogger) ([]string, error)
- func (b *Builder) WriteTemplate(ctx context.Context, filePath, contents string, args map[string]interface{}) ([]string, error)
- type Fetcher
- func (f *Fetcher) CreateVFS() (billy.Filesystem, []*configuration.TemplateRepositoryManifest, error)
- func (f *Fetcher) DownloadRepository(r *configuration.TemplateRepository) (billy.Filesystem, error)
- func (f *Fetcher) ParseRepositoryManifest(fs billy.Filesystem) (*configuration.TemplateRepositoryManifest, error)
- func (f *Fetcher) ResolveDependencies(filesystems map[string]bool, r *configuration.TemplateRepositoryManifest) ([]billy.Filesystem, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
FetchTemplate fetches a template from a git repository
func (*Builder) GenerateFiles ¶
GenerateFiles generates local files from the templates inside of the specific git repository from the service.yaml.
func (*Builder) HasDeviations ¶
HasDeviations looks for deviation blocks in a file, returning true if they exist
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 (f *Fetcher) CreateVFS() (billy.Filesystem, []*configuration.TemplateRepositoryManifest, error)
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.