PageSourceSearch

https://flanksource.com/assets/js/47a7d441.95391e24.js

js flanksource.com collected 2026-10-03 20:56:20 UTC 15,857 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkmission_control=globalThis.webpackChunkmission_control||[]).push([[4221,5109],{44542(e,n,t){t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>p,frontMatter:()=>r,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"guide/playbooks/actions/notification","title":"Notification","description":"Notification action sends notification.","source":"@site/docs/guide/playbooks/actions/notification.mdx","sourceDirName":"guide/playbooks/actions","slug":"/guide/playbooks/actions/notification","permalink":"/docs/guide/playbooks/actions/notification","draft":false,"unlisted":false,"editUrl":"https://github.com/flanksource/docs/tree/main/docs/guide/playbooks/actions/notification.mdx","tags":[],"version":"current","frontMatter":{"title":"Notification","sidebar_custom_props":{"icon":"email"}},"sidebar":"guide","previous":{"title":"Logs","permalink":"/docs/guide/playbooks/actions/logs"},"next":{"title":"Pod","permalink":"/docs/guide/playbooks/actions/pod"}}');var s=t(74848),o=t(28453),c=t(41085);const r={title:"Notification",sidebar_custom_props:{icon:"email"}},a=" Notification",l={},d=[{value:"Notification",id:"notification",level:2},{value:"Attachment",id:"attachment",level:3},{value:"Templating",id:"templating",level:2},...c.toc];function h(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",p:"p",pre:"pre",...(0,o.R)(),...e.components},{Action:t,Fields:i,Icon:r}=n;return t||x("Action",!0),i||x("Fields",!0),r||x("Icon",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsxs)(n.h1,{id:"-notification",children:[(0,s.jsx)(r,{name:"bell-dark"})," Notification"]})}),"\n",(0,s.jsx)(n.p,{children:"Notification action sends notification."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",metastring:'title="notify-deployment-restarts.yaml" file=<rootDir>/modules/mission-control/fixtures/playbooks/notification-playbook.yaml',children:"apiVersion: mission-control.flanksource.com/v1\nkind: Playbook\nmetadata:\n  name: notify-file-creation\nspec:\n  description: Sends Telegram notification when a file is created\n  parameters:\n    - name: path\n      label: path of the file\n  actions:\n    - name: 'Create the file'\n      exec:\n        script: touch {{.params.path}}\n    - name: 'Send notification'\n      notification:\n        connection: connection://telegram/aditya\n        title: 'File {{.params.path}} created successfully'\n        message: 'File \"{{.params.path}}\" created successfully'\n"})}),"\n",(0,s.jsx)(t,{rows:[{field:"notification",description:"Notification Action",scheme:"[Notification](#notification)"}]}),"\n",(0,s.jsx)(n.h2,{id:"notification",children:"Notification"}),"\n",(0,s.jsx)(i,{oneOf:["url","connection"],rows:[{field:"url",description:"Notification URL",scheme:"NotificationURL"},{field:"connection",description:"Connection to use to send the notification",scheme:"NotificationConnection"},{field:"title",description:"Title of the notification",scheme:"string",required:!0,templatable:!0},{field:"message",description:"Message is the body of the notification",scheme:"string",required:!0,templatable:!0},{field:"properties",description:"Notification channel properties",scheme:"map[string]string",templatable:!0},{field:"attachments",description:"Files to attach to the notification. _Only supported by SMTP_",scheme:"[[]Attachment](#attachment)",templatable:!0}]}),"\n",(0,s.jsx)(n.h3,{id:"attachment",children:"Attachment"}),"\n",(0,s.jsx)(i,{rows:[{field:"filename",description:"Name of the attached file",scheme:"string",required:!0,templatable:!0},{field:"content",description:"Body of the attachment",scheme:"string",required:!0,templatable:!0},{field:"contentType",description:"MIME type of the attachment e.g. `application/pdf`",scheme:"string",templatable:!0}]}),"\n",(0,s.jsx)(n.h2,{id:"templating",children:"Templating"}),"\n",(0,s.jsx)(c.default,{})]})}function p(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}function x(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}},41085(e,n,t){t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>r,default:()=>h,frontMatter:()=>c,metadata:()=>i,toc:()=>l});const i=JSON.parse('{"id":"reference/playbooks/context","title":"Context","description":"CEL Expressions","source":"@site/docs/reference/playbooks/context.mdx","sourceDirName":"reference/playbooks","slug":"/reference/playbooks/context","permalink":"/docs/reference/playbooks/context","draft":false,"unlisted":false,"editUrl":"https://github.com/flanksource/docs/tree/main/docs/reference/playbooks/context.mdx","tags":[],"version":"current","frontMatter":{"title":"Context"},"sidebar":"reference","previous":{"title":"Playbook","permalink":"/docs/reference/playbooks/"},"next":{"title":"Env Vars","permalink":"/docs/reference/playbooks/env-vars"}}');var s=t(74848),o=t(28453);const c={title:"Context"},r=void 0,a={}
1,l=[{value:"CEL Expressions",id:"cel-expressions",level:3},{value:"Go Templating",id:"go-templating",level:3},{value:"Functions",id:"functions",level:3}];function d(e){const n={a:"a",admonition:"admonition",code:"code",h3:"h3",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...e.components},{Details:t}=n;return t||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h3,{id:"cel-expressions",children:"CEL Expressions"}),"\n",(0,s.jsxs)(n.p,{children:["The following variables can be used within the ",(0,s.jsx)(n.a,{href:"/docs/reference/scripting/cel",children:"CEL"})," expressions of ",(0,s.jsx)(n.code,{children:"filter"}),", ",(0,s.jsx)(n.code,{children:"if"}),", ",(0,s.jsx)(n.code,{children:"delays"})," and ",(0,s.jsx)(n.code,{children:"parameters.default"}),":"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Field"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Schema"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"config"})}),(0,s.jsx)(n.td,{children:"Config passed to the playbook"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/reference/config-db",children:(0,s.jsx)(n.code,{children:"ConfigItem"})})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"check"})}),(0,s.jsx)(n.td,{children:"Canary Check passed to the playbook"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/reference/canary-checker/check",children:(0,s.jsx)(n.code,{children:"Check"})})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"playbook"})}),(0,s.jsx)(n.td,{children:"Playbook passed to the playbook"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/reference/playbooks",children:(0,s.jsx)(n.code,{children:"Playbook"})})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"run"})}),(0,s.jsx)(n.td,{children:"Current run"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/reference/playbooks/#run",children:(0,s.jsx)(n.code,{children:"Run"})})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"params"})}),(0,s.jsx)(n.td,{children:"User provided parameters to the playbook"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"map[string]any"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"request"})}),(0,s.jsx)(n.td,{children:"Webhook request"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/reference/playbooks/webhooks",children:(0,s.jsx)(n.code,{children:"Webhook Request"})})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"env"})}),(0,s.jsx)(n.td,{children:"Environment variables defined on the playbook"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"map[string]any"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"user.name"})}),(0,s.jsx)(n.td,{children:"Name of the user who invoked the action"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"string"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"user.email"})}),(0,s.jsx)(n.td,{children:"Email of the user who invoked the action"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"string"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"agent.id"})}),(0,s.jsx)(n.td,{children:"ID of the agent the resource belongs to."}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"string"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"agent.name"})}),(0,s.jsx)(n.td,{children:"Name of the agent the resource belongs to."}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"string"})})]})]})]}),"\n",(0,s.jsx)(t,{summary:"Conditionally Running Actions",children:(0,s.jsxs)("div",{children:[(0,s.jsx)(n.p,{children:"Playbook actions can be selectively executed based on CEL expressions. These expressions must either return"}),(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["a boolean value (",(0,s.jsx)(n.code,{children:"true"})," indicating run the action & skip the action otherwise)"]}),"\n",(0,s.jsx)(n.li,{children:"or a special function among the ones listed below"}),"\n"]}),(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Function"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"always()"})}),(0,s.jsx)(n.td,{children:"run no matter what; even if the playbook is cancelled/fails"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"failure()"})}),(0,s.jsx)(n.td,{children:"run if any of the previous actions failed"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"skip()"})}),(0,s.jsx)(n.td,{children:"skip running this action"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"success()"})}),(0,s.jsx)(n.td,{children:"run only if all previous actions succeeded (default)"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"timeout()"})}),(0,s.jsx)(n.td,{children:"run only if any of the previous actions timed out"})]})]})]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",metastring:'title="delete-kubernetes-pod.yaml" file=<rootDir>/modules/mission-control/fixtures/playbooks/exec-filter.yaml',children:'---\napiVersion: mission-control.flanksource.com/v1\nkind: Playbook\nmetadata:\n  name: notify-send-with-filter\nspec:\n  parameters:\n    - name: message\n      label: The message for notification\n      default: \'{{.config.name}}\'\n  configs:\n    - types: \n        - Kubernetes::Pod\n  actions:\n    - name: Send notification\n      exec:\n        script: notify-send "{{.config.name}} was created"\n    - name: Bad script\n      exec:\n        script: deltaforce\n    - name: Send all success notification\n      if: success() # this filter practically skips this action as the second action above always fail
1s\n      exec:\n        script: notify-send "Everything went successfully"\n    - name: Send notification regardless\n      if: always()\n      exec:\n        script: notify-send "a Pod config was created"\n'})})]})}),"\n",(0,s.jsx)(t,{summary:"Defaulting Parameters",children:(0,s.jsx)("div",{children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",metastring:'title="delete-kubernetes-pod.yaml"',children:"apiVersion:\n  mission-control.flanksource.com/v1\n  kind: Playbook\n  metadata:\n    name: edit\n  spec:\n    title: 'Edit Kustomize Resource'\n    icon: flux\n    parameters:\n      //highlight-next-line\n    - default: 'chore: update $(.config.type)/$(.config.name)'\n      name: commit_message\n"})})})}),"\n",(0,s.jsx)(n.h3,{id:"go-templating",children:"Go Templating"}),"\n",(0,s.jsxs)(n.p,{children:["When templating ",(0,s.jsx)(n.code,{children:"actions"})," with ",(0,s.jsx)(n.a,{href:"/docs/reference/scripting/gotemplate",children:"Go Templates"}),", the context variables are available as fields of the template's context object ",(0,s.jsx)(n.code,{children:"."})," eg ",(0,s.jsx)(n.code,{children:".config"}),", ",(0,s.jsx)(n.code,{children:".user.email"})]}),"\n",(0,s.jsx)(t,{summary:"Templating Actions",children:(0,s.jsx)("div",{children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",metastring:'title="delete-kubernetes-pod.yaml" file=<rootDir>/modules/mission-control/fixtures/playbooks/scale-deployment.yaml',children:"apiVersion: mission-control.flanksource.com/v1\nkind: Playbook\nmetadata:\n  name: scale-deployment\nspec:\n  description: Scale Deployment\n  configs:\n    - types:\n        - Kubernetes::Deployment\n  parameters:\n    - name: replicas\n      label: The new desired number of replicas.\n  actions:\n    - name: kubectl scale\n      exec:\n        script: |\n          kubectl scale --replicas={{.params.replicas}} \\\n            --namespace={{.config.tags.namespace}} \\\n            deployment {{.config.name}}\n"})})})}),"\n",(0,s.jsx)(n.h3,{id:"functions",children:"Functions"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Function"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{children:"Return"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"getLastAction()"})}),(0,s.jsx)(n.td,{children:"Returns the result of the action that just run"}),(0,s.jsx)(n.td,{children:"Action Specific"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"getAction({action})"})}),(0,s.jsx)(n.td,{children:"Return the result of a specific action"}),(0,s.jsx)(n.td,{children:"Action Specific"})]})]})]}),"\n",(0,s.jsx)(n.admonition,{title:"Printing out Results",type:"tip"}),"\n",(0,s.jsx)(t,{summary:"Reusing Action Results",children:(0,s.jsx)("div",{children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yaml",metastring:'title="action-results.yaml" file=<rootDir>/modules/mission-control/fixtures/playbooks/action-result.yaml',children:"apiVersion: mission-control.flanksource.com/v1\nkind: Playbook\nmetadata:\n  name: use-previous-action-result\nspec:\n  description: Creates a file with the content of the config\n  configs:\n    - types:\n        - Kubernetes::Pod\n  actions:\n    - name: Fetch all changes\n      sql:\n        query: SELECT id FROM config_changes WHERE config_id = '{{.config.id}}'\n        driver: postgres\n        connection: connection://postgres/local\n    - name: Send notification\n      if: 'last_result().count > 0'\n      notification:\n        title: 'Changes summary for {{.config.name}}'\n        connection: connection://slack/flanksource\n        message: |\n          {{$rows:=index last_result \"count\"}}\n          Found {{$rows}} changes\n"})})})})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},28453(e,n,t){t.d(n,{R:()=>c,x:()=>r});var i=t(96540);const s={},o=i.createContext(s);function c(e){const n=i.useContext(o);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),i.createElement(o.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.