argo-cd/resource_customizations/argoproj.io/Application/actions/toggle-auto-sync/action.lua
Vikas Rao 48f18e2905
feat: add toggle-auto-sync resource action for Application (#21564) (#26477)
Signed-off-by: vikasrao23 <vikasrao23@users.noreply.github.com>
Co-authored-by: vikasrao23 <vikasrao23@users.noreply.github.com>
2026-04-07 06:12:32 -04:00

23 lines
606 B
Lua

if obj.spec == nil then
obj.spec = {}
end
if obj.spec.syncPolicy == nil then
obj.spec.syncPolicy = {}
end
local automated = obj.spec.syncPolicy.automated
local isEnabled = automated ~= nil and (automated.enabled == true or automated.enabled == nil)
if isEnabled then
-- Currently ENABLED (enabled=true or enabled=nil): disable it
automated.enabled = false
else
-- Currently DISABLED (automated absent or enabled=false): enable it
if automated == nil then
obj.spec.syncPolicy.automated = { enabled = true }
else
automated.enabled = true
end
end
return obj