move parse or die logic to selector.go

This commit is contained in:
combk8s
2015-12-17 19:57:07 +08:00
parent 3cc588b5be
commit f697732a5d
4 changed files with 14 additions and 24 deletions

View File

@@ -62,7 +62,7 @@ func New(kubeClient client.Interface, resyncPeriod controller.ResyncPeriodFunc,
},
}
terminatedSelector := compileTerminatedPodSelector()
terminatedSelector := fields.ParseSelectorOrDie("status.phase!=" + string(api.PodPending) + ",status.phase!=" + string(api.PodRunning) + ",status.phase!=" + string(api.PodUnknown))
gcc.podStore.Store, gcc.podStoreSyncer = framework.NewInformer(
&cache.ListWatch{
@@ -114,14 +114,6 @@ func (gcc *GCController) gc() {
wait.Wait()
}
func compileTerminatedPodSelector() fields.Selector {
selector, err := fields.ParseSelector("status.phase!=" + string(api.PodPending) + ",status.phase!=" + string(api.PodRunning) + ",status.phase!=" + string(api.PodUnknown))
if err != nil {
panic("terminatedSelector must compile: " + err.Error())
}
return selector
}
// byCreationTimestamp sorts a list by creation timestamp, using their names as a tie breaker.
type byCreationTimestamp []*api.Pod