devkitkat 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -14
- data/lib/devkitkat/config.rb +17 -1
- data/lib/devkitkat/service.rb +9 -9
- data/lib/devkitkat/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: 707204a31dc5981d5d933d6f7b268727b61cb8c535e1abf856ea8ea944095ed3
|
4
|
+
data.tar.gz: e9358c4a44acc4636a55f42a0aaf862a103752a295702dd5f47e592a11f2fb0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26866d980e84a0d55205a6fb716b74a91a3ba7be1b2c0667fa84e9085c356bdb43cf82cc1434209065eb29c5fb13485ad5f19947305da72345ad6326f740eb75
|
7
|
+
data.tar.gz: ce3de3f45076654f9972163f73c4f3ee641bde236fcefaa9c0312c46fa70d0d4e4f70feb1e3c743de6a735ef40fed58993d125c693c2a81f9893b3bf85a205d6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -147,7 +147,7 @@ To include the shared script, you need to update your service script as the foll
|
|
147
147
|
|
148
148
|
```shell
|
149
149
|
#!/bin/bash
|
150
|
-
source ${
|
150
|
+
source ${DK_SYSTEM_SCRIPT_SHARED_DIR}
|
151
151
|
|
152
152
|
# Call a function defiend in the `shared` script
|
153
153
|
```
|
@@ -195,26 +195,26 @@ Example:
|
|
195
195
|
|
196
196
|
Devkitkat inject these predefined variables into the scripts by default.
|
197
197
|
|
198
|
-
- `
|
199
|
-
- `
|
200
|
-
- `
|
201
|
-
- `
|
202
|
-
- `
|
203
|
-
- `
|
204
|
-
- `
|
205
|
-
- `
|
198
|
+
- `DK_<service>_DIR` ... The root directory path of the service.
|
199
|
+
- `DK_<service>_SCRIPT_DIR` ... The script directory path of the service.
|
200
|
+
- `DK_<service>_SRC_DIR` ... The source directory path of the service.
|
201
|
+
- `DK_<service>_CACHE_DIR` ... The cache directory path of the service.
|
202
|
+
- `DK_<service>_DATA_DIR` ... The data directory path of the service.
|
203
|
+
- `DK_<service>_LOG_DIR` ... The log directory path of the service.
|
204
|
+
- `DK_<service>_EXAMPLE_DIR` ... The example directory path of the service.
|
205
|
+
- `DK_<service>_<key>` ... The value of the user-defined variable.
|
206
206
|
|
207
207
|
NOTE:
|
208
208
|
- User-defined variables are injected with the bare name. e.g. If you define
|
209
209
|
`VERSION: 1`, then you get the value with `echo $VERSION`. From the other services,
|
210
|
-
the variable can be fetched as `
|
210
|
+
the variable can be fetched as `DK_<service>_<key>`.
|
211
211
|
- `service` is the *uppercase* service *name*. e.g. if the service name is
|
212
|
-
`rails`, `
|
213
|
-
- `key` is *uppercase* e.g. `
|
212
|
+
`rails`, `DK_RAILS_DIR` is the root directory path of the service.
|
213
|
+
- `key` is *uppercase* e.g. `DK_RAILS_HOST`
|
214
214
|
- You can also use `SELF` instead of specifying a service name.
|
215
215
|
The `SELF` indicates that it's a context specific parameter, for example,
|
216
|
-
if you run a script for `workhorse` service, `
|
217
|
-
on the other hand, if you run a script for `gitaly` service, `
|
216
|
+
if you run a script for `workhorse` service, `DK_SELF_DIR` is `services/workhorse`,
|
217
|
+
on the other hand, if you run a script for `gitaly` service, `DK_SELF_DIR` is `services/gitaly`.
|
218
218
|
|
219
219
|
## How to control services via scripts
|
220
220
|
|
data/lib/devkitkat/config.rb
CHANGED
@@ -23,10 +23,12 @@ module Devkitkat
|
|
23
23
|
all_services
|
24
24
|
elsif group = find_group(target)
|
25
25
|
services_for_group(group)
|
26
|
+
elsif services = find_comma_separated_services(target)
|
27
|
+
services
|
26
28
|
elsif service = find_service(target)
|
27
29
|
[service]
|
28
30
|
else
|
29
|
-
|
31
|
+
raise_error(target)
|
30
32
|
end
|
31
33
|
|
32
34
|
services = services - exclude if exclude
|
@@ -80,6 +82,16 @@ module Devkitkat
|
|
80
82
|
services.find { |service| service == target }
|
81
83
|
end
|
82
84
|
|
85
|
+
def find_comma_separated_services(target)
|
86
|
+
return unless target.include?(',')
|
87
|
+
|
88
|
+
target.split(',').map do |t|
|
89
|
+
find_service(t).tap do |service|
|
90
|
+
raise_error(t) unless service
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
83
95
|
def load_config
|
84
96
|
File.read(config_path).yield_self do |content|
|
85
97
|
YAML.load(content)
|
@@ -89,5 +101,9 @@ module Devkitkat
|
|
89
101
|
def config_path
|
90
102
|
File.join(kit_root, DEVKITKAT_FILE_NAME)
|
91
103
|
end
|
104
|
+
|
105
|
+
def raise_error(target)
|
106
|
+
raise ArgumentError, "The target name #{target} couldn't be resolved"
|
107
|
+
end
|
92
108
|
end
|
93
109
|
end
|
data/lib/devkitkat/service.rb
CHANGED
@@ -105,32 +105,32 @@ set -e
|
|
105
105
|
executor.write("export #{key}=#{value}")
|
106
106
|
end
|
107
107
|
|
108
|
-
executor.write("export
|
109
|
-
executor.write("export
|
110
|
-
executor.write("export
|
108
|
+
executor.write("export DK_ROOT_DIR=#{kit_root}")
|
109
|
+
executor.write("export DK_ENVIRONMENT_TYPE=#{config.environment_type.to_s}")
|
110
|
+
executor.write("export DK_APPLICATION=#{config.application.to_s}")
|
111
111
|
end
|
112
112
|
|
113
113
|
def inject_public_variables
|
114
114
|
all_services.each do |service|
|
115
|
-
executor.write("export
|
115
|
+
executor.write("export DK_#{service.name.upcase}_DIR=#{service.service_dir}")
|
116
116
|
|
117
117
|
DIVISIONS.each do |division|
|
118
|
-
executor.write("export
|
118
|
+
executor.write("export DK_#{service.name.upcase}_#{division.upcase}_DIR=#{service.send("#{division}_dir")}")
|
119
119
|
end
|
120
120
|
|
121
|
-
executor.write("export
|
121
|
+
executor.write("export DK_#{service.name.upcase}_SHARED_SCRIPT_DIR=#{service.shared_script_dir}")
|
122
122
|
|
123
123
|
config.service_hash(service.name).each do |key, value|
|
124
|
-
executor.write("export
|
124
|
+
executor.write("export DK_#{service.name.upcase}_#{key.upcase}=#{value}")
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
129
|
def inject_private_variables
|
130
|
-
executor.write("export
|
130
|
+
executor.write("export DK_SELF_DIR=#{service_dir}")
|
131
131
|
|
132
132
|
DIVISIONS.each do |division|
|
133
|
-
executor.write("export
|
133
|
+
executor.write("export DK_SELF_#{division.upcase}_DIR=#{send("#{division}_dir")}")
|
134
134
|
end
|
135
135
|
|
136
136
|
config.service_hash(name).each do |key, value|
|
data/lib/devkitkat/version.rb
CHANGED