Documentation ¶
Overview ¶
Package config contains functionality for interacting with ComponentConfig files
DeferredFileLoader ¶
This uses a deferred file decoding allowing you to chain your configuration setup. You can pass this into manager.Options#File and it will load your config.
Index ¶
- type ControllerManagerConfiguration
- type DeferredFileLoader
- func (d *DeferredFileLoader) AtPath(path string) *DeferredFileLoader
- func (d *DeferredFileLoader) Complete() (v1alpha1.ControllerManagerConfigurationSpec, error)
- func (d *DeferredFileLoader) InjectScheme(scheme *runtime.Scheme) error
- func (d *DeferredFileLoader) OfKind(obj ControllerManagerConfiguration) *DeferredFileLoader
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControllerManagerConfiguration ¶
type ControllerManagerConfiguration interface { runtime.Object // Complete returns the versioned configuration Complete() (v1alpha1.ControllerManagerConfigurationSpec, error) }
ControllerManagerConfiguration defines the functions necessary to parse a config file and to configure the Options struct for the ctrl.Manager
type DeferredFileLoader ¶
type DeferredFileLoader struct { ControllerManagerConfiguration // contains filtered or unexported fields }
DeferredFileLoader is used to configure the decoder for loading controller runtime component config types
Example (AtPath) ¶
This example will load the file from a custom path
package main import ( "fmt" "os" "sigs.k8s.io/controller-runtime/pkg/config" ) func main() { loader := config.File().AtPath("/var/run/controller-runtime/config.yaml") _, err := loader.Complete() if err != nil { fmt.Println("failed to load config") os.Exit(1) } }
Output:
Example (InjectScheme) ¶
This example sets up loader with a custom scheme
package main import ( "fmt" "os" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/config" "sigs.k8s.io/controller-runtime/examples/configfile/custom/v1alpha1" ) var scheme = runtime.NewScheme() func init() { _ = v1alpha1.AddToScheme(scheme) } func main() { loader := config.File() err := loader.InjectScheme(scheme) if err != nil { fmt.Println("failed to inject scheme") os.Exit(1) } _, err = loader.Complete() if err != nil { fmt.Println("failed to load config") os.Exit(1) } }
Output:
Example (OfKind) ¶
This example sets up the loader with a custom scheme and custom type
package main import ( "fmt" "os" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/config" "sigs.k8s.io/controller-runtime/examples/configfile/custom/v1alpha1" ) var scheme = runtime.NewScheme() func init() { _ = v1alpha1.AddToScheme(scheme) } func main() { loader := config.File().OfKind(&v1alpha1.CustomControllerManagerConfiguration{}) err := loader.InjectScheme(scheme) if err != nil { fmt.Println("failed to inject scheme") os.Exit(1) } _, err = loader.Complete() if err != nil { fmt.Println("failed to load config") os.Exit(1) } }
Output:
func File ¶
func File() *DeferredFileLoader
File will set up the deferred file loader for the configuration this will also configure the defaults for the loader if nothing is
Defaults:
Path: "./config.yaml" Kind: GenericControllerManagerConfiguration
Example ¶
This example will load a file using Complete with only defaults set.
package main import ( "fmt" "os" "sigs.k8s.io/controller-runtime/pkg/config" ) func main() { // This will load a config file from ./config.yaml loader := config.File() _, err := loader.Complete() if err != nil { fmt.Println("failed to load config") os.Exit(1) } }
Output:
func (*DeferredFileLoader) AtPath ¶
func (d *DeferredFileLoader) AtPath(path string) *DeferredFileLoader
AtPath will set the path to load the file for the decoder
func (*DeferredFileLoader) Complete ¶
func (d *DeferredFileLoader) Complete() (v1alpha1.ControllerManagerConfigurationSpec, error)
Complete will use sync.Once to set the scheme
func (*DeferredFileLoader) InjectScheme ¶
func (d *DeferredFileLoader) InjectScheme(scheme *runtime.Scheme) error
InjectScheme will configure the scheme to be used for decoding the file
func (*DeferredFileLoader) OfKind ¶
func (d *DeferredFileLoader) OfKind(obj ControllerManagerConfiguration) *DeferredFileLoader
OfKind will set the type to be used for decoding the file into