render

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 44 Imported by: 2

README

Testing

In order to run all tests in this package you must set the REMOTE_CLUSTER_CONTEXT env var to the name of a context in your kubeconfig. To quickly provision two kind clusters for testing, run ./ci/setup-kind.sh <remote-context-name>. This will create two kind clusters, skv2-test-master and <remote-context-name>, and set your current context to kind-skv2-test-master. To run the multicluster tests in this package, you can then use REMOTE_CLUSTER_CONTEXT=kind-<remote-context-name> TEST_PKG=codegen/render make run-tests. To cleanup the kind clusters, run ./ci/teardown-kind.sh.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientsTemplates = inputTemplates{
	"code/types/clients.gotmpl": {
		Path: "clients.go",
	},
	"code/types/type_helpers.gotmpl": {
		Path: "type_helpers.go",
	},
}
View Source
var ControllerTemplates = inputTemplates{
	"code/controller/event_handlers.gotmpl": {
		Path: "controller/event_handlers.go",
	},
	"code/controller/reconcilers.gotmpl": {
		Path: "controller/reconcilers.go",
	},
	"code/controller/multicluster_reconcilers.gotmpl": {
		Path: "controller/multicluster_reconcilers.go",
	},
}
View Source
var DefaultTemplateRenderer = templateRenderer{
	// contains filtered or unexported fields
}
View Source
var TypesTemplates = func(skipDeepCopy bool) inputTemplates {
	tmpl := inputTemplates{
		"code/types/types.gotmpl": {
			Path: "types.go",
		},
		"code/types/register.gotmpl": {
			Path: "register.go",
		},
		"code/types/doc.gotmpl": {
			Path: "doc.go",
		},
		"code/types/zz_generated.deepcopy.gotmpl": {
			Path: "zz_generated.deepcopy.go",
		},
	}

	if skipDeepCopy {
		delete(tmpl, "code/types/zz_generated.deepcopy.gotmpl")
	}

	return tmpl
}

Functions

func EscapeGoTemplateOperators added in v0.28.0

func EscapeGoTemplateOperators(d map[string]interface{})

func KubeCodegen

func KubeCodegen(group Group) error

runs kubernetes code-generator.sh cannot be used to write output to memory also generates deecopy code

func PrependMockgenDirective added in v0.7.17

func PrependMockgenDirective(files []OutFile)

func SetVersionForObject added in v0.19.1

func SetVersionForObject(obj metav1.Object, version string)

Types

type BuildRenderer

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

renders files used to build the operator

func (BuildRenderer) Render

func (r BuildRenderer) Render(build model.Build) ([]OutFile, error)

func (BuildRenderer) RenderCustomTemplates

func (r BuildRenderer) RenderCustomTemplates(customTemplates map[string]string, customFuncs template.FuncMap, data interface{}) ([]OutFile, error)

type ChartRenderer

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

func (ChartRenderer) Render

func (r ChartRenderer) Render(chart model.Chart) ([]OutFile, error)

func (ChartRenderer) RenderCustomTemplates

func (r ChartRenderer) RenderCustomTemplates(customTemplates map[string]string, customFuncs template.FuncMap, data interface{}) ([]OutFile, error)

type Field

type Field = model.Field

type Group

type Group = model.Group

type HeaderOverride added in v0.28.0

type HeaderOverride interface {
	Generate() string
}

type KubeCodeRenderer

type KubeCodeRenderer struct {

	// the templates to use for rendering kube kypes
	TypesTemplates inputTemplates

	// the templates to use for rendering typed kube clients which use the underlying cache
	ClientsTemplates inputTemplates

	// the templates to use for rendering kube controllers
	ControllerTemplates inputTemplates

	// the go module of the project
	GoModule string

	// the relative path to the api dir
	// types will render in the package <module>/<apiRoot>/<group>/<version>
	ApiRoot string
	// contains filtered or unexported fields
}

renders kubernetes from templates

func (KubeCodeRenderer) RenderCustomTemplates

func (r KubeCodeRenderer) RenderCustomTemplates(customTemplates map[string]string, customFuncs template.FuncMap, data interface{}) ([]OutFile, error)

func (KubeCodeRenderer) RenderKubeCode

func (r KubeCodeRenderer) RenderKubeCode(grp Group) ([]OutFile, error)

type MakeResourceFunc

type MakeResourceFunc func(groups []*Group) ([]metav1.Object, error)

creates a k8s resource for a group this gets turned into a k8s manifest file

type ManifestsRenderer

type ManifestsRenderer struct {
	AppName       string // used for labeling
	ResourceFuncs map[OutFile]MakeResourceFunc
	ManifestDir   string
	ProtoDir      string
	// the name of the flag to pass the list of enabled alpha-level crds
	// used in codegen/templates/manifests/crd.yamltmpl
	EnabledAlphaApiFlagName string
	// contains filtered or unexported fields
}

renders kubernetes from templates

func (ManifestsRenderer) RenderCustomTemplates added in v0.33.0

func (r ManifestsRenderer) RenderCustomTemplates(customTemplates map[string]string, customFuncs template.FuncMap, data interface{}) ([]OutFile, error)

func (ManifestsRenderer) RenderManifests

func (r ManifestsRenderer) RenderManifests(grps []*Group, protoOpts protoutil.Options, groupOptions model.GroupOptions) ([]OutFile, error)

type OutFile

type OutFile struct {
	Path       string
	Permission os.FileMode
	Content    string // set by Renderer
}

func RenderApiTypes

func RenderApiTypes(grp Group) ([]OutFile, error)

func RenderBuild

func RenderBuild(build model.Build) ([]OutFile, error)

func RenderChart

func RenderChart(chart model.Chart) ([]OutFile, error)

func RenderManifests

func RenderManifests(opts RenderOptions) ([]OutFile, error)

func RenderProtoTypes

func RenderProtoTypes(grp Group) ([]OutFile, error)

type ProtoCodeRenderer

type ProtoCodeRenderer struct {

	// the go module of the project
	GoModule string

	// the relative path to the api dir
	// types will render in the package <module>/<apiRoot>/<group>/<version>
	ApiRoot string
	// contains filtered or unexported fields
}

renders kubernetes from templates

func (ProtoCodeRenderer) RenderCustomTemplates

func (r ProtoCodeRenderer) RenderCustomTemplates(customTemplates map[string]string, customFuncs template.FuncMap, data interface{}) ([]OutFile, error)

func (ProtoCodeRenderer) RenderProtoHelpers

func (r ProtoCodeRenderer) RenderProtoHelpers(grp Group) ([]OutFile, error)

type RenderOptions added in v0.34.7

type RenderOptions struct {
	AppName                 string
	ManifestRoot            string
	ProtoDir                string
	EnabledAlphaApiFlagName string
	ProtoOpts               protoutil.Options
	Groups                  []*Group
	GroupOptions            model.GroupOptions
	SkipCrdsManifest        bool
}

type Resource

type Resource = model.Resource

type TemplateRenderer

type TemplateRenderer interface {
	RenderCustomTemplates(customTemplates map[string]string, customFuncs template.FuncMap, data interface{}) ([]OutFile, error)
}

exported interface for using to render templates

Jump to

Keyboard shortcuts

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