Class: Capsium::Reactor::Deploy
- Inherits:
-
Object
- Object
- Capsium::Reactor::Deploy
- Defined in:
- lib/capsium/reactor/deploy.rb,
sig/capsium/reactor/deploy.rbs
Overview
Reactor-side deployment configuration (deploy.json): everything that must NOT ship in the package — OAuth2 client secrets, the session signing secret, role assignments, an alternate htpasswd file, the public base URL.
Constant Summary collapse
- FILE =
"deploy.json"- ENV_VAR =
"CAPSIUM_DEPLOY"
Instance Attribute Summary collapse
-
#config ⇒ Hash[String, untyped]
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.load(source) ⇒ Deploy
Loads from an explicit path, an already-parsed Hash, or the CAPSIUM_DEPLOY environment variable; empty when unconfigured.
Instance Method Summary collapse
- #authentication ⇒ Hash[String, untyped]
- #base_url ⇒ String?
- #client_secret ⇒ String?
-
#initialize(config) ⇒ Deploy
constructor
A new instance of Deploy.
- #passwd_file ⇒ String?
-
#roles ⇒ Hash[String, Array[String]]
Role assignments keyed by identity name (basic-auth username, OAuth2 email or subject): ["admin", "user"].
- #session_secret ⇒ String?
Constructor Details
#initialize(config) ⇒ Deploy
Returns a new instance of Deploy.
40 41 42 |
# File 'lib/capsium/reactor/deploy.rb', line 40 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Hash[String, untyped] (readonly)
Returns the value of attribute config.
28 29 30 |
# File 'lib/capsium/reactor/deploy.rb', line 28 def config @config end |
Class Method Details
.load(source) ⇒ Deploy
Loads from an explicit path, an already-parsed Hash, or the CAPSIUM_DEPLOY environment variable; empty when unconfigured.
15 16 17 18 19 20 21 22 23 |
# File 'sig/capsium/reactor/deploy.rbs', line 15 def self.load(source) return new(source) if source.is_a?(Hash) path = source || ENV.fetch(ENV_VAR, nil) return new({}) if path.nil? || path.to_s.empty? raise Error, "deploy configuration not found: #{path}" unless File.file?(path) new(JSON.parse(File.read(path))) end |
Instance Method Details
#authentication ⇒ Hash[String, untyped]
44 45 46 |
# File 'lib/capsium/reactor/deploy.rb', line 44 def authentication config["authentication"] || {} end |
#base_url ⇒ String?
48 49 50 |
# File 'lib/capsium/reactor/deploy.rb', line 48 def base_url config["baseUrl"] end |
#client_secret ⇒ String?
52 53 54 |
# File 'lib/capsium/reactor/deploy.rb', line 52 def client_secret authentication.dig("oauth2", "clientSecret") end |
#passwd_file ⇒ String?
60 61 62 |
# File 'lib/capsium/reactor/deploy.rb', line 60 def passwd_file authentication.dig("basicAuth", "passwdFile") end |
#roles ⇒ Hash[String, Array[String]]
Role assignments keyed by identity name (basic-auth username, OAuth2 email or subject): ["admin", "user"].
66 67 68 |
# File 'lib/capsium/reactor/deploy.rb', line 66 def roles authentication["roles"] || {} end |
#session_secret ⇒ String?
56 57 58 |
# File 'lib/capsium/reactor/deploy.rb', line 56 def session_secret authentication["sessionSecret"] end |