struct Swarmy::Server

Overview

A named remote Docker Swarm host, reachable over SSH.

Servers are typically loaded from ~/.config/swarmy/servers.yml via .load_all, but can also be built ad hoc (e.g. from --host/--user/--port).

Defined in:

swarmy/server.cr

Constant Summary

DEFAULT_PATH = File.join(ENV["HOME"]? || "", ".config", "swarmy", "servers.yml")

Default location of the saved-servers YAML file, under the user's config dir.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(name : String, host : String, user : Nil | String = nil, port : Int32 | Nil = nil) #

Class Method Detail

def self.find(name : String, servers : Array(Server) = load_all) : Server | Nil #

Finds a saved server by name, or nil if none matches.


def self.load_all(path : String = DEFAULT_PATH) : Array(Server) #

Loads all servers saved at path.

Returns an empty array if the file is missing, has no servers key, or fails to parse as YAML (a warning is printed to stderr in that case).


def self.save(server : Server, path : String = DEFAULT_PATH) : Nil #

Persists server to path, replacing any existing entry with the same name.


Instance Method Detail

def docker_host : String #

Builds the ssh:// URL used as DOCKER_HOST to reach this server.


def host : String #

def name : String #

def port : Int32 | Nil #

def user : String | Nil #