scaffold

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

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"
	VersionDir     = "version"
)
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 GoTestScriptFile = "go-test.sh"
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 TestPodYamlFile = "test-pod.yaml"
View Source
const UserSetupFile = "user_setup"
View Source
const VersionFile = "version.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 PrintDeps added in v0.2.0

func PrintDeps() error

func PrintDepsAsFile added in v0.2.0

func PrintDepsAsFile()

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 CR added in v0.5.0

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

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

type CRD added in v0.5.0

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
}

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

func (*CRD) CustomRender added in v0.5.0

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

func (*CRD) GetInput added in v0.5.0

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

func (*CRD) SetFS added in v0.6.0

func (s *CRD) SetFS(_ 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
}

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

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

type Entrypoint struct {
	input.Input
}

Entrypoint - entrypoint script

func (*Entrypoint) GetInput added in v0.5.0

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 GoTestScript

type GoTestScript struct {
	input.Input
}

func (*GoTestScript) GetInput

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

	IsClusterScoped bool
}

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
}

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)
}

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 TestFrameworkDockerfile

type TestFrameworkDockerfile struct {
	input.Input
}

func (*TestFrameworkDockerfile) GetInput

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

type TestPod

type TestPod struct {
	input.Input

	// Image is the image name used for testing, ex. quay.io/repo/operator-image
	Image string

	// TestNamespaceEnv is an env variable specifying the test namespace
	TestNamespaceEnv string
}

func (*TestPod) GetInput

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

type UserSetup struct {
	input.Input
}

UserSetup - userSetup script

func (*UserSetup) GetInput added in v0.5.0

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

Jump to

Keyboard shortcuts

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