ferryboat 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ferryboat/config.rb +46 -39
- data/lib/ferryboat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ec8e08a0bd5b2267b5105ecfb141d84f9676fb97d46f1bae3bec54b902ad6c
|
4
|
+
data.tar.gz: bc74ed346fb5ac26e51822be2a7618fd7796e50405bc41c736a9e8d341f9025c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a438ac5e1db9b658dc1ebd827b5d5bb2a12442880611ad7db8b8d9bda3f9aae6905c478a189b14fd51da2cafe0ebd00eab47f288a32dd820a1bc5efbf19925e
|
7
|
+
data.tar.gz: 396a35fdf33e28ddabe7421a6a07fac4fbab754ebb747313a5f5494b19cb702469650793f4b6094b63a7af6793c9b0081e58be4ca81a1bb0cd55d28c32520ef5
|
data/lib/ferryboat/config.rb
CHANGED
@@ -11,41 +11,44 @@ module Ferryboat
|
|
11
11
|
|
12
12
|
REQUIRED_KEYS = %i[service image_repo domain].freeze
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
class << self
|
15
|
+
def from_env(env: ENV.fetch("FERRY_ENV", "production"))
|
16
|
+
new(
|
17
|
+
env: env,
|
18
|
+
service: ENV.fetch("FERRY_SERVICE", nil),
|
19
|
+
image_repo: ENV.fetch("FERRY_IMAGE", nil),
|
20
|
+
domain: ENV.fetch("FERRY_DOMAIN", nil),
|
21
|
+
host: ENV.fetch("FERRY_HOST", "localhost"),
|
22
|
+
provider: ENV.fetch("FERRY_PROVIDER", "docker"), # docker|kamal
|
23
|
+
git_url: ENV["GIT_URL"],
|
24
|
+
git_branch: ENV.fetch("GIT_BRANCH", "main"),
|
25
|
+
health_path: ENV.fetch("FERRY_HEALTH_PATH", "/up"),
|
26
|
+
health_timeout: Integer(ENV.fetch("FERRY_HEALTH_TIMEOUT", "120")),
|
27
|
+
detect_timeout: Integer(ENV.fetch("FERRY_TRAEFIK_DETECT_TIMEOUT", "60")),
|
28
|
+
auto_backup: ENV["FERRY_AUTO_BACKUP"] == "true"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Optional YAML loader (keeps env override semantics)
|
33
|
+
def from_file(path, env: "production")
|
34
|
+
data = File.exist?(path) ? (YAML.load_file(path) || {}) : {}
|
35
|
+
config = data[env] || data[env.to_s] || data[env.to_sym] || {}
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
detect_timeout: Integer(ENV["FERRY_TRAEFIK_DETECT_TIMEOUT"] || cfg["detect_timeout"] || 60),
|
47
|
-
auto_backup: (ENV["FERRY_AUTO_BACKUP"] || cfg["auto_backup"]).to_s == "true"
|
48
|
-
)
|
37
|
+
new(
|
38
|
+
env: env,
|
39
|
+
service: ENV["FERRY_SERVICE"] || config["service"],
|
40
|
+
image_repo: ENV["FERRY_IMAGE"] || config["image_repo"] || config["docker_registry"],
|
41
|
+
domain: ENV["FERRY_DOMAIN"] || config["domain"],
|
42
|
+
host: ENV["FERRY_HOST"] || config["host"] || "localhost",
|
43
|
+
provider: ENV["FERRY_PROVIDER"] || config["provider"] || "docker",
|
44
|
+
git_url: ENV["GIT_URL"] || config["git_url"],
|
45
|
+
git_branch: ENV["GIT_BRANCH"] || config["git_branch"] || "main",
|
46
|
+
health_path: ENV["FERRY_HEALTH_PATH"] || config["health_path"] || "/up",
|
47
|
+
health_timeout: Integer(ENV["FERRY_HEALTH_TIMEOUT"] || config["health_timeout"] || 120),
|
48
|
+
detect_timeout: Integer(ENV["FERRY_TRAEFIK_DETECT_TIMEOUT"] || config["detect_timeout"] || 60),
|
49
|
+
auto_backup: (ENV["FERRY_AUTO_BACKUP"] || config["auto_backup"]).to_s == "true"
|
50
|
+
)
|
51
|
+
end
|
49
52
|
end
|
50
53
|
|
51
54
|
def initialize(env:, service:, image_repo:, domain:, host:, provider:, git_url:, git_branch:, health_path:, health_timeout:, detect_timeout:, auto_backup:)
|
@@ -59,11 +62,11 @@ module Ferryboat
|
|
59
62
|
|
60
63
|
def validate!
|
61
64
|
missing = []
|
62
|
-
missing << :service
|
63
|
-
missing << :image_repo
|
64
|
-
missing << :domain
|
65
|
-
|
66
|
-
|
65
|
+
missing << :service if blank?(service)
|
66
|
+
missing << :image_repo if blank?(image_repo)
|
67
|
+
missing << :domain if blank?(domain)
|
68
|
+
raise ArgumentError, "Missing required config: #{missing.join(', ')}" unless missing.empty?
|
69
|
+
true
|
67
70
|
end
|
68
71
|
|
69
72
|
def provider_runner
|
@@ -84,5 +87,9 @@ module Ferryboat
|
|
84
87
|
end
|
85
88
|
|
86
89
|
private
|
90
|
+
|
91
|
+
def blank?(v)
|
92
|
+
v.nil? || v.to_s.strip.empty?
|
93
|
+
end
|
87
94
|
end
|
88
95
|
end
|
data/lib/ferryboat/version.rb
CHANGED