envirobly 0.5.1 → 0.5.2
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/envirobly/config.rb +19 -20
- data/lib/envirobly/git/commit.rb +9 -0
- data/lib/envirobly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cbc25ee0033c84e86fd94e67a3be65ee43c8fbcfd86cd962ecf9e5f616bf042
|
4
|
+
data.tar.gz: e07002a42e3490bd841f6538ab7cd565990bf55e159fe8d7ce033cff62f6c38d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb490ba6309b3775f548522596c6a5d42504ba2ca878ef8c74b530af12733b9a9ac1ce016ece2afdb7d6c616f4121ca418a49ef3037e06790a9e3da3b916ba93
|
7
|
+
data.tar.gz: 7abc4689844be2617b74bb425c0ba8136b793d5c0c36600d58defdeadf8a84e9b31715442467c1e912b8988ee1c708c61eedb0192a2af3eadf9fc0b54bf0a327
|
data/lib/envirobly/config.rb
CHANGED
@@ -35,7 +35,7 @@ class Envirobly::Config
|
|
35
35
|
def to_deployment_params
|
36
36
|
{
|
37
37
|
environ: {
|
38
|
-
|
38
|
+
name: @environment,
|
39
39
|
project_url: @project_url
|
40
40
|
},
|
41
41
|
commit: {
|
@@ -57,17 +57,17 @@ class Envirobly::Config
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def set_project_url
|
60
|
-
@project_url = dig :
|
60
|
+
@project_url = dig :project
|
61
61
|
if @project_url.blank?
|
62
|
-
@errors << "Missing
|
62
|
+
@errors << "Missing `project: <url>` top level attribute."
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
def transform_env_var_values!
|
67
|
-
@project.fetch(:services, {}).each do |
|
67
|
+
@project.fetch(:services, {}).each do |name, service|
|
68
68
|
service.fetch(:env, {}).each do |key, value|
|
69
69
|
if value.is_a?(Hash) && value.has_key?(:file)
|
70
|
-
@project[:services][
|
70
|
+
@project[:services][name][:env][key] = @commit.file_content(value.fetch(:file)).strip
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -75,39 +75,38 @@ class Envirobly::Config
|
|
75
75
|
|
76
76
|
NON_BUILDABLE_TYPES = %w[ postgres mysql valkey ]
|
77
77
|
BUILD_DEFAULTS = {
|
78
|
-
dockerfile: "Dockerfile",
|
79
|
-
build_context: "."
|
78
|
+
dockerfile: [ "Dockerfile", :file_exists? ],
|
79
|
+
build_context: [ ".", :dir_exists? ]
|
80
80
|
}
|
81
81
|
def append_image_tags!
|
82
|
-
@project.fetch(:services, {}).each do |
|
82
|
+
@project.fetch(:services, {}).each do |name, service|
|
83
83
|
next if NON_BUILDABLE_TYPES.include?(service[:type]) || service[:image].present?
|
84
84
|
checksums = []
|
85
85
|
|
86
|
-
BUILD_DEFAULTS.each do |attribute,
|
87
|
-
value = service.fetch(attribute,
|
88
|
-
|
89
|
-
|
90
|
-
@errors << "Service `#{logical_id}` specifies `#{attribute}` as `#{value}` which doesn't exist in this commit."
|
86
|
+
BUILD_DEFAULTS.each do |attribute, options|
|
87
|
+
value = service.fetch(attribute, options.first)
|
88
|
+
unless @commit.public_send(options.second, value)
|
89
|
+
@errors << "Service `#{name}` specifies `#{attribute}` as `#{value}` which doesn't exist in this commit."
|
91
90
|
else
|
92
|
-
checksums <<
|
91
|
+
checksums << @commit.objects_with_checksum_at(value)
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
96
95
|
if checksums.size == 2
|
97
|
-
@project[:services][
|
96
|
+
@project[:services][name][:image_tag] = Digest::SHA1.hexdigest checksums.to_json
|
98
97
|
end
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
102
101
|
def merge_environment_overrides!
|
103
102
|
return unless services = @project.dig(:environments, @environment.to_sym)
|
104
|
-
services.each do |
|
103
|
+
services.each do |name, service|
|
105
104
|
service.each do |attribute, value|
|
106
|
-
if value.is_a?(Hash) && @project[:services][
|
107
|
-
@project[:services][
|
108
|
-
@project[:services][
|
105
|
+
if value.is_a?(Hash) && @project[:services][name][attribute].is_a?(Hash)
|
106
|
+
@project[:services][name][attribute].merge! value
|
107
|
+
@project[:services][name][attribute].compact!
|
109
108
|
else
|
110
|
-
@project[:services][
|
109
|
+
@project[:services][name][attribute] = value
|
111
110
|
end
|
112
111
|
end
|
113
112
|
end
|
data/lib/envirobly/git/commit.rb
CHANGED
@@ -23,6 +23,15 @@ class Envirobly::Git::Commit
|
|
23
23
|
Time.parse git(%(log #{@ref} -n1 --date=iso --pretty=format:"%ad")).stdout
|
24
24
|
end
|
25
25
|
|
26
|
+
def file_exists?(path)
|
27
|
+
git(%(cat-file -t #{@ref}:#{path})).stdout.strip == "blob"
|
28
|
+
end
|
29
|
+
|
30
|
+
def dir_exists?(path)
|
31
|
+
suffix = path.end_with?("/") ? nil : "/"
|
32
|
+
git(%(cat-file -t #{@ref}:#{path}#{suffix})).stdout.strip == "tree"
|
33
|
+
end
|
34
|
+
|
26
35
|
def file_content(path)
|
27
36
|
git(%(show #{@ref}:#{path})).stdout
|
28
37
|
end
|
data/lib/envirobly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envirobly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Starsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|