Class: Textus::CLI::Verb::PolicyList

Inherits:
Textus::CLI::Verb show all
Defined in:
lib/textus/cli/verb/policy_list.rb

Instance Attribute Summary

Attributes inherited from Textus::CLI::Verb

#positional

Instance Method Summary collapse

Methods inherited from Textus::CLI::Verb

#context_for, #emit, inherited, #initialize, needs_store?, option, options, #parse, #resolved_role

Constructor Details

This class inherits a constructor from Textus::CLI::Verb

Instance Method Details

#call(store) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/textus/cli/verb/policy_list.rb', line 5

def call(store)
  policies = store.manifest.policies.blocks.map do |b|
    row = { "match" => b.match }
    if b.refresh
      row["refresh"] = {
        "ttl_seconds" => b.refresh.ttl_seconds,
        "on_stale" => b.refresh.on_stale,
        "sync_budget_ms" => b.refresh.sync_budget_ms,
      }
    end
    row["handler_allowlist"] = b.handler_allowlist.handlers if b.handler_allowlist
    row["promote_requires"] = b.promote.requires if b.promote
    row["retention"] = b.retention if b.retention
    row
  end
  emit({ "verb" => "policy_list", "policies" => policies })
end