module Obsctl::Config::ConfigInspector

Overview

Answers three questions about a config file that the schema alone cannot: where each effective value came from (.explain), how the file departs from the defaults (.diff), and what rewriting it in the current schema would change (.migrate).

All three work on dotted key paths flattened from the canonical YAML serialization, so they stay correct as the schema grows without needing a hand-maintained key list.

Defined in:

obsctl/config/config_inspector.cr

Class Method Summary

Class Method Detail

def self.diff(path : String) : Array(Change) #

Returns the settings where the file departs from the defaults.

A key present in only one side is still a change: default or current is null to say which side lacks it.


[View source]
def self.explain(path : String) : Array(Entry) #

Returns every effective setting with the source that supplied it.


[View source]
def self.flatten(yaml : String) : Hash(String, String) #

Flattens a YAML document into dotted key paths.

Sequences are rendered as a single inline value rather than indexed keys: aliases and shortcuts read better as one line, and an index-based key path would make reordering a list look like a settings change.


[View source]
def self.migrate(path : String, dry_run : Bool = false, writer : ConfigWriter = ConfigWriter.new) : Migration #

Rewrites the file in the current canonical schema.

dry_run reports what would change without touching the file. Keys the current schema does not recognize are dropped, which is the point of the command: it is how a config written for an older obsctl stops carrying settings that no longer do anything.


[View source]