Skip to content

Commit 4485f2f

Browse files
author
Phillip Wittrock
authored
Merge pull request #7 from pwittrock/iterations
Add godocs for inject packages
2 parents 105ee20 + ca1b152 commit 4485f2f

File tree

4 files changed

+120
-5
lines changed

4 files changed

+120
-5
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package controller_test
18+
19+
import "github.com/kubernetes-sigs/kubebuilder/pkg/controller"
20+
21+
func ExampleControllerManager() {
22+
// Create a new empty ControllerManager for managing Informers and Controllers
23+
var _ = &controller.ControllerManager{}
24+
}

pkg/inject/args/args.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,28 @@ func CreateInjectArgs(config *rest.Config) InjectArgs {
7777
}
7878
}
7979

80+
// Injector is used by code generators to register code generated objects
8081
type Injector struct {
81-
CRDs []*apiextensionsv1beta1.CustomResourceDefinition
82-
PolicyRules []rbacv1.PolicyRule
83-
GroupVersions []schema.GroupVersion
84-
Runnables []Runnable
85-
RunFns []RunFn
82+
// CRDs are CRDs that may be created / updated at startup
83+
CRDs []*apiextensionsv1beta1.CustomResourceDefinition
84+
85+
// PolicyRules are RBAC policy rules that may be installed with the controller
86+
PolicyRules []rbacv1.PolicyRule
87+
88+
// GroupVersions are the api group versions in the CRDs
89+
GroupVersions []schema.GroupVersion
90+
91+
// Runnables objects run with RunArguments
92+
Runnables []Runnable
93+
94+
// RunFns are functions run with RunArguments
95+
RunFns []RunFn
96+
97+
// ControllerManager is used to register Informers and Controllers
8698
ControllerManager *controller.ControllerManager
8799
}
88100

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

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

115+
// Runnable can be registered with an Injector and run
101116
type Runnable interface {
102117
Run(arguments run.RunArguments) error
103118
}

pkg/inject/args/example_args_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package args_test
18+
19+
import (
20+
"flag"
21+
"github.com/kubernetes-sigs/kubebuilder/pkg/config"
22+
"github.com/kubernetes-sigs/kubebuilder/pkg/inject/args"
23+
)
24+
25+
func Example() {
26+
flag.Parse()
27+
config := config.GetConfigOrDie()
28+
29+
// Create base arguments for initializing controllers
30+
var _ = args.CreateInjectArgs(config)
31+
}
32+
33+
func ExampleCreateInjectArgs() {
34+
flag.Parse()
35+
config := config.GetConfigOrDie()
36+
37+
// Create base arguments for initializing controllers
38+
var _ = args.CreateInjectArgs(config)
39+
}
40+
41+
func ExampleInjectArgs_CreateRecorder() {
42+
flag.Parse()
43+
config := config.GetConfigOrDie()
44+
45+
iargs := args.CreateInjectArgs(config)
46+
var _ = iargs.CreateRecorder("ControllerName")
47+
}

pkg/inject/run/example_args_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package run_test
18+
19+
import "github.com/kubernetes-sigs/kubebuilder/pkg/inject/run"
20+
21+
func Example() {
22+
// Create arguments for running Controllers
23+
var _ = run.CreateRunArguments()
24+
}
25+
26+
func ExampleCreateInjectArgs() {
27+
// Create arguments for running Controllers
28+
var _ = run.CreateRunArguments()
29+
}

0 commit comments

Comments
 (0)