/* Copyright 2020 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 app import ( "time" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/informers" "k8s.io/client-go/restmapper" "k8s.io/controller-manager/pkg/clientbuilder" "k8s.io/controller-manager/pkg/informerfactory" ) // ControllerContext defines the context object for controller type ControllerContext struct { // ClientBuilder will provide a client for this controller to use ClientBuilder clientbuilder.ControllerClientBuilder // InformerFactory gives access to informers for the controller. InformerFactory informers.SharedInformerFactory // ObjectOrMetadataInformerFactory gives access to informers for typed resources // and dynamic resources by their metadata. All generic controllers currently use // object metadata - if a future controller needs access to the full object this // would become GenericInformerFactory and take a dynamic client. ObjectOrMetadataInformerFactory informerfactory.InformerFactory // DeferredDiscoveryRESTMapper is a RESTMapper that will defer // initialization of the RESTMapper until the first mapping is // requested. RESTMapper *restmapper.DeferredDiscoveryRESTMapper // AvailableResources is a map listing currently available resources AvailableResources map[schema.GroupVersionResource]bool // Stop is the stop channel Stop <-chan struct{} // InformersStarted is closed after all of the controllers have been initialized and are running. After this point it is safe, // for an individual controller to start the shared informers. Before it is closed, they should not. InformersStarted chan struct{} // ResyncPeriod generates a duration each time it is invoked; this is so that // multiple controllers don't get into lock-step and all hammer the apiserver // with list requests simultaneously. ResyncPeriod func() time.Duration }