{"modulePath":"github.phpd.cn/openshift/origin","version":"v4.1.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package trigger\n\n## Variables\n\n```go\nvar ErrUnresolvedTag = fmt.Errorf(\"one or more triggers on this object cannot be resolved\")\n```\nErrUnresolvedTag is used to indicate a resource is not ready to be triggered\n\n## Functions\n\n```go\nfunc NewTagRetriever(lister imagev1lister.ImageStreamLister) trigger.TagRetriever\n```\nNewTagRetriever will return a tag retriever that can look up image stream tag references from an image stream.\n\n```go\nfunc NewTriggerCache() cache.ThreadSafeStore\n```\nNewTriggerCache constructs a cacher that expects objects of type \\*trigger.CacheEntry and converts those triggers into entries in the thread safe cache by image stream namespace and name.\n\n```go\nfunc NewTriggerEventBroadcaster(client kv1core.CoreV1Interface) record.EventBroadcaster\n```\n\n```go\nfunc ProcessEvents(c cache.ThreadSafeStore, indexer trigger.Indexer, queue workqueue.RateLimitingInterface, tags trigger.TagRetriever) cache.ResourceEventHandler\n```\nProcessEvents returns a ResourceEventHandler suitable for use with an Informer to maintain the cache. indexer is responsible for calculating triggers and any pending changes. Operations are added to the operation queue if a change is required.\n\n## Types\n\n```go\ntype TriggerController struct {\n\t// contains filtered or unexported fields\n}\n```\nTriggerController updates fields on resources to the docker image reference that an ImageStreamTag points to. Different resource types may have different mechanisms for describing triggers (DeploymentConfigs and BuildConfigs have fields, other resource types use annotations) and different mechanisms for updating the objects. The provided TriggerSources map objects into a set of triggers (trigger.CacheEntry) watches for either object changes or image stream tag changes, and then calls a type specific ImageReactor function with the latest cached copy of the object. Because image triggers are explicitly level driven, the controller avoids pre- calculating the state of images, preferring to let the image reaction itself retrieve the latest tag. The controller will try forever to apply image changes but a backoff will be used.\n\nTrigger indexers must handle logical failures themselves (for types that don't do validation up front), and ImageReactors are responsible for applying type specific business logic (DeploymentConfigs do not fire for the first time until all potential images have resolved at least once).\n\n```go\nfunc NewTriggerController(eventBroadcaster record.EventBroadcaster, isInformer imagev1informer.ImageStreamInformer, sources ...TriggerSource) *TriggerController\n```\nNewTriggerController instantiates a trigger controller from the provided sources.\n\n```go\nfunc (c *TriggerController) Run(workers int, stopCh \u003c-chan struct{})\n```\nRun begins watching and syncing.\n\n```go\ntype TriggerSource struct {\n\t// Resource is a value guaranteed to be unique across all TriggerSources passed\n\t// to a given controller - used to separate keys processed by this controller.\n\tResource schema.GroupResource\n\t// Informer is the source of changes for the resource type.\n\tInformer cache.SharedInformer\n\t// Store is the latest in memory cache for the resource type.\n\tStore cache.Store\n\t// TriggerFn must return a function that converts an object returned by the\n\t// informer into a trigger.CacheEntry and add prefix to the trigger.CacheEntry key.\n\tTriggerFn func(prefix string) trigger.Indexer\n\t// Reactor is invoked when an image stream tag change is detected on one or\n\t// more of the triggers defined on the object.\n\tReactor trigger.ImageReactor\n}\n```\nTriggerSource defines the behavior for given resource type that can be triggered by image stream tag changes.\n\n","path":"github.phpd.cn/openshift/origin/pkg/image/controller/trigger","name":"trigger","synopsis":"","isRedistributable":true}
