Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add godocs for inject packages
  • Loading branch information
pwittrock committed Mar 17, 2018
commit ca1b1522cc1616219065c5b119e120f305513b63
24 changes: 24 additions & 0 deletions pkg/controller/example_controllermanager_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controller_test

import "github.com/kubernetes-sigs/kubebuilder/pkg/controller"

func ExampleControllerManager() {
// Create a new empty ControllerManager for managing Informers and Controllers
var _ = &controller.ControllerManager{}
}
25 changes: 20 additions & 5 deletions pkg/inject/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,28 @@ func CreateInjectArgs(config *rest.Config) InjectArgs {
}
}

// Injector is used by code generators to register code generated objects
type Injector struct {
CRDs []*apiextensionsv1beta1.CustomResourceDefinition
PolicyRules []rbacv1.PolicyRule
GroupVersions []schema.GroupVersion
Runnables []Runnable
RunFns []RunFn
// CRDs are CRDs that may be created / updated at startup
CRDs []*apiextensionsv1beta1.CustomResourceDefinition

// PolicyRules are RBAC policy rules that may be installed with the controller
PolicyRules []rbacv1.PolicyRule

// GroupVersions are the api group versions in the CRDs
GroupVersions []schema.GroupVersion

// Runnables objects run with RunArguments
Runnables []Runnable

// RunFns are functions run with RunArguments
RunFns []RunFn

// ControllerManager is used to register Informers and Controllers
ControllerManager *controller.ControllerManager
}

// Run will run all of the registered RunFns and Runnables
func (i Injector) Run(a run.RunArguments) error {
for _, r := range i.Runnables {
go r.Run(a)
Expand All @@ -96,8 +109,10 @@ func (i Injector) Run(a run.RunArguments) error {
return nil
}

// RunFn can be registered with an Injector and run
type RunFn func(arguments run.RunArguments) error

// Runnable can be registered with an Injector and run
type Runnable interface {
Run(arguments run.RunArguments) error
}
47 changes: 47 additions & 0 deletions pkg/inject/args/example_args_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package args_test

import (
"flag"
"github.com/kubernetes-sigs/kubebuilder/pkg/config"
"github.com/kubernetes-sigs/kubebuilder/pkg/inject/args"
)

func Example() {
flag.Parse()
config := config.GetConfigOrDie()

// Create base arguments for initializing controllers
var _ = args.CreateInjectArgs(config)
}

func ExampleCreateInjectArgs() {
flag.Parse()
config := config.GetConfigOrDie()

// Create base arguments for initializing controllers
var _ = args.CreateInjectArgs(config)
}

func ExampleInjectArgs_CreateRecorder() {
flag.Parse()
config := config.GetConfigOrDie()

iargs := args.CreateInjectArgs(config)
var _ = iargs.CreateRecorder("ControllerName")
}
29 changes: 29 additions & 0 deletions pkg/inject/run/example_args_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package run_test

import "github.com/kubernetes-sigs/kubebuilder/pkg/inject/run"

func Example() {
// Create arguments for running Controllers
var _ = run.CreateRunArguments()
}

func ExampleCreateInjectArgs() {
// Create arguments for running Controllers
var _ = run.CreateRunArguments()
}