github.com/mrgossett/heapster@v0.18.2/sources.go (about) 1 // Copyright 2015 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "fmt" 19 20 "k8s.io/heapster/extpoints" 21 "k8s.io/heapster/sinks/cache" 22 "k8s.io/heapster/sources/api" 23 ) 24 25 func newSources(c cache.Cache) ([]api.Source, error) { 26 var sources []api.Source 27 for _, u := range argSources { 28 factory := extpoints.SourceFactories.Lookup(u.Key) 29 if factory == nil { 30 return nil, fmt.Errorf("Unknown source: %s", u.Key) 31 } 32 33 createdSources, err := factory(&u.Val, c) 34 if err != nil { 35 return nil, err 36 } 37 sources = append(sources, createdSources...) 38 } 39 return sources, nil 40 }