Help us shape the future of Go! Take the 2026 Go Developer Survey

scaffold

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoilerplateFile = "boilerplate.go.txt"
	HackDir         = "hack"
)
View Source
const (

	// dirs
	CmdDir         = "cmd"
	ManagerDir     = CmdDir + filePathSep + "manager"
	PkgDir         = "pkg"
	ApisDir        = PkgDir + filePathSep + "apis"
	ControllerDir  = PkgDir + filePathSep + "controller"
	BuildDir       = "build"
	BuildTestDir   = BuildDir + filePathSep + "test-framework"
	BuildBinDir    = BuildDir + filePathSep + "_output" + filePathSep + "bin"
	BuildScriptDir = BuildDir + filePathSep + "bin"
	DeployDir      = "deploy"
	CRDsDir        = DeployDir + filePathSep + "crds"
)
View Source
const ApisFile = "apis.go"
View Source
const ControllerFile = "controller.go"
View Source
const DocFile = "doc.go"
View Source
const DockerfileFile = "Dockerfile"
View Source
const EntrypointFile = "entrypoint"
View Source
const GitignoreFile = ".gitignore"
View Source
const GoModFile = "go.mod"
View Source
const GroupFile = "group.go"
View Source
const OperatorYamlFile = "operator.yaml"
View Source
const RegisterFile = "register.go"
View Source
const RoleBindingYamlFile = "role_binding.yaml"
View Source
const RoleYamlFile = "role.yaml"
View Source
const ServiceAccountYamlFile = "service_account.yaml"
View Source
const ToolsFile = "tools.go"

Variables

View Source
var (
	// ResourceVersionRegexp matches Kubernetes API versions.
	// See https://kubernetes.io/docs/concepts/overview/kubernetes-api/#api-versioning
	ResourceVersionRegexp = regexp.MustCompile("^v[1-9][0-9]*((alpha|beta)[1-9][0-9]*)?$")
	// ResourceKindRegexp matches Kubernetes API Kind's.
	ResourceKindRegexp = regexp.MustCompile("^[A-Z]{1}[a-zA-Z0-9]+$")
)

Functions

func MergeRoleForResource added in v0.18.0

func MergeRoleForResource(r *Resource, absProjectPath string, roleScaffold Role) error

MergeRoleForResource merges incoming new API resource rules with existing deploy/role.yaml

func PrintGoMod

func PrintGoMod() error

func UpdateRoleForResource

func UpdateRoleForResource(r *Resource, absProjectPath string) error

Types

type AddController

type AddController struct {
	input.Input

	// Resource defines the inputs for the controller's primary resource
	Resource *Resource
}

AddController is the input needed to generate a pkg/controller/add_<kind>.go file

func (*AddController) GetInput

func (s *AddController) GetInput() (input.Input, error)

type AddToScheme

type AddToScheme struct {
	input.Input

	// Resource defines the inputs for the new api
	Resource *Resource
}

AddToScheme is the input needed to generate an addtoscheme_<group>_<version>.go file

func (*AddToScheme) GetInput

func (s *AddToScheme) GetInput() (input.Input, error)

type Apis

type Apis struct {
	input.Input
}

func (*Apis) GetInput

func (s *Apis) GetInput() (input.Input, error)

type Boilerplate

type Boilerplate struct {
	input.Input

	// BoilerplateSrcPath is the path to a file containing boilerplate text for
	// generated Go files.
	BoilerplateSrcPath string
}

func (*Boilerplate) CustomRender

func (s *Boilerplate) CustomRender() ([]byte, error)

func (*Boilerplate) GetInput

func (s *Boilerplate) GetInput() (input.Input, error)

func (*Boilerplate) SetFS

func (s *Boilerplate) SetFS(_ afero.Fs)

type CR

type CR struct {
	input.Input

	// Resource defines the inputs for the new custom resource
	Resource *Resource

	// Spec is a custom spec for the CR. It will be automatically indented. If
	// unset, a default spec will be created.
	Spec string
}

CR is the input needed to generate a deploy/crds/<full group>_<version>_<kind>_cr.yaml file

func (*CR) GetInput

func (s *CR) GetInput() (input.Input, error)

type Controller

type Controller struct {
	input.Input
}

func (*Controller) GetInput

func (s *Controller) GetInput() (input.Input, error)

type ControllerKind

type ControllerKind struct {
	input.Input

	// Resource defines the inputs for the controller's primary resource
	Resource *Resource
	// CustomImport holds the import path for a built-in or custom Kubernetes
	// API that this controller reconciles, if specified by the scaffold invoker.
	CustomImport string

	// The following fields will be overwritten by GetInput().
	//
	// ImportMap maps all imports destined for the scaffold to their import
	// identifier, if any.
	ImportMap map[string]string
	// GoImportIdent is the import identifier for the API reconciled by this
	// controller.
	GoImportIdent string
}

ControllerKind is the input needed to generate a pkg/controller/<kind>/<kind>_controller.go file

func (*ControllerKind) GetInput

func (s *ControllerKind) GetInput() (input.Input, error)

type CustomRenderer

type CustomRenderer interface {
	// SetFS sets the fs in the CustomRenderer's underlying type if it exists.
	// SetFS is used to inject the callers' fs into a CustomRenderer, which may
	// want to write/read from the same fs.
	SetFS(afero.Fs)
	// CustomRender performs arbitrary rendering of file data and returns
	// bytes to write to a file.
	CustomRender() ([]byte, error)
}

CustomRenderer is the interface for writing any scaffold file that does not use a template.

type Doc

type Doc struct {
	input.Input

	// Resource defines the inputs for the new doc file
	Resource *Resource
}

Doc is the input needed to generate a pkg/apis/<group>/<version>/doc.go file

func (*Doc) GetInput

func (s *Doc) GetInput() (input.Input, error)

type Dockerfile

type Dockerfile struct {
	input.Input
}

func (*Dockerfile) GetInput

func (s *Dockerfile) GetInput() (input.Input, error)

type Entrypoint

type Entrypoint struct {
	input.Input
}

Entrypoint - entrypoint script

func (*Entrypoint) GetInput

func (e *Entrypoint) GetInput() (input.Input, error)

type Gitignore

type Gitignore struct {
	input.Input
}

func (*Gitignore) GetInput

func (s *Gitignore) GetInput() (input.Input, error)

type GoMod

type GoMod struct {
	input.Input
}

func (*GoMod) GetInput

func (s *GoMod) GetInput() (input.Input, error)

type Group

type Group struct {
	input.Input

	Resource *Resource
}

func (*Group) GetInput

func (s *Group) GetInput() (input.Input, error)

type Operator

type Operator struct {
	input.Input
}

func (*Operator) GetInput

func (s *Operator) GetInput() (input.Input, error)

type Register

type Register struct {
	input.Input

	// Resource defines the inputs for the new custom resource definition
	Resource *Resource
}

Register is the input needed to generate a pkg/apis/<group>/<version>/register.go file

func (*Register) GetInput

func (s *Register) GetInput() (input.Input, error)

type Resource

type Resource struct {
	// APIVersion is the complete group-subdomain/version e.g app.example.com/v1alpha1
	APIVersion string

	// Kind is the API Kind e.g AppService
	Kind string

	// FullGroup is the complete group name with subdomain e.g app.example.com
	// Parsed from APIVersion
	FullGroup string

	// Group is the API Group.  Does not contain the sub-domain. e.g app
	// Parsed from APIVersion
	Group string

	// GoImportGroup is the non-hyphenated go import group for this resource
	GoImportGroup string

	// Version is the API version - e.g. v1alpha1
	// Parsed from APIVersion
	Version string

	// Resource is the API Resource i.e plural(lowercased(Kind)) e.g appservices
	Resource string

	// LowerKind is lowercased(Kind) e.g appservice
	LowerKind string
}

Resource contains the information required to scaffold files for a resource.

func NewResource

func NewResource(apiVersion, kind string) (*Resource, error)

func (*Resource) Validate

func (r *Resource) Validate() error

Validate defaults and checks the Resource values to make sure they are valid.

type Role

type Role struct {
	input.Input

	IsClusterScoped  bool
	SkipDefaultRules bool
	CustomRules      []rbacv1.PolicyRule
}

func (*Role) GetInput

func (s *Role) GetInput() (input.Input, error)

type RoleBinding

type RoleBinding struct {
	input.Input

	IsClusterScoped bool
}

func (*RoleBinding) GetInput

func (s *RoleBinding) GetInput() (input.Input, error)

type Scaffold

type Scaffold struct {
	// Repo is the go project package
	Repo string
	// AbsProjectPath is the absolute path to the project root, including the project directory.
	AbsProjectPath string
	// ProjectName is the operator's name, ex. app-operator
	ProjectName string
	// Fs is the filesystem GetWriter uses to write scaffold files.
	Fs afero.Fs
	// GetWriter returns a writer for writing scaffold files.
	GetWriter func(path string, mode os.FileMode) (io.Writer, error)
	// BoilerplatePath is the path to a file containing Go boilerplate text.
	BoilerplatePath string
	// contains filtered or unexported fields
}

Scaffold writes Templates to scaffold new files

func (*Scaffold) Execute

func (s *Scaffold) Execute(cfg *input.Config, files ...input.File) error

Execute executes scaffolding the Files

type ServiceAccount

type ServiceAccount struct {
	input.Input
}

func (*ServiceAccount) GetInput

func (s *ServiceAccount) GetInput() (input.Input, error)

type Tools

type Tools struct {
	input.Input
}

func (*Tools) GetInput

func (s *Tools) GetInput() (input.Input, error)

type Types

type Types struct {
	input.Input

	// Resource defines the inputs for the new types file
	Resource *Resource
}

Types is the input needed to generate a pkg/apis/<group>/<version>/<kind>_types.go file

func (*Types) GetInput

func (s *Types) GetInput() (input.Input, error)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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