CINXE.COM

handler package - sigs.k8s.io/controller-runtime/pkg/handler - Go Packages

<!DOCTYPE html> <html lang="en" data-layout="responsive" data-local=""> <head> <script> window.addEventListener('error', window.__err=function f(e){f.p=f.p||[];f.p.push(e)}); </script> <script> (function() { const theme = document.cookie.match(/prefers-color-scheme=(light|dark|auto)/)?.[1] if (theme) { document.querySelector('html').setAttribute('data-theme', theme); } }()) </script> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="Description" content="Package handler defines EventHandlers that enqueue reconcile.Requests in response to Create, Update, Deletion Events observed from Watching Kubernetes APIs."> <meta class="js-gtmID" data-gtmid="GTM-W8MVQXG"> <link rel="shortcut icon" href="/static/shared/icon/favicon.ico"> <link rel="canonical" href="https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/handler"> <link href="/static/frontend/frontend.min.css?version=prod-frontend-00090-vzc" rel="stylesheet"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Go Packages"> <title>handler package - sigs.k8s.io/controller-runtime/pkg/handler - Go Packages</title> <link href="/static/frontend/unit/unit.min.css?version=prod-frontend-00090-vzc" rel="stylesheet"> <link href="/static/frontend/unit/main/main.min.css?version=prod-frontend-00090-vzc" rel="stylesheet"> </head> <body> <script> function loadScript(src, mod = true) { let s = document.createElement('script'); s.src = src; if (mod) { s.type = 'module'; s.async = true; s.defer = true } document.head.appendChild(s); } loadScript("/third_party/dialog-polyfill/dialog-polyfill.js", false) loadScript("/static/frontend/frontend.js"); </script> <header class="go-Header go-Header--full js-siteHeader"> <div class="go-Header-inner go-Header-inner--dark"> <nav class="go-Header-nav"> <a href="https://go.dev/" class="js-headerLogo" data-gtmc="nav link" data-test-id="go-header-logo-link" role="heading" aria-level="1"> <img class="go-Header-logo" src="/static/shared/logo/go-white.svg" alt="Go"> </a> <div class="skip-navigation-wrapper"> <a class="skip-to-content-link" aria-label="Skip to main content" href="#main-content"> Skip to Main Content </a> </div> <div class="go-Header-rightContent"> <div class="go-SearchForm js-searchForm"> <form class="go-InputGroup go-ShortcutKey go-SearchForm-form" action="/search" data-shortcut="/" data-shortcut-alt="search" data-gtmc="search form" aria-label="Search for a package" role="search" > <input name="q" class="go-Input js-searchFocus" aria-label="Search for a package" type="search" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" placeholder="Search packages or symbols" value="" /> <input name="m" value="" hidden> <button class="go-Button go-Button--inverted" aria-label="Submit search"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/search_gm_grey_24dp.svg" alt="" /> </button> </form> <button class="go-SearchForm-expandSearch js-expandSearch" data-gtmc="nav button" aria-label="Open search" data-test-id="expand-search"> <img class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/search_gm_grey_24dp.svg" alt=""> </button> </div> <ul class="go-Header-menu"> <li class="go-Header-menuItem"> <a class="js-desktop-menu-hover" href="#" data-gtmc="nav link"> Why Go <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_drop_down_gm_grey_24dp.svg" alt="submenu dropdown icon"> </a> <ul class="go-Header-submenu go-Header-submenu--why js-desktop-submenu-hover" aria-label="submenu"> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/solutions#case-studies"> </span>Case Studies</span> </a> </div> <p>Common problems companies solve with Go</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/solutions#use-cases"> </span>Use Cases</span> </a> </div> <p>Stories about how and why companies use Go</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/security/policy/"> </span>Security Policy</span> </a> </div> <p>How Go can help keep you secure by default</p> </li> </ul> </li> <li class="go-Header-menuItem"> <a href="https://go.dev/learn/" data-gtmc="nav link">Learn</a> </li> <li class="go-Header-menuItem"> <a class="js-desktop-menu-hover" href="#" data-gtmc="nav link"> Docs <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_drop_down_gm_grey_24dp.svg" alt="submenu dropdown icon"> </a> <ul class="go-Header-submenu go-Header-submenu--docs js-desktop-submenu-hover" aria-label="submenu"> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/doc/effective_go"> <span>Effective Go</span> </a> </div> <p>Tips for writing clear, performant, and idiomatic Go code</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/doc/"> <span>Go User Manual</span> </a> </div> <p>A complete introduction to building software with Go</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://pkg.go.dev/std"> <span>Standard library</span> </a> </div> <p>Reference documentation for Go's standard library</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/doc/devel/release"> <span>Release Notes</span> </a> </div> <p>Learn what's new in each Go release</p> </li> </ul> </li> <li class="go-Header-menuItem go-Header-menuItem--active"> <a href="/" data-gtmc="nav link">Packages</a> </li> <li class="go-Header-menuItem"> <a class="js-desktop-menu-hover" href="#" data-gtmc="nav link"> Community <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_drop_down_gm_grey_24dp.svg" alt="submenu dropdown icon"> </a> <ul class="go-Header-submenu go-Header-submenu--community js-desktop-submenu-hover" aria-label="submenu"> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/talks/"> <span>Recorded Talks</span> </a> </div> <p>Videos from prior events</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://www.meetup.com/pro/go"> <span>Meetups</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </div> <p>Meet other local Go developers</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://github.com/golang/go/wiki/Conferences"> <span>Conferences</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </div> <p>Learn and network with Go developers from around the world</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/blog"> <span>Go blog</span> </a> </div> <p>The Go project's official blog.</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/help"> <span>Go project</span> </a> </div> <p>Get help and stay informed from Go</p> </li> <li class="go-Header-submenuItem"> <div> Get connected </div> <p></p> <div class="go-Header-socialIcons"> <a class="go-Header-socialIcon" aria-label="Get connected with google-groups (Opens in new window)" href="https://groups.google.com/g/golang-nuts" ><img src="/static/shared/logo/social/google-groups.svg" /></a> <a class="go-Header-socialIcon" aria-label="Get connected with github (Opens in new window)" href="https://github.com/golang"><img src="/static/shared/logo/social/github.svg" /></a> <a class="go-Header-socialIcon" aria-label="Get connected with twitter (Opens in new window)" href="https://twitter.com/golang"><img src="/static/shared/logo/social/twitter.svg" /></a> <a class="go-Header-socialIcon" aria-label="Get connected with reddit (Opens in new window)" href="https://www.reddit.com/r/golang/"><img src="/static/shared/logo/social/reddit.svg" /></a> <a class="go-Header-socialIcon" aria-label="Get connected with slack (Opens in new window)" href="https://invite.slack.golangbridge.org/"><img src="/static/shared/logo/social/slack.svg" /></a> <a class="go-Header-socialIcon" aria-label="Get connected with stack-overflow (Opens in new window)" href="https://stackoverflow.com/collectives/go"><img src="/static/shared/logo/social/stack-overflow.svg" /></a> </div> </li> </ul> </li> </ul> <button class="go-Header-navOpen js-headerMenuButton go-Header-navOpen--white" data-gtmc="nav button" aria-label="Open navigation"> </button> </div> </nav> </div> </header> <aside class="go-NavigationDrawer js-header"> <nav class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="https://go.dev/"> <img class="go-NavigationDrawer-logo" src="/static/shared/logo/go-blue.svg" alt="Go."> </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem js-mobile-subnav-trigger go-NavigationDrawer-hasSubnav"> <a href="#"> <span>Why Go</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_next_gm_grey_24dp.svg" alt=""> </i> </a> <div class="go-NavigationDrawer go-NavigationDrawer-submenuItem"> <div class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="#"> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_before_gm_grey_24dp.svg" alt=""> </i> Why Go </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/solutions#case-studies"> Case Studies </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/solutions#use-cases"> Use Cases </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/security/policy/"> Security Policy </a> </li> </ul> </div> </div> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/learn/">Learn</a> </li> <li class="go-NavigationDrawer-listItem js-mobile-subnav-trigger go-NavigationDrawer-hasSubnav"> <a href="#"> <span>Docs</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_next_gm_grey_24dp.svg" alt=""> </i> </a> <div class="go-NavigationDrawer go-NavigationDrawer-submenuItem"> <div class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="#"><i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_before_gm_grey_24dp.svg" alt=""> </i> Docs </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/doc/effective_go"> Effective Go </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/doc/"> Go User Manual </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://pkg.go.dev/std"> Standard library </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/doc/devel/release"> Release Notes </a> </li> </ul> </div> </div> </li> <li class="go-NavigationDrawer-listItem go-NavigationDrawer-listItem--active"> <a href="/">Packages</a> </li> <li class="go-NavigationDrawer-listItem js-mobile-subnav-trigger go-NavigationDrawer-hasSubnav"> <a href="#"> <span>Community</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_next_gm_grey_24dp.svg" alt=""> </i> </a> <div class="go-NavigationDrawer go-NavigationDrawer-submenuItem"> <div class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="#"> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_before_gm_grey_24dp.svg" alt=""> </i> Community </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/talks/"> Recorded Talks </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://www.meetup.com/pro/go"> Meetups <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://github.com/golang/go/wiki/Conferences"> Conferences <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/blog"> Go blog </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/help"> Go project </a> </li> <li class="go-NavigationDrawer-listItem"> <div>Get connected</div> <div class="go-Header-socialIcons"> <a class="go-Header-socialIcon" href="https://groups.google.com/g/golang-nuts"><img src="/static/shared/logo/social/google-groups.svg" /></a> <a class="go-Header-socialIcon" href="https://github.com/golang"><img src="/static/shared/logo/social/github.svg" /></a> <a class="go-Header-socialIcon" href="https://twitter.com/golang"><img src="/static/shared/logo/social/twitter.svg" /></a> <a class="go-Header-socialIcon" href="https://www.reddit.com/r/golang/"><img src="/static/shared/logo/social/reddit.svg" /></a> <a class="go-Header-socialIcon" href="https://invite.slack.golangbridge.org/"><img src="/static/shared/logo/social/slack.svg" /></a> <a class="go-Header-socialIcon" href="https://stackoverflow.com/collectives/go"><img src="/static/shared/logo/social/stack-overflow.svg" /></a> </div> </li> </ul> </div> </div> </li> </ul> </nav> </aside> <div class="go-NavigationDrawer-scrim js-scrim" role="presentation"></div> <main class="go-Main" id="main-content"> <div class="go-Main-banner" role="alert"></div> <header class="go-Main-header js-mainHeader"> <nav class="go-Main-headerBreadcrumb go-Breadcrumb" aria-label="Breadcrumb" data-test-id="UnitHeader-breadcrumb"> <ol> <li data-test-id="UnitHeader-breadcrumbItem"> <a href="/" data-gtmc="breadcrumb link">Discover Packages</a> </li> <li data-test-id="UnitHeader-breadcrumbItem"> <a href="/sigs.k8s.io/controller-runtime" data-gtmc="breadcrumb link">sigs.k8s.io/controller-runtime</a> </li> <li data-test-id="UnitHeader-breadcrumbItem"> <a href="/sigs.k8s.io/controller-runtime/pkg" data-gtmc="breadcrumb link">pkg</a> </li> <li> <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/handler" data-gtmc="breadcrumb link" aria-current="location" data-test-id="UnitHeader-breadcrumbCurrent"> handler </a> <button class="go-Button go-Button--inline go-Clipboard js-clipboard" title="Copy path to clipboard.&#10;&#10;sigs.k8s.io/controller-runtime/pkg/handler" aria-label="Copy Path to Clipboard" data-to-copy="sigs.k8s.io/controller-runtime/pkg/handler" data-gtmc="breadcrumbs button" > <img class="go-Icon go-Icon--accented" height="24" width="24" src="/static/shared/icon/content_copy_gm_grey_24dp.svg" alt="" > </button> </li> </ol> </nav> <div class="go-Main-headerContent"> <div class="go-Main-headerTitle js-stickyHeader"> <a class="go-Main-headerLogo" href="https://go.dev/" aria-hidden="true" tabindex="-1" data-gtmc="header link" aria-label="Link to Go Homepage"> <img height="78" width="207" src="/static/shared/logo/go-blue.svg" alt="Go"> </a> <h1 class="UnitHeader-titleHeading" data-test-id="UnitHeader-title">handler</h1> <span class="go-Chip go-Chip--inverted">package</span> <button class="go-Button go-Button--inline go-Clipboard js-clipboard" title="Copy path to clipboard.&#10;&#10;sigs.k8s.io/controller-runtime/pkg/handler" aria-label="Copy Path to Clipboard" data-to-copy="sigs.k8s.io/controller-runtime/pkg/handler" data-gtmc="title button" tabindex="-1" > <img class="go-Icon go-Icon--accented" height="24" width="24" src="/static/shared/icon/content_copy_gm_grey_24dp.svg" alt="" /> </button> </div> <div class="go-Main-headerDetails"> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-version"> <a href="?tab=versions" aria-label="Version: v0.19.2" data-gtmc="header link" aria-describedby="version-description"> <span class="go-textSubtle" aria-hidden="true">Version: </span> v0.19.2 </a> <div class="screen-reader-only" id="version-description" hidden> Opens a new window with list of versions in this module. </div> <span class="DetailsHeader-badge--latest" data-test-id="UnitHeader-minorVersionBanner"> <span class="go-Chip DetailsHeader-span--latest">Latest</span> <span class="go-Chip DetailsHeader-span--notAtLatest"> Latest <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary> <img class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/alert_gm_grey_24dp.svg" alt="Warning"> </summary> <p>This package is not in the latest version of its module.</p> </details> </span> <a href="/sigs.k8s.io/controller-runtime/pkg/handler" aria-label="Go to Latest Version" data-gtmc="header link"> <span class="go-Chip go-Chip--alert DetailsHeader-span--goToLatest">Go to latest</span> </a> </span> </span> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-commitTime"> Published: Nov 21, 2024 </span> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-licenses"> License: <a href="/sigs.k8s.io/controller-runtime/pkg/handler?tab=licenses" data-test-id="UnitHeader-license" data-gtmc="header link" aria-describedby="license-description">Apache-2.0</a> </span> <div class="screen-reader-only" id="license-description" hidden> Opens a new window with license information. </div> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-imports"> <a href="/sigs.k8s.io/controller-runtime/pkg/handler?tab=imports" aria-label="Imports: 13" data-gtmc="header link" aria-describedby="imports-description"> <span class="go-textSubtle">Imports: </span>13 </a> </span> <div class="screen-reader-only" id="imports-description" hidden> Opens a new window with list of imports. </div> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-importedby"> <a href="/sigs.k8s.io/controller-runtime/pkg/handler?tab=importedby" aria-label="Imported By: 5,285" data-gtmc="header link" aria-describedby="importedby-description"> <span class="go-textSubtle">Imported by: </span>5,285 </a> </span> <div class="screen-reader-only" id="importedby-description" hidden> Opens a new window with list of known importers. </div> </div> <div class="UnitHeader-overflowContainer"> <svg class="UnitHeader-overflowImage" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"> <path d="M0 0h24v24H0z" fill="none"/> <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/> </svg> <select class="UnitHeader-overflowSelect js-selectNav" tabindex="-1"> <option value="/">Main</option> <option value="/sigs.k8s.io/controller-runtime/pkg/handler?tab=versions"> Versions </option> <option value="/sigs.k8s.io/controller-runtime/pkg/handler?tab=licenses"> Licenses </option> <option value="/sigs.k8s.io/controller-runtime/pkg/handler?tab=imports"> Imports </option> <option value="/sigs.k8s.io/controller-runtime/pkg/handler?tab=importedby"> Imported By </option> </select> </div> </div> </header> <aside class="go-Main-aside js-mainAside"> <div class="UnitMeta"> <h2 class="go-textLabel">Details</h2> <ul class="UnitMeta-details"> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked"height="24" width="24"> Valid <a href="https://github.com/kubernetes-sigs/controller-runtime/tree/v0.19.2/go.mod" target="_blank" rel="noopener">go.mod</a> file <img class="go-Icon" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" height="24" width="24"> </summary> <p> The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go. </p> </details> </li> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked"height="24" width="24"> Redistributable license <img class="go-Icon" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" height="24" width="24"> </summary> <p> Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed. </p> </details> </li> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked"height="24" width="24"> Tagged version <img class="go-Icon" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" height="24" width="24"> </summary> <p>Modules with tagged versions give importers more predictable builds.</p> </details> </li> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon"src="/static/shared/icon/cancel_gm_grey_24dp.svg" alt="unchecked"height="24" width="24"> Stable version <img class="go-Icon" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" height="24" width="24"> </summary> <p>When a project reaches major version v1 it is considered stable.</p> </details> </li> <li class="UnitMeta-detailsLearn"> <a href="/about#best-practices" data-gtmc="meta link">Learn more about best practices</a> </li> </ul> <h2 class="go-textLabel">Repository</h2> <div class="UnitMeta-repo"> <a href="https://github.com/kubernetes-sigs/controller-runtime" title="https://github.com/kubernetes-sigs/controller-runtime" target="_blank" rel="noopener"> github.com/kubernetes-sigs/controller-runtime </a> </div> <h2 class="go-textLabel">Links</h2> <ul class="UnitMeta-links"> <li> <a href="https://deps.dev/go/sigs.k8s.io%2Fcontroller-runtime/v0.19.2" title="View this module on Open Source Insights" target="_blank" rel="noopener" data-test-id="meta-link-depsdev"> <img class="depsdev-Icon" src="/static/shared/icon/depsdev-logo.svg" alt="Open Source Insights Logo" /> Open Source Insights </a> </li> </ul> </div> </aside> <nav class="go-Main-nav go-Main-nav--sticky js-mainNav" aria-label="Outline"> <div class="go-Main-navDesktop"> <div class="UnitOutline-jumpTo"> <button class="UnitOutline-jumpToInput go-ShortcutKey js-jumpToInput" aria-controls="jump-to-modal" aria-label="Open Jump to Identifier" data-shortcut="f" data-shortcut-alt="find" data-test-id="jump-to-button" data-gtmc="outline button"> Jump to ... </button> </div> <ul class="go-Tree js-tree" role="tree" aria-label="Outline"> <li> <a href="#section-documentation" data-gtmc="outline link"> Documentation </a> <ul> <li> <a href="#pkg-overview" data-gtmc="doc outline link">Overview</a> </li> <li class="DocNav-overview"> <a href="#pkg-index" data-gtmc="doc outline link"> Index </a> <ul> <li> <a href="#pkg-examples" data-gtmc="doc outline link"> Examples </a> </li> </ul> </li> <li class="DocNav-constants"> <a href="#pkg-constants" data-gtmc="doc outline link"> Constants </a> </li> <li class="DocNav-variables"> <a href="#pkg-variables" data-gtmc="doc outline link"> Variables </a> </li> <li class="DocNav-functions"> <a href="#pkg-functions" data-gtmc="doc outline link"> Functions </a> </li> <li class="DocNav-types"> <a href="#pkg-types" data-gtmc="doc outline link"> Types </a> <ul> <li> <a href="#EnqueueRequestForObject" title="type EnqueueRequestForObject" data-gtmc="doc outline link"> type EnqueueRequestForObject </a> </li> <li> <a href="#EventHandler" title="type EventHandler" data-gtmc="doc outline link"> type EventHandler </a> <ul> <li> <a href="#EnqueueRequestForOwner" title="EnqueueRequestForOwner(scheme, mapper, ownerType, opts)" data-gtmc="doc outline link"> EnqueueRequestForOwner(scheme, mapper, ownerType, opts) </a> </li> <li> <a href="#EnqueueRequestsFromMapFunc" title="EnqueueRequestsFromMapFunc(fn)" data-gtmc="doc outline link"> EnqueueRequestsFromMapFunc(fn) </a> </li> </ul> </li> <li> <a href="#Funcs" title="type Funcs" data-gtmc="doc outline link"> type Funcs </a> </li> <li> <a href="#MapFunc" title="type MapFunc" data-gtmc="doc outline link"> type MapFunc </a> </li> <li> <a href="#OwnerOption" title="type OwnerOption" data-gtmc="doc outline link"> type OwnerOption </a> <ul> <li> <a href="#OnlyControllerOwner" title="OnlyControllerOwner()" data-gtmc="doc outline link"> OnlyControllerOwner() </a> </li> </ul> </li> <li> <a href="#TypedEnqueueRequestForObject" title="type TypedEnqueueRequestForObject" data-gtmc="doc outline link"> type TypedEnqueueRequestForObject </a> <ul> <li> <a href="#TypedEnqueueRequestForObject.Create" title="(e) Create(ctx, evt, q)" data-gtmc="doc outline link"> (e) Create(ctx, evt, q) </a> </li> <li> <a href="#TypedEnqueueRequestForObject.Delete" title="(e) Delete(ctx, evt, q)" data-gtmc="doc outline link"> (e) Delete(ctx, evt, q) </a> </li> <li> <a href="#TypedEnqueueRequestForObject.Generic" title="(e) Generic(ctx, evt, q)" data-gtmc="doc outline link"> (e) Generic(ctx, evt, q) </a> </li> <li> <a href="#TypedEnqueueRequestForObject.Update" title="(e) Update(ctx, evt, q)" data-gtmc="doc outline link"> (e) Update(ctx, evt, q) </a> </li> </ul> </li> <li> <a href="#TypedEventHandler" title="type TypedEventHandler" data-gtmc="doc outline link"> type TypedEventHandler </a> <ul> <li> <a href="#TypedEnqueueRequestForOwner" title="TypedEnqueueRequestForOwner(scheme, mapper, ownerType, opts)" data-gtmc="doc outline link"> TypedEnqueueRequestForOwner(scheme, mapper, ownerType, opts) </a> </li> <li> <a href="#TypedEnqueueRequestsFromMapFunc" title="TypedEnqueueRequestsFromMapFunc(fn)" data-gtmc="doc outline link"> TypedEnqueueRequestsFromMapFunc(fn) </a> </li> </ul> </li> <li> <a href="#TypedFuncs" title="type TypedFuncs" data-gtmc="doc outline link"> type TypedFuncs </a> <ul> <li> <a href="#TypedFuncs.Create" title="(h) Create(ctx, e, q)" data-gtmc="doc outline link"> (h) Create(ctx, e, q) </a> </li> <li> <a href="#TypedFuncs.Delete" title="(h) Delete(ctx, e, q)" data-gtmc="doc outline link"> (h) Delete(ctx, e, q) </a> </li> <li> <a href="#TypedFuncs.Generic" title="(h) Generic(ctx, e, q)" data-gtmc="doc outline link"> (h) Generic(ctx, e, q) </a> </li> <li> <a href="#TypedFuncs.Update" title="(h) Update(ctx, e, q)" data-gtmc="doc outline link"> (h) Update(ctx, e, q) </a> </li> </ul> </li> <li> <a href="#TypedMapFunc" title="type TypedMapFunc" data-gtmc="doc outline link"> type TypedMapFunc </a> </li> </ul> </li> </ul> </li> <li> <a href="#section-sourcefiles" data-gtmc="outline link"> Source Files </a> </li> </ul> </div> <div class="go-Main-navMobile js-mainNavMobile"> <label class="go-Label"> <select class="go-Select"> <option selected disabled>Documentation</option> </select> </label> </div> </nav> <article class="go-Main-article js-mainContent"> <div class="UnitDetails" data-test-id="UnitDetails" style="display: block;"> <div class="UnitDetails-content js-unitDetailsContent" data-test-id="UnitDetails-content"> <div class="UnitDoc"> <h2 class="UnitDoc-title" id="section-documentation"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/code_gm_grey_24dp.svg" alt=""> Documentation <a class="UnitDoc-idLink" href="#section-documentation" aria-label="Go to Documentation">露</a> </h2> <div class="Documentation js-documentation"> <div class="Documentation-content js-docContent"> <section class="Documentation-overview"> <h3 tabindex="-1" id="pkg-overview" class="Documentation-overviewHeader">Overview <a href="#pkg-overview" aria-label="Go to Overview">露</a></h3> <p>Package handler defines EventHandlers that enqueue reconcile.Requests in response to Create, Update, Deletion Events observed from Watching Kubernetes APIs. Users should provide a source.Source and handler.EventHandler to Controller.Watch in order to generate and enqueue reconcile.Request work items. </p><p>Generally, following premade event handlers should be sufficient for most use cases: </p><p>EventHandlers: </p><p>EnqueueRequestForObject - Enqueues a reconcile.Request containing the Name and Namespace of the object in the Event. This will cause the object that was the source of the Event (e.g. the created / deleted / updated object) to be reconciled. </p><p>EnqueueRequestForOwner - Enqueues a reconcile.Request containing the Name and Namespace of the Owner of the object in the Event. This will cause owner of the object that was the source of the Event (e.g. the owner object that created the object) to be reconciled. </p><p>EnqueueRequestsFromMapFunc - Enqueues reconcile.Requests resulting from a user provided transformation function run against the object in the Event. This will cause an arbitrary collection of objects (defined from a transformation of the source object) to be reconciled. </p> </section><section class="Documentation-index"> <h3 id="pkg-index" class="Documentation-indexHeader">Index <a href="#pkg-index" aria-label="Go to Index">露</a></h3> <ul class="Documentation-indexList"> <li class="Documentation-indexType"> <a href="#EnqueueRequestForObject">type EnqueueRequestForObject</a></li> <li class="Documentation-indexType"> <a href="#EventHandler">type EventHandler</a></li> <li><ul class="Documentation-indexTypeFunctions"> <li> <a href="#EnqueueRequestForOwner">func EnqueueRequestForOwner(scheme *runtime.Scheme, mapper meta.RESTMapper, ownerType client.Object, ...) EventHandler</a></li> <li> <a href="#EnqueueRequestsFromMapFunc">func EnqueueRequestsFromMapFunc(fn MapFunc) EventHandler</a></li> </ul></li> <li class="Documentation-indexType"> <a href="#Funcs">type Funcs</a></li> <li class="Documentation-indexType"> <a href="#MapFunc">type MapFunc</a></li> <li class="Documentation-indexType"> <a href="#OwnerOption">type OwnerOption</a></li> <li><ul class="Documentation-indexTypeFunctions"> <li> <a href="#OnlyControllerOwner">func OnlyControllerOwner() OwnerOption</a></li> </ul></li> <li class="Documentation-indexType"> <a href="#TypedEnqueueRequestForObject">type TypedEnqueueRequestForObject</a></li> <li><ul class="Documentation-indexTypeMethods"> <li> <a href="#TypedEnqueueRequestForObject.Create">func (e *TypedEnqueueRequestForObject[T]) Create(ctx context.Context, evt event.TypedCreateEvent[T], ...)</a></li> <li> <a href="#TypedEnqueueRequestForObject.Delete">func (e *TypedEnqueueRequestForObject[T]) Delete(ctx context.Context, evt event.TypedDeleteEvent[T], ...)</a></li> <li> <a href="#TypedEnqueueRequestForObject.Generic">func (e *TypedEnqueueRequestForObject[T]) Generic(ctx context.Context, evt event.TypedGenericEvent[T], ...)</a></li> <li> <a href="#TypedEnqueueRequestForObject.Update">func (e *TypedEnqueueRequestForObject[T]) Update(ctx context.Context, evt event.TypedUpdateEvent[T], ...)</a></li> </ul></li> <li class="Documentation-indexType"> <a href="#TypedEventHandler">type TypedEventHandler</a></li> <li><ul class="Documentation-indexTypeFunctions"> <li> <a href="#TypedEnqueueRequestForOwner">func TypedEnqueueRequestForOwner[object client.Object](scheme *runtime.Scheme, mapper meta.RESTMapper, ownerType client.Object, ...) TypedEventHandler[object, reconcile.Request]</a></li> <li> <a href="#TypedEnqueueRequestsFromMapFunc">func TypedEnqueueRequestsFromMapFunc[object any, request comparable](fn TypedMapFunc[object, request]) TypedEventHandler[object, request]</a></li> </ul></li> <li class="Documentation-indexType"> <a href="#TypedFuncs">type TypedFuncs</a></li> <li><ul class="Documentation-indexTypeMethods"> <li> <a href="#TypedFuncs.Create">func (h TypedFuncs[object, request]) Create(ctx context.Context, e event.TypedCreateEvent[object], ...)</a></li> <li> <a href="#TypedFuncs.Delete">func (h TypedFuncs[object, request]) Delete(ctx context.Context, e event.TypedDeleteEvent[object], ...)</a></li> <li> <a href="#TypedFuncs.Generic">func (h TypedFuncs[object, request]) Generic(ctx context.Context, e event.TypedGenericEvent[object], ...)</a></li> <li> <a href="#TypedFuncs.Update">func (h TypedFuncs[object, request]) Update(ctx context.Context, e event.TypedUpdateEvent[object], ...)</a></li> </ul></li> <li class="Documentation-indexType"> <a href="#TypedMapFunc">type TypedMapFunc</a></li> </ul> </section><section class="Documentation-examples"> <h4 tabindex="-1" id="pkg-examples" class="Documentation-examplesHeader">Examples <a class="Documentation-idLink" href="#pkg-examples" aria-label="Go to Examples">露</a></h4> <ul class="Documentation-examplesList"> <li><a href="#example-EnqueueRequestForObject" class="js-exampleHref">EnqueueRequestForObject</a></li> <li><a href="#example-EnqueueRequestForOwner" class="js-exampleHref">EnqueueRequestForOwner</a></li> <li><a href="#example-EnqueueRequestsFromMapFunc" class="js-exampleHref">EnqueueRequestsFromMapFunc</a></li> <li><a href="#example-Funcs" class="js-exampleHref">Funcs</a></li> </ul> </section><h3 tabindex="-1" id="pkg-constants" class="Documentation-constantsHeader">Constants <a href="#pkg-constants" aria-label="Go to Constants">露</a></h3> <section class="Documentation-constants"><p class="Documentation-empty">This section is empty.</p></section> <h3 tabindex="-1" id="pkg-variables" class="Documentation-variablesHeader">Variables <a href="#pkg-variables" aria-label="Go to Variables">露</a></h3> <section class="Documentation-variables"><p class="Documentation-empty">This section is empty.</p></section> <h3 tabindex="-1" id="pkg-functions" class="Documentation-functionsHeader">Functions <a href="#pkg-functions" aria-label="Go to Functions">露</a></h3> <section class="Documentation-functions"><p class="Documentation-empty">This section is empty.</p></section> <h3 tabindex="-1" id="pkg-types" class="Documentation-typesHeader">Types <a href="#pkg-types" aria-label="Go to Types">露</a></h3> <section class="Documentation-types"><div class="Documentation-type"> <h4 tabindex="-1" id="EnqueueRequestForObject" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go#L40">EnqueueRequestForObject</a> <a class="Documentation-idLink" href="#EnqueueRequestForObject" aria-label="Go to EnqueueRequestForObject">露</a></span> <span class="Documentation-sinceVersion"> </span> </h4> <div class="Documentation-declaration"> <pre>type EnqueueRequestForObject = <a href="#TypedEnqueueRequestForObject">TypedEnqueueRequestForObject</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>]</pre> </div> <p>EnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event. (e.g. the created / deleted / updated objects Name and Namespace). handler.EnqueueRequestForObject is used by almost all Controllers that have associated Resources (e.g. CRDs) to reconcile the associated Resource. </p> <details tabindex="-1" id="example-EnqueueRequestForObject" class="Documentation-exampleDetails js-exampleContainer"> <summary class="Documentation-exampleDetailsHeader">Example <a href="#example-EnqueueRequestForObject" aria-label="Go to Example">露</a></summary> <div class="Documentation-exampleDetailsBody"> <p>This example watches Pods and enqueues Requests with the Name and Namespace of the Pod from the Event (i.e. change caused by a Create, Update, Delete). </p> <pre class="Documentation-exampleCode"> package main import ( corev1 &#34;k8s.io/api/core/v1&#34; &#34;sigs.k8s.io/controller-runtime/pkg/controller&#34; &#34;sigs.k8s.io/controller-runtime/pkg/handler&#34; &#34;sigs.k8s.io/controller-runtime/pkg/manager&#34; &#34;sigs.k8s.io/controller-runtime/pkg/source&#34; ) var ( mgr manager.Manager c controller.Controller ) func main() { // controller is a controller.controller err := c.Watch( source.Kind(mgr.GetCache(), &amp;corev1.Pod{}, &amp;handler.TypedEnqueueRequestForObject[*corev1.Pod]{}), ) if err != nil { // handle it } } </pre> <pre><span class="Documentation-exampleOutputLabel">Output:</span> <span class="Documentation-exampleOutput"></span></pre> </div> <div class="Documentation-exampleButtonsContainer"> <p class="Documentation-exampleError" role="alert" aria-atomic="true"></p> <button class="Documentation-exampleShareButton" aria-label="Share Code">Share</button> <button class="Documentation-exampleFormatButton" aria-label="Format Code">Format</button> <button class="Documentation-exampleRunButton" aria-label="Run Code">Run</button> </div></details> </div><div class="Documentation-type"> <h4 tabindex="-1" id="EventHandler" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L46">EventHandler</a> <a class="Documentation-idLink" href="#EventHandler" aria-label="Go to EventHandler">露</a></span> <span class="Documentation-sinceVersion"> </span> </h4> <div class="Documentation-declaration"> <pre>type EventHandler = <a href="#TypedEventHandler">TypedEventHandler</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>]</pre> </div> <p>EventHandler enqueues reconcile.Requests in response to events (e.g. Pod Create). EventHandlers map an Event for one object to trigger Reconciles for either the same object or different objects - e.g. if there is an Event for object with type Foo (using source.Kind) then reconcile one or more object(s) with type Bar. </p><p>Identical reconcile.Requests will be batched together through the queuing mechanism before reconcile is called. </p><p>* Use EnqueueRequestForObject to reconcile the object the event is for - do this for events for the type the Controller Reconciles. (e.g. Deployment for a Deployment Controller) </p><p>* Use EnqueueRequestForOwner to reconcile the owner of the object the event is for - do this for events for the types the Controller creates. (e.g. ReplicaSets created by a Deployment Controller) </p><p>* Use EnqueueRequestsFromMapFunc to transform an event for an object to a reconcile of an object of a different type - do this for events for types the Controller may be interested in, but doesn&#39;t create. (e.g. If Foo responds to cluster size events, map Node events to Foo objects.) </p><p>Unless you are implementing your own EventHandler, you can ignore the functions on the EventHandler interface. Most users shouldn&#39;t need to implement their own EventHandler. </p> <div class="Documentation-typeFunc"> <h4 tabindex="-1" id="EnqueueRequestForOwner" data-kind="function" class="Documentation-typeFuncHeader"> <span>func <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_owner.go#L50">EnqueueRequestForOwner</a> <a class="Documentation-idLink" href="#EnqueueRequestForOwner" aria-label="Go to EnqueueRequestForOwner">露</a></span> <span class="Documentation-sinceVersion"> </span> </h4> <div class="Documentation-declaration"> <pre>func EnqueueRequestForOwner(scheme *<a href="/k8s.io/apimachinery/pkg/runtime">runtime</a>.<a href="/k8s.io/apimachinery/pkg/runtime#Scheme">Scheme</a>, mapper <a href="/k8s.io/apimachinery/pkg/api/meta">meta</a>.<a href="/k8s.io/apimachinery/pkg/api/meta#RESTMapper">RESTMapper</a>, ownerType <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>, opts ...<a href="#OwnerOption">OwnerOption</a>) <a href="#EventHandler">EventHandler</a></pre> </div> <p>EnqueueRequestForOwner enqueues Requests for the Owners of an object. E.g. the object that created the object that was the source of the Event. </p><p>If a ReplicaSet creates Pods, users may reconcile the ReplicaSet in response to Pod Events using: </p><p>- a source.Kind Source with Type of Pod. </p><p>- a handler.enqueueRequestForOwner EventHandler with an OwnerType of ReplicaSet and OnlyControllerOwner set to true. </p> <details tabindex="-1" id="example-EnqueueRequestForOwner" class="Documentation-exampleDetails js-exampleContainer"> <summary class="Documentation-exampleDetailsHeader">Example <a href="#example-EnqueueRequestForOwner" aria-label="Go to Example">露</a></summary> <div class="Documentation-exampleDetailsBody"> <p>This example watches ReplicaSets and enqueues a Request containing the Name and Namespace of the owning (direct) Deployment responsible for the creation of the ReplicaSet. </p> <pre class="Documentation-exampleCode"> package main import ( appsv1 &#34;k8s.io/api/apps/v1&#34; &#34;sigs.k8s.io/controller-runtime/pkg/controller&#34; &#34;sigs.k8s.io/controller-runtime/pkg/handler&#34; &#34;sigs.k8s.io/controller-runtime/pkg/manager&#34; &#34;sigs.k8s.io/controller-runtime/pkg/source&#34; ) var ( mgr manager.Manager c controller.Controller ) func main() { // controller is a controller.controller err := c.Watch( source.Kind(mgr.GetCache(), &amp;appsv1.ReplicaSet{}, handler.TypedEnqueueRequestForOwner[*appsv1.ReplicaSet](mgr.GetScheme(), mgr.GetRESTMapper(), &amp;appsv1.Deployment{}, handler.OnlyControllerOwner()), ), ) if err != nil { // handle it } } </pre> <pre><span class="Documentation-exampleOutputLabel">Output:</span> <span class="Documentation-exampleOutput"></span></pre> </div> <div class="Documentation-exampleButtonsContainer"> <p class="Documentation-exampleError" role="alert" aria-atomic="true"></p> <button class="Documentation-exampleShareButton" aria-label="Share Code">Share</button> <button class="Documentation-exampleFormatButton" aria-label="Format Code">Format</button> <button class="Documentation-exampleRunButton" aria-label="Run Code">Run</button> </div></details> </div><div class="Documentation-typeFunc"> <h4 tabindex="-1" id="EnqueueRequestsFromMapFunc" data-kind="function" class="Documentation-typeFuncHeader"> <span>func <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_mapped.go#L48">EnqueueRequestsFromMapFunc</a> <a class="Documentation-idLink" href="#EnqueueRequestsFromMapFunc" aria-label="Go to EnqueueRequestsFromMapFunc">露</a></span> <span class="Documentation-sinceVersion"> </span> </h4> <div class="Documentation-declaration"> <pre>func EnqueueRequestsFromMapFunc(fn <a href="#MapFunc">MapFunc</a>) <a href="#EventHandler">EventHandler</a></pre> </div> <p>EnqueueRequestsFromMapFunc enqueues Requests by running a transformation function that outputs a collection of reconcile.Requests on each Event. The reconcile.Requests may be for an arbitrary set of objects defined by some user specified transformation of the source Event. (e.g. trigger Reconciler for a set of objects in response to a cluster resize event caused by adding or deleting a Node) </p><p>EnqueueRequestsFromMapFunc is frequently used to fan-out updates from one object to one or more other objects of a differing type. </p><p>For UpdateEvents which contain both a new and old object, the transformation function is run on both objects and both sets of Requests are enqueue. </p> <details tabindex="-1" id="example-EnqueueRequestsFromMapFunc" class="Documentation-exampleDetails js-exampleContainer"> <summary class="Documentation-exampleDetailsHeader">Example <a href="#example-EnqueueRequestsFromMapFunc" aria-label="Go to Example">露</a></summary> <div class="Documentation-exampleDetailsBody"> <p>This example watches Deployments and enqueues a Request contain the Name and Namespace of different objects (of Type: MyKind) using a mapping function defined by the user. </p> <pre class="Documentation-exampleCode"> package main import ( &#34;context&#34; appsv1 &#34;k8s.io/api/apps/v1&#34; &#34;k8s.io/apimachinery/pkg/types&#34; &#34;sigs.k8s.io/controller-runtime/pkg/controller&#34; &#34;sigs.k8s.io/controller-runtime/pkg/handler&#34; &#34;sigs.k8s.io/controller-runtime/pkg/manager&#34; &#34;sigs.k8s.io/controller-runtime/pkg/reconcile&#34; &#34;sigs.k8s.io/controller-runtime/pkg/source&#34; ) var ( mgr manager.Manager c controller.Controller ) func main() { // controller is a controller.controller err := c.Watch( source.Kind(mgr.GetCache(), &amp;appsv1.Deployment{}, handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, a *appsv1.Deployment) []reconcile.Request { return []reconcile.Request{ {NamespacedName: types.NamespacedName{ Name: a.Name + &#34;-1&#34;, Namespace: a.Namespace, }}, {NamespacedName: types.NamespacedName{ Name: a.Name + &#34;-2&#34;, Namespace: a.Namespace, }}, } }), ), ) if err != nil { // handle it } } </pre> <pre><span class="Documentation-exampleOutputLabel">Output:</span> <span class="Documentation-exampleOutput"></span></pre> </div> <div class="Documentation-exampleButtonsContainer"> <p class="Documentation-exampleError" role="alert" aria-atomic="true"></p> <button class="Documentation-exampleShareButton" aria-label="Share Code">Share</button> <button class="Documentation-exampleFormatButton" aria-label="Format Code">Format</button> <button class="Documentation-exampleRunButton" aria-label="Run Code">Run</button> </div></details> </div> </div><div class="Documentation-type"> <h4 tabindex="-1" id="Funcs" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L86">Funcs</a> <a class="Documentation-idLink" href="#Funcs" aria-label="Go to Funcs">露</a></span> <span class="Documentation-sinceVersion"> </span> </h4> <div class="Documentation-declaration"> <pre>type Funcs = <a href="#TypedFuncs">TypedFuncs</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>]</pre> </div> <p>Funcs implements eventhandler. </p> <details tabindex="-1" id="example-Funcs" class="Documentation-exampleDetails js-exampleContainer"> <summary class="Documentation-exampleDetailsHeader">Example <a href="#example-Funcs" aria-label="Go to Example">露</a></summary> <div class="Documentation-exampleDetailsBody"> <p>This example implements handler.EnqueueRequestForObject. </p> <pre class="Documentation-exampleCode"> package main import ( &#34;context&#34; corev1 &#34;k8s.io/api/core/v1&#34; &#34;k8s.io/apimachinery/pkg/types&#34; &#34;k8s.io/client-go/util/workqueue&#34; &#34;sigs.k8s.io/controller-runtime/pkg/controller&#34; &#34;sigs.k8s.io/controller-runtime/pkg/event&#34; &#34;sigs.k8s.io/controller-runtime/pkg/handler&#34; &#34;sigs.k8s.io/controller-runtime/pkg/manager&#34; &#34;sigs.k8s.io/controller-runtime/pkg/reconcile&#34; &#34;sigs.k8s.io/controller-runtime/pkg/source&#34; ) var ( mgr manager.Manager c controller.Controller ) func main() { // controller is a controller.controller err := c.Watch( source.Kind(mgr.GetCache(), &amp;corev1.Pod{}, handler.TypedFuncs[*corev1.Pod, reconcile.Request]{ CreateFunc: func(ctx context.Context, e event.TypedCreateEvent[*corev1.Pod], q workqueue.TypedRateLimitingInterface[reconcile.Request]) { q.Add(reconcile.Request{NamespacedName: types.NamespacedName{ Name: e.Object.Name, Namespace: e.Object.Namespace, }}) }, UpdateFunc: func(ctx context.Context, e event.TypedUpdateEvent[*corev1.Pod], q workqueue.TypedRateLimitingInterface[reconcile.Request]) { q.Add(reconcile.Request{NamespacedName: types.NamespacedName{ Name: e.ObjectNew.Name, Namespace: e.ObjectNew.Namespace, }}) }, DeleteFunc: func(ctx context.Context, e event.TypedDeleteEvent[*corev1.Pod], q workqueue.TypedRateLimitingInterface[reconcile.Request]) { q.Add(reconcile.Request{NamespacedName: types.NamespacedName{ Name: e.Object.Name, Namespace: e.Object.Namespace, }}) }, GenericFunc: func(ctx context.Context, e event.TypedGenericEvent[*corev1.Pod], q workqueue.TypedRateLimitingInterface[reconcile.Request]) { q.Add(reconcile.Request{NamespacedName: types.NamespacedName{ Name: e.Object.Name, Namespace: e.Object.Namespace, }}) }, }, ), ) if err != nil { // handle it } } </pre> <pre><span class="Documentation-exampleOutputLabel">Output:</span> <span class="Documentation-exampleOutput"></span></pre> </div> <div class="Documentation-exampleButtonsContainer"> <p class="Documentation-exampleError" role="alert" aria-atomic="true"></p> <button class="Documentation-exampleShareButton" aria-label="Share Code">Share</button> <button class="Documentation-exampleFormatButton" aria-label="Format Code">Format</button> <button class="Documentation-exampleRunButton" aria-label="Run Code">Run</button> </div></details> </div><div class="Documentation-type"> <h4 tabindex="-1" id="MapFunc" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_mapped.go#L30">MapFunc</a> <a class="Documentation-idLink" href="#MapFunc" aria-label="Go to MapFunc">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.7.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>type MapFunc = <a href="#TypedMapFunc">TypedMapFunc</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>]</pre> </div> <p>MapFunc is the signature required for enqueueing requests from a generic function. This type is usually used with EnqueueRequestsFromMapFunc when registering an event handler. </p> </div><div class="Documentation-type"> <h4 tabindex="-1" id="OwnerOption" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_owner.go#L40">OwnerOption</a> <a class="Documentation-idLink" href="#OwnerOption" aria-label="Go to OwnerOption">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.15.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>type OwnerOption func(e enqueueRequestForOwnerInterface)</pre> </div> <p>OwnerOption modifies an EnqueueRequestForOwner EventHandler. </p> <div class="Documentation-typeFunc"> <h4 tabindex="-1" id="OnlyControllerOwner" data-kind="function" class="Documentation-typeFuncHeader"> <span>func <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_owner.go#L79">OnlyControllerOwner</a> <a class="Documentation-idLink" href="#OnlyControllerOwner" aria-label="Go to OnlyControllerOwner">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.15.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func OnlyControllerOwner() <a href="#OwnerOption">OwnerOption</a></pre> </div> <p>OnlyControllerOwner if provided will only look at the first OwnerReference with Controller: true. </p> </div> </div><div class="Documentation-type"> <h4 tabindex="-1" id="TypedEnqueueRequestForObject" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go#L47">TypedEnqueueRequestForObject</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestForObject" aria-label="Go to TypedEnqueueRequestForObject">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>type TypedEnqueueRequestForObject[object <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>] struct{}</pre> </div> <p>TypedEnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event. (e.g. the created / deleted / updated objects Name and Namespace). handler.TypedEnqueueRequestForObject is used by almost all Controllers that have associated Resources (e.g. CRDs) to reconcile the associated Resource. </p><p>TypedEnqueueRequestForObject is experimental and subject to future change. </p> <div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedEnqueueRequestForObject.Create" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (*TypedEnqueueRequestForObject[T]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go#L50">Create</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestForObject.Create" aria-label="Go to TypedEnqueueRequestForObject.Create">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (e *<a href="#TypedEnqueueRequestForObject">TypedEnqueueRequestForObject</a>[T]) Create(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, evt <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedCreateEvent">TypedCreateEvent</a>[T], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>])</pre> </div> <p>Create implements EventHandler. </p> </div><div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedEnqueueRequestForObject.Delete" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (*TypedEnqueueRequestForObject[T]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go#L80">Delete</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestForObject.Delete" aria-label="Go to TypedEnqueueRequestForObject.Delete">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (e *<a href="#TypedEnqueueRequestForObject">TypedEnqueueRequestForObject</a>[T]) Delete(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, evt <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedDeleteEvent">TypedDeleteEvent</a>[T], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>])</pre> </div> <p>Delete implements EventHandler. </p> </div><div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedEnqueueRequestForObject.Generic" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (*TypedEnqueueRequestForObject[T]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go#L92">Generic</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestForObject.Generic" aria-label="Go to TypedEnqueueRequestForObject.Generic">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (e *<a href="#TypedEnqueueRequestForObject">TypedEnqueueRequestForObject</a>[T]) Generic(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, evt <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedGenericEvent">TypedGenericEvent</a>[T], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>])</pre> </div> <p>Generic implements EventHandler. </p> </div><div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedEnqueueRequestForObject.Update" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (*TypedEnqueueRequestForObject[T]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go#L62">Update</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestForObject.Update" aria-label="Go to TypedEnqueueRequestForObject.Update">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (e *<a href="#TypedEnqueueRequestForObject">TypedEnqueueRequestForObject</a>[T]) Update(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, evt <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedUpdateEvent">TypedUpdateEvent</a>[T], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>])</pre> </div> <p>Update implements EventHandler. </p> </div> </div><div class="Documentation-type"> <h4 tabindex="-1" id="TypedEventHandler" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L68">TypedEventHandler</a> <a class="Documentation-idLink" href="#TypedEventHandler" aria-label="Go to TypedEventHandler">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>type TypedEventHandler[object <a href="/builtin#any">any</a>, request <a href="/builtin#comparable">comparable</a>] interface { <span id="TypedEventHandler.Create" data-kind="method"> <span class="comment">// Create is called in response to a create event - e.g. Pod Creation.</span> </span> Create(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedCreateEvent">TypedCreateEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) <span id="TypedEventHandler.Update" data-kind="method"> <span class="comment">// Update is called in response to an update event - e.g. Pod Updated.</span> </span> Update(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedUpdateEvent">TypedUpdateEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) <span id="TypedEventHandler.Delete" data-kind="method"> <span class="comment">// Delete is called in response to a delete event - e.g. Pod Deleted.</span> </span> Delete(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedDeleteEvent">TypedDeleteEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) <span id="TypedEventHandler.Generic" data-kind="method"> <span class="comment">// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or</span> </span> <span class="comment">// external trigger request - e.g. reconcile Autoscaling, or a Webhook.</span> Generic(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedGenericEvent">TypedGenericEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) }</pre> </div> <p>TypedEventHandler enqueues reconcile.Requests in response to events (e.g. Pod Create). TypedEventHandlers map an Event for one object to trigger Reconciles for either the same object or different objects - e.g. if there is an Event for object with type Foo (using source.Kind) then reconcile one or more object(s) with type Bar. </p><p>Identical reconcile.Requests will be batched together through the queuing mechanism before reconcile is called. </p><p>* Use TypedEnqueueRequestForObject to reconcile the object the event is for - do this for events for the type the Controller Reconciles. (e.g. Deployment for a Deployment Controller) </p><p>* Use TypedEnqueueRequestForOwner to reconcile the owner of the object the event is for - do this for events for the types the Controller creates. (e.g. ReplicaSets created by a Deployment Controller) </p><p>* Use TypedEnqueueRequestsFromMapFunc to transform an event for an object to a reconcile of an object of a different type - do this for events for types the Controller may be interested in, but doesn&#39;t create. (e.g. If Foo responds to cluster size events, map Node events to Foo objects.) </p><p>Unless you are implementing your own TypedEventHandler, you can ignore the functions on the TypedEventHandler interface. Most users shouldn&#39;t need to implement their own TypedEventHandler. </p><p>TypedEventHandler is experimental and subject to future change. </p> <div class="Documentation-typeFunc"> <h4 tabindex="-1" id="TypedEnqueueRequestForOwner" data-kind="function" class="Documentation-typeFuncHeader"> <span>func <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_owner.go#L64">TypedEnqueueRequestForOwner</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestForOwner" aria-label="Go to TypedEnqueueRequestForOwner">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func TypedEnqueueRequestForOwner[object <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>](scheme *<a href="/k8s.io/apimachinery/pkg/runtime">runtime</a>.<a href="/k8s.io/apimachinery/pkg/runtime#Scheme">Scheme</a>, mapper <a href="/k8s.io/apimachinery/pkg/api/meta">meta</a>.<a href="/k8s.io/apimachinery/pkg/api/meta#RESTMapper">RESTMapper</a>, ownerType <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client">client</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/client#Object">Object</a>, opts ...<a href="#OwnerOption">OwnerOption</a>) <a href="#TypedEventHandler">TypedEventHandler</a>[object, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile">reconcile</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/reconcile#Request">Request</a>]</pre> </div> <p>TypedEnqueueRequestForOwner enqueues Requests for the Owners of an object. E.g. the object that created the object that was the source of the Event. </p><p>If a ReplicaSet creates Pods, users may reconcile the ReplicaSet in response to Pod Events using: </p><p>- a source.Kind Source with Type of Pod. </p><p>- a handler.typedEnqueueRequestForOwner EventHandler with an OwnerType of ReplicaSet and OnlyControllerOwner set to true. </p><p>TypedEnqueueRequestForOwner is experimental and subject to future change. </p> </div><div class="Documentation-typeFunc"> <h4 tabindex="-1" id="TypedEnqueueRequestsFromMapFunc" data-kind="function" class="Documentation-typeFuncHeader"> <span>func <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_mapped.go#L64">TypedEnqueueRequestsFromMapFunc</a> <a class="Documentation-idLink" href="#TypedEnqueueRequestsFromMapFunc" aria-label="Go to TypedEnqueueRequestsFromMapFunc">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func TypedEnqueueRequestsFromMapFunc[object <a href="/builtin#any">any</a>, request <a href="/builtin#comparable">comparable</a>](fn <a href="#TypedMapFunc">TypedMapFunc</a>[object, request]) <a href="#TypedEventHandler">TypedEventHandler</a>[object, request]</pre> </div> <p>TypedEnqueueRequestsFromMapFunc enqueues Requests by running a transformation function that outputs a collection of reconcile.Requests on each Event. The reconcile.Requests may be for an arbitrary set of objects defined by some user specified transformation of the source Event. (e.g. trigger Reconciler for a set of objects in response to a cluster resize event caused by adding or deleting a Node) </p><p>TypedEnqueueRequestsFromMapFunc is frequently used to fan-out updates from one object to one or more other objects of a differing type. </p><p>For TypedUpdateEvents which contain both a new and old object, the transformation function is run on both objects and both sets of Requests are enqueue. </p><p>TypedEnqueueRequestsFromMapFunc is experimental and subject to future change. </p> </div> </div><div class="Documentation-type"> <h4 tabindex="-1" id="TypedFuncs" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L91">TypedFuncs</a> <a class="Documentation-idLink" href="#TypedFuncs" aria-label="Go to TypedFuncs">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>type TypedFuncs[object <a href="/builtin#any">any</a>, request <a href="/builtin#comparable">comparable</a>] struct { <span id="TypedFuncs.CreateFunc" data-kind="field"> <span class="comment">// Create is called in response to an add event. Defaults to no-op.</span> </span> <span class="comment">// RateLimitingInterface is used to enqueue reconcile.Requests.</span> CreateFunc func(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedCreateEvent">TypedCreateEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) <span id="TypedFuncs.UpdateFunc" data-kind="field"> <span class="comment">// Update is called in response to an update event. Defaults to no-op.</span> </span> <span class="comment">// RateLimitingInterface is used to enqueue reconcile.Requests.</span> UpdateFunc func(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedUpdateEvent">TypedUpdateEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) <span id="TypedFuncs.DeleteFunc" data-kind="field"> <span class="comment">// Delete is called in response to a delete event. Defaults to no-op.</span> </span> <span class="comment">// RateLimitingInterface is used to enqueue reconcile.Requests.</span> DeleteFunc func(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedDeleteEvent">TypedDeleteEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) <span id="TypedFuncs.GenericFunc" data-kind="field"> <span class="comment">// GenericFunc is called in response to a generic event. Defaults to no-op.</span> </span> <span class="comment">// RateLimitingInterface is used to enqueue reconcile.Requests.</span> GenericFunc func(<a href="/context">context</a>.<a href="/context#Context">Context</a>, <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedGenericEvent">TypedGenericEvent</a>[object], <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request]) }</pre> </div> <p>TypedFuncs implements eventhandler. </p><p>TypedFuncs is experimental and subject to future change. </p> <div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedFuncs.Create" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (TypedFuncs[object, request]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L110">Create</a> <a class="Documentation-idLink" href="#TypedFuncs.Create" aria-label="Go to TypedFuncs.Create">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (h <a href="#TypedFuncs">TypedFuncs</a>[object, request]) Create(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, e <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedCreateEvent">TypedCreateEvent</a>[object], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request])</pre> </div> <p>Create implements EventHandler. </p> </div><div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedFuncs.Delete" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (TypedFuncs[object, request]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L117">Delete</a> <a class="Documentation-idLink" href="#TypedFuncs.Delete" aria-label="Go to TypedFuncs.Delete">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (h <a href="#TypedFuncs">TypedFuncs</a>[object, request]) Delete(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, e <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedDeleteEvent">TypedDeleteEvent</a>[object], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request])</pre> </div> <p>Delete implements EventHandler. </p> </div><div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedFuncs.Generic" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (TypedFuncs[object, request]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L131">Generic</a> <a class="Documentation-idLink" href="#TypedFuncs.Generic" aria-label="Go to TypedFuncs.Generic">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (h <a href="#TypedFuncs">TypedFuncs</a>[object, request]) Generic(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, e <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedGenericEvent">TypedGenericEvent</a>[object], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request])</pre> </div> <p>Generic implements EventHandler. </p> </div><div class="Documentation-typeMethod"> <h4 tabindex="-1" id="TypedFuncs.Update" data-kind="method" class="Documentation-typeMethodHeader"> <span>func (TypedFuncs[object, request]) <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go#L124">Update</a> <a class="Documentation-idLink" href="#TypedFuncs.Update" aria-label="Go to TypedFuncs.Update">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>func (h <a href="#TypedFuncs">TypedFuncs</a>[object, request]) Update(ctx <a href="/context">context</a>.<a href="/context#Context">Context</a>, e <a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event">event</a>.<a href="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/event#TypedUpdateEvent">TypedUpdateEvent</a>[object], q <a href="/k8s.io/client-go/util/workqueue">workqueue</a>.<a href="/k8s.io/client-go/util/workqueue#TypedRateLimitingInterface">TypedRateLimitingInterface</a>[request])</pre> </div> <p>Update implements EventHandler. </p> </div> </div><div class="Documentation-type"> <h4 tabindex="-1" id="TypedMapFunc" data-kind="type" class="Documentation-typeHeader"> <span>type <a class="Documentation-source" href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_mapped.go#L36">TypedMapFunc</a> <a class="Documentation-idLink" href="#TypedMapFunc" aria-label="Go to TypedMapFunc">露</a></span> <span class="Documentation-sinceVersion"> <span class="Documentation-sinceVersionLabel">added in</span> <span class="Documentation-sinceVersionVersion">v0.18.0</span> </span> </h4> <div class="Documentation-declaration"> <pre>type TypedMapFunc[object <a href="/builtin#any">any</a>, request <a href="/builtin#comparable">comparable</a>] func(<a href="/context">context</a>.<a href="/context#Context">Context</a>, object) []request</pre> </div> <p>TypedMapFunc is the signature required for enqueueing requests from a generic function. This type is usually used with EnqueueRequestsFromTypedMapFunc when registering an event handler. </p><p>TypedMapFunc is experimental and subject to future change. </p> </div></section></div> </div> </div> <div class="UnitFiles js-unitFiles"> <h2 class="UnitFiles-title" id="section-sourcefiles"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/insert_drive_file_gm_grey_24dp.svg" alt=""> Source Files <a class="UnitFiles-idLink" href="#section-sourcefiles" aria-label="Go to Source Files">露</a> </h2> <div class="UnitFiles-titleLink"> <a href="https://github.com/kubernetes-sigs/controller-runtime/tree/v0.19.2/pkg/handler" target="_blank" rel="noopener">View all Source files</a> </div> <div> <ul class="UnitFiles-fileList"><li> <a href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/doc.go" target="_blank" rel="noopener" title="doc.go">doc.go</a> </li><li> <a href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue.go" target="_blank" rel="noopener" title="enqueue.go">enqueue.go</a> </li><li> <a href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_mapped.go" target="_blank" rel="noopener" title="enqueue_mapped.go">enqueue_mapped.go</a> </li><li> <a href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/enqueue_owner.go" target="_blank" rel="noopener" title="enqueue_owner.go">enqueue_owner.go</a> </li><li> <a href="https://github.com/kubernetes-sigs/controller-runtime/blob/v0.19.2/pkg/handler/eventhandler.go" target="_blank" rel="noopener" title="eventhandler.go">eventhandler.go</a> </li></ul> </div> </div> </div> </div> <div id="showInternal-description" hidden> Click to show internal directories. </div> <div id="hideInternal-description" hidden> Click to hide internal directories. </div> </article> <footer class="go-Main-footer"></footer> </main> <footer class="go-Footer"> <div class="go-Footer-links"> <div class="go-Footer-linkColumn"> <a href="https://go.dev/solutions" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Why Go </a> <a href="https://go.dev/solutions#use-cases" class="go-Footer-link" data-gtmc="footer link"> Use Cases </a> <a href="https://go.dev/solutions#case-studies" class="go-Footer-link" data-gtmc="footer link"> Case Studies </a> </div> <div class="go-Footer-linkColumn"> <a href="https://learn.go.dev/" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Get Started </a> <a href="https://play.golang.org" class="go-Footer-link" data-gtmc="footer link"> Playground </a> <a href="https://tour.golang.org" class="go-Footer-link" data-gtmc="footer link"> Tour </a> <a href="https://stackoverflow.com/questions/tagged/go?tab=Newest" class="go-Footer-link" data-gtmc="footer link"> Stack Overflow </a> <a href="https://go.dev/help" class="go-Footer-link" data-gtmc="footer link"> Help </a> </div> <div class="go-Footer-linkColumn"> <a href="https://pkg.go.dev" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Packages </a> <a href="/std" class="go-Footer-link" data-gtmc="footer link"> Standard Library </a> <a href="/golang.org/x" class="go-Footer-link" data-gtmc="footer link"> Sub-repositories </a> <a href="https://pkg.go.dev/about" class="go-Footer-link" data-gtmc="footer link"> About Go Packages </a> </div> <div class="go-Footer-linkColumn"> <a href="https://go.dev/project" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> About </a> <a href="https://go.dev/dl/" class="go-Footer-link" data-gtmc="footer link">Download</a> <a href="https://go.dev/blog" class="go-Footer-link" data-gtmc="footer link">Blog</a> <a href="https://github.com/golang/go/issues" class="go-Footer-link" data-gtmc="footer link"> Issue Tracker </a> <a href="https://go.dev/doc/devel/release.html" class="go-Footer-link" data-gtmc="footer link"> Release Notes </a> <a href="https://blog.golang.org/go-brand" class="go-Footer-link" data-gtmc="footer link"> Brand Guidelines </a> <a href="https://go.dev/conduct" class="go-Footer-link" data-gtmc="footer link"> Code of Conduct </a> </div> <div class="go-Footer-linkColumn"> <a href="https://www.twitter.com/golang" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Connect </a> <a href="https://www.twitter.com/golang" class="go-Footer-link" data-gtmc="footer link"> Twitter </a> <a href="https://github.com/golang" class="go-Footer-link" data-gtmc="footer link">GitHub</a> <a href="https://invite.slack.golangbridge.org/" class="go-Footer-link" data-gtmc="footer link"> Slack </a> <a href="https://reddit.com/r/golang" class="go-Footer-link" data-gtmc="footer link"> r/golang </a> <a href="https://www.meetup.com/pro/go" class="go-Footer-link" data-gtmc="footer link"> Meetup </a> <a href="https://golangweekly.com/" class="go-Footer-link" data-gtmc="footer link"> Golang Weekly </a> </div> </div> <div class="go-Footer-bottom"> <img class="go-Footer-gopher" width="1431" height="901" src="/static/shared/gopher/pilot-bust-1431x901.svg" alt="Gopher in flight goggles"> <ul class="go-Footer-listRow"> <li class="go-Footer-listItem"> <a href="https://go.dev/copyright" data-gtmc="footer link">Copyright</a> </li> <li class="go-Footer-listItem"> <a href="https://go.dev/tos" data-gtmc="footer link">Terms of Service</a> </li> <li class="go-Footer-listItem"> <a href="http://www.google.com/intl/en/policies/privacy/" data-gtmc="footer link" target="_blank" rel="noopener"> Privacy Policy </a> </li> <li class="go-Footer-listItem"> <a href="https://go.dev/s/pkgsite-feedback" target="_blank" rel="noopener" data-gtmc="footer link"> Report an Issue </a> </li> <li class="go-Footer-listItem"> <button class="go-Button go-Button--text go-Footer-toggleTheme js-toggleTheme" aria-label="Theme Toggle"> <img data-value="auto" class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/brightness_6_gm_grey_24dp.svg" alt="System theme"> <img data-value="dark" class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/brightness_2_gm_grey_24dp.svg" alt="Dark theme"> <img data-value="light" class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/light_mode_gm_grey_24dp.svg" alt="Light theme"> <p> Theme Toggle </p> </button> </li> <li class="go-Footer-listItem"> <button class="go-Button go-Button--text go-Footer-keyboard js-openShortcuts" aria-label="Shorcuts Modal"> <img class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/keyboard_grey_24dp.svg" alt=""> <p> Shortcuts Modal </p> </button> </li> </ul> <a class="go-Footer-googleLogo" href="https://google.com" target="_blank"rel="noopener" data-gtmc="footer link"> <img class="go-Footer-googleLogoImg" height="24" width="72" src="/static/shared/logo/google-white.svg" alt="Google logo"> </a> </div> </footer> <dialog id="jump-to-modal" class="JumpDialog go-Modal go-Modal--md js-modal"> <form method="dialog" data-gmtc="jump to form" aria-label="Jump to Identifier"> <div class="Dialog-title go-Modal-header"> <h2>Jump to</h2> <button class="go-Button go-Button--inline" type="button" data-modal-close data-gtmc="modal button" aria-label="Close" > <img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="" /> </button> </div> <div class="JumpDialog-filter"> <input class="JumpDialog-input go-Input" autocomplete="off" type="text"> </div> <div class="JumpDialog-body go-Modal-body"> <div class="JumpDialog-list"></div> </div> <div class="go-Modal-actions"> <button class="go-Button" data-test-id="close-dialog">Close</button> </div> </form> </dialog> <dialog class="ShortcutsDialog go-Modal go-Modal--sm js-modal"> <form method="dialog"> <div class="go-Modal-header"> <h2>Keyboard shortcuts</h2> <button class="go-Button go-Button--inline" type="button" data-modal-close data-gtmc="modal button" aria-label="Close" > <img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="" /> </button> </div> <div class="go-Modal-body"> <table> <tbody> <tr><td class="ShortcutsDialog-key"> <strong>?</strong></td><td> : This menu</td> </tr> <tr><td class="ShortcutsDialog-key"> <strong>/</strong></td><td> : Search site</td> </tr> <tr><td class="ShortcutsDialog-key"> <strong>f</strong> or <strong>F</strong></td><td> : Jump to</td> </tr> <tr> <td class="ShortcutsDialog-key"><strong>y</strong> or <strong>Y</strong></td> <td> : Canonical URL</td> </tr> </tbody> </table> </div> <div class="go-Modal-actions"> <button class="go-Button" data-test-id="close-dialog">Close</button> </div> </form> </dialog> <section class="Cookie-notice js-cookieNotice"> <div>go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. <a target=_blank href="https://policies.google.com/technologies/cookies">Learn more.</a></div> <div><button class="go-Button">Okay</button></div> </section> <script> // this will throw if the querySelector can鈥檛 find the element const gtmId = document.querySelector('.js-gtmID').dataset.gtmid; if (!gtmId) { throw new Error('Google Tag Manager ID not found'); } loadScript(`https://www.googletagmanager.com/gtm.js?id=${gtmId}`); </script> <noscript> <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W8MVQXG" height="0" width="0" style="display:none;visibility:hidden"> </iframe> </noscript> <div class="js-canonicalURLPath" data-canonical-url-path="/sigs.k8s.io/controller-runtime@v0.19.2/pkg/handler" hidden></div> <div class="js-playgroundVars" data-modulepath="sigs.k8s.io/controller-runtime" data-version="v0.19.2" hidden></div> <script> loadScript('/static/frontend/unit/main/main.js') </script> <script> loadScript('/static/frontend/unit/unit.js') </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10