contrib

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 4 Imported by: 5

README

Contributions

Contributions to skv2 are welcome! Extensions to skv2 which are common across projects but not intended to be universally applied should be placed int the contrib directory.

  • Templates should go in contrib/codegen/templates/ (e.g. contrib/codegen/templates/sets.go.tmpl)
  • Libraries imported by contrib templates should go in contrib/pkg/ (e.g. contrib/pkg/sets.go)
  • Test code should be added to contrib/tests/*_test.go where * is the name of the template (e.g. contrib/tests/sets_test.go)
  • A CustomTemplate should be added to contrib/custom_templates.go like so:
/*
Sets custom template
 */
const (
	SetOutputFilename     = "sets/sets.go"
	SetCustomTemplatePath = "sets/sets.gotmpl"
)

var Sets = func() model.CustomTemplates {
	templateContents, err := templatesBox.FindString(SetCustomTemplatePath)
	if err != nil {
		panic(err)
	}
	setsTemplates := model.CustomTemplates{
		Templates: map[string]string{SetOutputFilename: templateContents},
	}
	// register sets
	AllCustomTemplates = append(AllCustomTemplates, setsTemplates)

	return setsTemplates
}()

Note: to test generated

Documentation

Index

Constants

View Source
const (
	SetOutputFilename     = "sets/sets.go"
	SetCustomTemplatePath = "sets/sets.gotmpl"
)

Sets custom template

View Source
const (
	ClientProvidersOutputFilename     = "providers/client_providers.go"
	ClientProvidersCustomTemplatePath = "providers/client_providers.gotmpl"
)

ClientProviders custom template

View Source
const (
	InputReconcilerCustomTemplatePath = "input/input_reconciler.gotmpl"
)

InputReconciler custom template

View Source
const (
	InputSnapshotCustomTemplatePath = "input/input_snapshot.gotmpl"
)

InputSnapshot custom template

View Source
const (
	InputSnapshotManualBuilderCustomTemplatePath = "input/input_snapshot_manual_builder.gotmpl"
)

InputSnapshot test builder custom template

View Source
const (
	OutputSnapshotCustomTemplatePath = "output/output_snapshot.gotmpl"
)

OutputSnapshot custom template

Variables

View Source
var AllGroupCustomTemplates []model.CustomTemplates

use to get all group-level templates in contrib

View Source
var ClientProviders = func() model.CustomTemplates {
	templateContents, err := templatesBox.FindString(ClientProvidersCustomTemplatePath)
	if err != nil {
		panic(err)
	}
	clientProvidersTemplate := model.CustomTemplates{
		Templates: map[string]string{ClientProvidersOutputFilename: templateContents},
	}

	AllGroupCustomTemplates = append(AllGroupCustomTemplates, clientProvidersTemplate)

	return clientProvidersTemplate
}()
View Source
var Sets = func() model.CustomTemplates {
	templateContents, err := templatesBox.FindString(SetCustomTemplatePath)
	if err != nil {
		panic(err)
	}
	setsTemplates := model.CustomTemplates{
		Templates: map[string]string{SetOutputFilename: templateContents},
	}

	AllGroupCustomTemplates = append(AllGroupCustomTemplates, setsTemplates)

	return setsTemplates
}()

Functions

func InputReconciler

func InputReconciler(params CrossGroupTemplateParameters) model.CustomTemplates

Returns the template for generating input reconcilers.

func InputSnapshot

Returns the template for generating input snapshots.

func InputSnapshotManualBuilder added in v0.7.17

func InputSnapshotManualBuilder(params CrossGroupTemplateParameters) model.CustomTemplates

Returns the template for generating input snapshots.

func OutputSnapshot

func OutputSnapshot(params CrossGroupTemplateParameters) model.CustomTemplates

Returns the template for generating output snapshots.

Types

type CrossGroupTemplateParameters

type CrossGroupTemplateParameters struct {
	// the path of the output file produced from this template. relative to project root.
	OutputFilename string

	// a map of Go modules to (a superset of) the imported codegen Groups. only required if the codegen group is defined in a different go module than the types (i.e. it is using a CustomTypesImportPath)
	SelectFromGroups map[string][]model.Group

	// a map of the GVKs to the resources which we want to include in the input snapshot.
	ResourcesToSelect map[schema.GroupVersion][]string
}

Parameters for constructing templates that span across multiple Groups.

Directories

Path Synopsis
codegen
pkg

Jump to

Keyboard shortcuts

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