scaffold

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: Apache-2.0 Imports: 20 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"
	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 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 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-zA-Z]+$")
	// ResourceGroupRegexp matches Kubernetes API Group's.
	ResourceGroupRegexp = regexp.MustCompile("^[a-z]+$")
)

Functions

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 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 Cr

type Cr struct {
	input.Input

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

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
}

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

func (*Crd) GetInput

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

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

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

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

func (*Role) GetInput

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

type RoleBinding

type RoleBinding struct {
	input.Input
}

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

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