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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecae4680a42c6d7ad196463b79e0d5d82916854959f3fd03708e062b48ddbc26
4
- data.tar.gz: ee12f3b11a6801dcdd2b26cb2a5e8476fab8c4767055f2a27474438db5826e4a
3
+ metadata.gz: 707204a31dc5981d5d933d6f7b268727b61cb8c535e1abf856ea8ea944095ed3
4
+ data.tar.gz: e9358c4a44acc4636a55f42a0aaf862a103752a295702dd5f47e592a11f2fb0b
5
5
  SHA512:
6
- metadata.gz: 9c4e980362a3b2699edb4862bcd0c3199c6ddbcc516532499a0aabebbf31bcaecbdff40a80054ec1a340e0ea988c24e0b21a66414392cd46be1c1d56aecff1da
7
- data.tar.gz: eebf977ed6e79c4e1ea8608e4ca4eaf208ac1b8a6f82a487e78ef711fa45bf8952bc2fa3dd98712211ed18d07ba563210c0678f05415cc0c71da7e1480bea928
6
+ metadata.gz: 26866d980e84a0d55205a6fb716b74a91a3ba7be1b2c0667fa84e9085c356bdb43cf82cc1434209065eb29c5fb13485ad5f19947305da72345ad6326f740eb75
7
+ data.tar.gz: ce3de3f45076654f9972163f73c4f3ee641bde236fcefaa9c0312c46fa70d0d4e4f70feb1e3c743de6a735ef40fed58993d125c693c2a81f9893b3bf85a205d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devkitkat (0.1.14)
4
+ devkitkat (0.1.15)
5
5
  activesupport (~> 6.0.0)
6
6
  colorize (~> 0.8.1)
7
7
  docker-api (~> 1.34.2)
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 ${MI_SYSTEM_SCRIPT_SHARED_DIR}
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
- - `MI_<service>_DIR` ... The root directory path of the service.
199
- - `MI_<service>_SCRIPT_DIR` ... The script directory path of the service.
200
- - `MI_<service>_SRC_DIR` ... The source directory path of the service.
201
- - `MI_<service>_CACHE_DIR` ... The cache directory path of the service.
202
- - `MI_<service>_DATA_DIR` ... The data directory path of the service.
203
- - `MI_<service>_LOG_DIR` ... The log directory path of the service.
204
- - `MI_<service>_EXAMPLE_DIR` ... The example directory path of the service.
205
- - `MI_<service>_<key>` ... The value of the user-defined variable.
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 `MI_<service>_<key>`.
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`, `MI_RAILS_DIR` is the root directory path of the service.
213
- - `key` is *uppercase* e.g. `MI_RAILS_HOST`
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, `MI_SELF_DIR` is `services/workhorse`,
217
- on the other hand, if you run a script for `gitaly` service, `MI_SELF_DIR` is `services/gitaly`.
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
 
@@ -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
- raise ArgumentError, "The target name #{target} couldn't be resolved"
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
@@ -105,32 +105,32 @@ set -e
105
105
  executor.write("export #{key}=#{value}")
106
106
  end
107
107
 
108
- executor.write("export MI_ROOT_DIR=#{kit_root}")
109
- executor.write("export MI_ENVIRONMENT_TYPE=#{config.environment_type.to_s}")
110
- executor.write("export MI_APPLICATION=#{config.application.to_s}")
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 MI_#{service.name.upcase}_DIR=#{service.service_dir}")
115
+ executor.write("export DK_#{service.name.upcase}_DIR=#{service.service_dir}")
116
116
 
117
117
  DIVISIONS.each do |division|
118
- executor.write("export MI_#{service.name.upcase}_#{division.upcase}_DIR=#{service.send("#{division}_dir")}")
118
+ executor.write("export DK_#{service.name.upcase}_#{division.upcase}_DIR=#{service.send("#{division}_dir")}")
119
119
  end
120
120
 
121
- executor.write("export MI_#{service.name.upcase}_SHARED_SCRIPT_DIR=#{service.shared_script_dir}")
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 MI_#{service.name.upcase}_#{key.upcase}=#{value}")
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 MI_SELF_DIR=#{service_dir}")
130
+ executor.write("export DK_SELF_DIR=#{service_dir}")
131
131
 
132
132
  DIVISIONS.each do |division|
133
- executor.write("export MI_SELF_#{division.upcase}_DIR=#{send("#{division}_dir")}")
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|
@@ -1,3 +1,3 @@
1
1
  module Devkitkat
2
- VERSION = "0.1.14"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devkitkat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinya Maeda