scaffold

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 33 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"
	OLMCatalogDir  = DeployDir + filePathSep + "olm-catalog"
	CRDsDir        = DeployDir + filePathSep + "crds"
)
View Source
const (
	VersionDir  = "version"
	VersionFile = "version.go"
)
View Source
const ApisFile = "apis.go"
View Source
const CmdFile = "main.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 GopkgTomlFile = "Gopkg.toml"
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"
View Source
const UserSetupFile = "user_setup"

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 PrintDepGopkgTOML added in v0.8.0

func PrintDepGopkgTOML(asFile bool) error

func PrintGoMod added in v0.8.0

func PrintGoMod(asFile bool) 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 added in v0.8.0

type Boilerplate struct {
	input.Input

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

func (*Boilerplate) CustomRender added in v0.8.0

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

func (*Boilerplate) GetInput added in v0.8.0

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

func (*Boilerplate) SetFS added in v0.8.0

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/<group>_<version>_<kind>_cr.yaml file

func (*CR) GetInput

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

type CRD

type CRD struct {
	input.Input

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

	// IsOperatorGo is true when the operator is written in Go.
	IsOperatorGo bool
	// contains filtered or unexported fields
}

CRD is the input needed to generate a deploy/crds/<group>_<version>_<kind>_crd.yaml file

func (*CRD) CustomRender

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

func (*CRD) GetInput

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

func (*CRD) SetFS

func (s *CRD) SetFS(fs afero.Fs)

type Cmd

type Cmd struct {
	input.Input
}

func (*Cmd) GetInput

func (s *Cmd) 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 added in v0.8.0

type GoMod struct {
	input.Input
}

func (*GoMod) GetInput added in v0.8.0

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

type GopkgToml

type GopkgToml struct {
	input.Input
}

func (*GopkgToml) GetInput

func (s *GopkgToml) 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
	SkipMetricsRules 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 added in v0.8.0

type Tools struct {
	input.Input
}

func (*Tools) GetInput added in v0.8.0

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)

type UserSetup

type UserSetup struct {
	input.Input
}

UserSetup - userSetup script

func (*UserSetup) GetInput

func (u *UserSetup) GetInput() (input.Input, error)

type Version

type Version struct {
	input.Input
}

func (*Version) GetInput

func (s *Version) 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