Class: RKSeal::Commands::List

Inherits:
Object
  • Object
show all
Defined in:
lib/rkseal/commands/list.rb

Overview

Orchestrates the ‘rkseal list [namespace]` flow.

Lists the SealedSecret CRD objects in the cluster (all namespaces, or a single one) as a kubectl-style table. Strictly read-only and metadata-only: it prints solely each object’s namespace, name, derived scope, and age – NEVER any part of ‘spec.encryptedData` (not even its keys). No editor, no RAM workspace, no file is written.

Examples:

all namespaces

puts RKSeal::Commands::List.new.call

one namespace

puts RKSeal::Commands::List.new(namespace: "app").call

Constant Summary collapse

HEADERS =

Column headers, in display order.

%w[NAMESPACE NAME SCOPE AGE].freeze
SCOPE_LABELS =

Scope symbol -> the dashed display label shown in the SCOPE column.

{
  strict: "strict",
  namespace_wide: "namespace-wide",
  cluster_wide: "cluster-wide"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace: nil, kubectl: Kubectl.new, now: Time.now) ⇒ List

Returns a new instance of List.

Parameters:

  • namespace (String, nil) (defaults to: nil)

    limit to this namespace; nil lists all.

  • kubectl (RKSeal::Kubectl) (defaults to: Kubectl.new)

    cluster adapter (read only).

  • now (Time) (defaults to: Time.now)

    clock used to compute AGE (injectable for tests).



37
38
39
40
41
# File 'lib/rkseal/commands/list.rb', line 37

def initialize(namespace: nil, kubectl: Kubectl.new, now: Time.now)
  @namespace = namespace
  @kubectl = kubectl
  @now = now
end

Instance Attribute Details

#namespaceString? (readonly)

Returns the namespace filter, or nil for all namespaces.

Returns:

  • (String, nil)

    the namespace filter, or nil for all namespaces.



22
23
24
# File 'lib/rkseal/commands/list.rb', line 22

def namespace
  @namespace
end

Instance Method Details

#callString

Run the list flow: read the SealedSecrets and render the table.

Side effects: a single read-only ‘kubectl get sealedsecret`. No editor, no workspace, no file write.

Returns:

  • (String)

    the table (or a friendly empty-list message) to print.

Raises:



50
51
52
53
54
55
56
# File 'lib/rkseal/commands/list.rb', line 50

def call
  @kubectl.ensure_available!
  items = parse_items(@kubectl.list_sealedsecrets(namespace: @namespace))
  return empty_message if items.empty?

  render_table(items.map { |item| row_for(item) })
end