Documentation ¶
Index ¶
- Constants
- func AddToFrameworkScheme(addToScheme addToSchemeFunc, obj dynclient.ObjectList) error
- func ExecCmd(cmd *exec.Cmd) error
- func GetGoPkg() string
- func GetKubeconfigAndNamespace(configPath string) (*rest.Config, string, error)
- func GoBuild(opts GoCmdOptions) error
- func GoCmd(cmd string, opts GoCmdOptions) error
- func GoModOn() (bool, error)
- func MainEntry(m *testing.M)
- func MustGetwd() string
- func MustSetWdGopath(currentGopath string) string
- type CleanupOptions
- type Context
- func (ctx *Context) AddCleanupFn(fn cleanupFn)
- func (ctx *Context) Cleanup()
- func (ctx *Context) GetID() string
- func (ctx *Context) GetNamespace() (string, error)
- func (ctx *Context) GetOperatorNamespace() (string, error)
- func (ctx *Context) GetWatchNamespace() (string, error)
- func (ctx *Context) InitializeClusterResources(cleanupOptions *CleanupOptions) error
- type ErrUnknownOperatorType
- type Framework
- type FrameworkClient
- type GoCmdOptions
- type GoTestOptions
- type OperatorType
- type Scanner
- type TestCtxdeprecated
Constants ¶
const ( // dirs CmdDir = "cmd" ManagerDir = CmdDir + filePathSep + "manager" BuildDir = "build" BuildBinDir = BuildDir + filePathSep + "_output" + filePathSep + "bin" )
from the old operator-sdk scaffold constants
const ( // KubeConfigEnvVar defines the env variable KUBECONFIG which // contains the kubeconfig file path. KubeConfigEnvVar = "KUBECONFIG" // WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE // which is the namespace where the watch activity happens. // this value is empty if the operator is running with clusterScope. WatchNamespaceEnvVar = "WATCH_NAMESPACE" )
const ( ProjRootFlag = "root" KubeConfigFlag = "kubeconfig" NamespacedManPathFlag = "namespacedMan" GlobalManPathFlag = "globalMan" LocalOperatorFlag = "localOperator" LocalOperatorArgs = "localOperatorArgs" SkipCleanupOnErrorFlag = "skipCleanupOnError" TestOperatorNamespaceEnv = "TEST_OPERATOR_NAMESPACE" TestWatchNamespaceEnv = "TEST_WATCH_NAMESPACE" TestBundleInstallEnv = "TEST_BUNDLE_INSTALL" )
const ( GoPathEnv = "GOPATH" GoModEnv = "GO111MODULE" SrcDir = "src" )
Variables ¶
This section is empty.
Functions ¶
func AddToFrameworkScheme ¶
func AddToFrameworkScheme(addToScheme addToSchemeFunc, obj dynclient.ObjectList) error
AddToFrameworkScheme allows users to add the scheme for their custom resources to the framework's scheme for use with the dynamic client. The user provides the addToScheme function (located in the register.go file of their operator project) and the List struct for their custom resource. For example, for a memcached operator, the list stuct may look like: &MemcachedList{} The List object is needed because the CRD has not always been fully registered by the time this function is called. If the CRD takes more than 5 seconds to become ready, this function throws an error
func GetGoPkg ¶
func GetGoPkg() string
TODO(hasbro17): If this function is called in the subdir of a module project it will fail to parse go.mod and return the correct import path. This needs to be fixed to return the pkg import path for any subdir in order for `generate csv` to correctly form pkg imports for API pkg paths that are not relative to the root dir. This might not be fixable since there is no good way to get the project root from inside the subdir of a module project.
GetGoPkg returns the current directory's import path by parsing it from wd if this project's repository path is rooted under $GOPATH/src, or from go.mod the project uses Go modules to manage dependencies. If the project has a go.mod then wd must be the project root.
Example: "github.com/example-inc/app-operator"
func GetKubeconfigAndNamespace ¶
GetKubeconfigAndNamespace returns the *rest.Config and default namespace defined in the kubeconfig at the specified path. If no path is provided, returns the default *rest.Config and namespace
func GoModOn ¶
From https://github.com/golang/go/wiki/Modules:
You can activate module support in one of two ways: - Invoke the go command in a directory with a valid go.mod file in the current directory or any parent of it and the environment variable GO111MODULE unset (or explicitly set to auto). - Invoke the go command with GO111MODULE=on environment variable set.
GoModOn returns true if Go modules are on in one of the above two ways.
func MustSetWdGopath ¶
MustSetWdGopath sets GOPATH to the first element of the path list in currentGopath that prefixes the wd, then returns the set path. If GOPATH cannot be set, MustSetWdGopath exits.
Types ¶
type CleanupOptions ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) AddCleanupFn ¶
func (ctx *Context) AddCleanupFn(fn cleanupFn)
func (*Context) GetNamespace ¶
TODO: remove before 1.0.0 Deprecated: GetNamespace() exists for historical compatibility. Use GetOperatorNamespace() or GetWatchNamespace() instead
func (*Context) GetOperatorNamespace ¶
GetOperatorNamespace will return an Operator Namespace, if the flag --operator-namespace not be used (TestOpeatorNamespaceEnv not set) then it will create a new namespace with randon name and return that namespace
func (*Context) GetWatchNamespace ¶
GetWatchNamespace will return the namespaces to operator watch for changes, if the flag --watch-namespaced not be used then it will return the Operator Namespace.
func (*Context) InitializeClusterResources ¶
func (ctx *Context) InitializeClusterResources(cleanupOptions *CleanupOptions) error
type ErrUnknownOperatorType ¶
type ErrUnknownOperatorType struct {
Type string
}
func (ErrUnknownOperatorType) Error ¶
func (e ErrUnknownOperatorType) Error() string
type Framework ¶
type Framework struct { Client *frameworkClient KubeConfig *rest.Config KubeClient kubernetes.Interface Scheme *runtime.Scheme NamespacedManPath *string OperatorNamespace string WatchNamespace string LocalOperator bool // contains filtered or unexported fields }
var ( // Global framework struct Global *Framework )
type FrameworkClient ¶
type FrameworkClient interface { Get(gCtx goctx.Context, key dynclient.ObjectKey, obj dynclient.Object) error List(gCtx goctx.Context, list dynclient.ObjectList, opts ...dynclient.ListOption) error Create(gCtx goctx.Context, obj dynclient.Object, cleanupOptions *CleanupOptions) error Delete(gCtx goctx.Context, obj dynclient.Object, opts ...dynclient.DeleteOption) error Update(gCtx goctx.Context, obj dynclient.Object) error }
type GoCmdOptions ¶
type GoCmdOptions struct { // BinName is the name of the compiled binary, passed to -o. BinName string // Args are args passed to "go {cmd}", aside from "-o {bin_name}" and // test binary args. // These apply to build, clean, get, install, list, run, and test. Args []string // PackagePath is the path to the main (go build) or test (go test) packages. PackagePath string // Env is a list of environment variables to pass to the cmd; // exec.Command.Env is set to this value. Env []string // Dir is the dir to run "go {cmd}" in; exec.Command.Dir is set to this value. Dir string }
GoCmdOptions is the base option set for "go" subcommands.
type GoTestOptions ¶
type GoTestOptions struct { GoCmdOptions // TestBinaryArgs are args passed to the binary compiled by "go test". TestBinaryArgs []string }
GoTestOptions is the set of options for "go test".
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner scans a yaml manifest file for manifest tokens delimited by "---". See bufio.Scanner for semantics.