Sovite.Core.Postfix.Migration (sovite v0.6.0)

Copy Markdown View Source

Turns a Postfix configuration into a Sovite one, for sovitectl migrate postfix.

migrate/3 reads the contents of main.cf and master.cf, and the lookup tables they name through a read function, and returns:

  • config - a sovite.toml, which Sovite.Core.Config.parse/1 accepts. Values that need a look have a # check: comment.
  • script - an import.sh of sovitectl commands that load the lookup tables (aliases, mailboxes, transports, access rules, ...) into Sovite's database. It can hold relay passwords.
  • report - what was migrated, what was ignored because Sovite does it anyway or it does not apply, and what needs attention: settings Sovite has no equivalent for, and manual steps.

It also returns the report lines as entries, the commands of the script as commands (argument lists, or {:stdin, password, args}), and the problems Config.parse/1 found in config as errors, which should be none.

Only the parameters main.cf sets are reported, apart from Postfix defaults that change what Sovite does (such as mynetworks_style). The files are untrusted input: no atoms are created from them.

Summary

Types

A report line.

Functions

Migrates main_cf and master_cf (nil when there is none).

Types

entry()

@type entry() :: %{
  level: :attention | :migrated | :ignored,
  setting: String.t(),
  value: String.t() | nil,
  message: String.t()
}

A report line.

result()

@type result() :: %{
  config: String.t(),
  script: String.t(),
  report: String.t(),
  entries: [entry()],
  commands: [[String.t()] | {:stdin, String.t(), [String.t()]}],
  errors: [String.t()]
}

Functions

migrate(main_cf, master_cf, opts \\ [])

@spec migrate(String.t(), String.t() | nil, keyword()) :: result()

Migrates main_cf and master_cf (nil when there is none).

Options:

  • :read - reads a file Postfix names, such as a lookup table's source: (path -> {:ok, binary} | {:error, reason}). Default: File.read/1.
  • :defaults - Postfix defaults that depend on the system, such as "myhostname". See Sovite.Core.Postfix.MainCf.parse/2.
  • :source - where the files came from, for the comments.
  • :date - the date for the comments. Default: today.