2 Copyright 2015 The Kubernetes Authors.
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
19 // SchemeBuilder collects functions that add things to a scheme. It's to allow
20 // code to compile without explicitly referencing generated types. You should
21 // declare one in each package that will have generated deep copy or conversion
23 type SchemeBuilder []func(*Scheme) error
25 // AddToScheme applies all the stored functions to the scheme. A non-nil error
26 // indicates that one function failed and the attempt was abandoned.
27 func (sb *SchemeBuilder) AddToScheme(s *Scheme) error {
28 for _, f := range *sb {
29 if err := f(s); err != nil {
36 // Register adds a scheme setup function to the list.
37 func (sb *SchemeBuilder) Register(funcs ...func(*Scheme) error) {
38 for _, f := range funcs {
43 // NewSchemeBuilder calls Register for you.
44 func NewSchemeBuilder(funcs ...func(*Scheme) error) SchemeBuilder {