pups 1.2.1 → 1.3.0
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/.github/workflows/ci.yml +5 -5
- data/.rubocop.yml +0 -1
- data/CHANGELOG +4 -0
- data/README.md +22 -2
- data/lib/pups/cli.rb +9 -2
- data/lib/pups/config.rb +24 -12
- data/lib/pups/exec_command.rb +0 -1
- data/lib/pups/file_command.rb +0 -2
- data/lib/pups/version.rb +1 -1
- data/pups.gemspec +1 -1
- data/test/cli_test.rb +24 -0
- data/test/config_test.rb +10 -0
- 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: 3a3b8f3717bb917e039d84ec656835ce1c4b213d481de705244bb15fa58e8f1a
|
4
|
+
data.tar.gz: f104c2f76abccafc9705c08a1619dd1a0351ad91a19ddf5c29cb4f9bc283a91d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de7bd31e09e421f3a2ff172199694cc19e757a4be8fde50188cde889f8ca788c15f9733d354ad6ee0b8ef6551f804bdf470ab8175059a5b66be05d9c73cadf5f
|
7
|
+
data.tar.gz: 8b704e22e578e48870733a8c3925afff1dc7773cf17fe5a5c9182fa1a464fc2ca97c80a0bed174393e54ff5f2e3071d9c4abb2eee8086c07a9c96da0c44267b1
|
data/.github/workflows/ci.yml
CHANGED
@@ -16,10 +16,10 @@ jobs:
|
|
16
16
|
fail-fast: true
|
17
17
|
matrix:
|
18
18
|
os: [ubuntu-latest]
|
19
|
-
ruby: ["3.
|
19
|
+
ruby: ["3.3"]
|
20
20
|
|
21
21
|
steps:
|
22
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v4
|
23
23
|
- uses: ruby/setup-ruby@v1
|
24
24
|
with:
|
25
25
|
ruby-version: ${{ matrix.ruby }}
|
@@ -34,10 +34,10 @@ jobs:
|
|
34
34
|
fail-fast: true
|
35
35
|
matrix:
|
36
36
|
os: [ubuntu-latest]
|
37
|
-
ruby: ["3.
|
37
|
+
ruby: ["3.3"]
|
38
38
|
|
39
39
|
steps:
|
40
|
-
- uses: actions/checkout@
|
40
|
+
- uses: actions/checkout@v4
|
41
41
|
- uses: ruby/setup-ruby@v1
|
42
42
|
with:
|
43
43
|
ruby-version: ${{ matrix.ruby }}
|
@@ -52,7 +52,7 @@ jobs:
|
|
52
52
|
runs-on: ubuntu-latest
|
53
53
|
|
54
54
|
steps:
|
55
|
-
- uses: actions/checkout@
|
55
|
+
- uses: actions/checkout@v4
|
56
56
|
|
57
57
|
- name: Release Gem
|
58
58
|
uses: discourse/publish-rubygems-action@v2
|
data/.rubocop.yml
CHANGED
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -25,10 +25,10 @@ Usage: pups [options] [FILE|--stdin]
|
|
25
25
|
--stdin Read input from stdin.
|
26
26
|
--quiet Don't print any logs.
|
27
27
|
--ignore <elements> Ignore specific configuration elements, multiple elements can be provided (comma-delimited).
|
28
|
-
--tags <elements> Only run tagged commands.
|
29
|
-
--skip-tags <elements> Run all but listed tagged commands.
|
30
28
|
Useful if you want to skip over config in a pups execution.
|
31
29
|
e.g. `--ignore env,params`.
|
30
|
+
--tags <elements> Only run tagged commands.
|
31
|
+
--skip-tags <elements> Run all but listed tagged commands.
|
32
32
|
--gen-docker-run-args Output arguments from the pups configuration for input into a docker run command. All other pups config is ignored.
|
33
33
|
-h, --help
|
34
34
|
```
|
@@ -76,6 +76,26 @@ Running: `pups --tags="sometag,anothertag" somefile.yaml` will not run the echo
|
|
76
76
|
|
77
77
|
Running: `pups --skip-tags="sometag,anothertag" somefile.yaml` will ONLY run the echo goodbye statement.
|
78
78
|
|
79
|
+
#### Parameter overriding
|
80
|
+
|
81
|
+
The `--params` argument allows pups to dynamically override params set within a configuration for the single pups run.
|
82
|
+
|
83
|
+
Note, it is expected to be of the form `key=value`. If it is malformed, a warning will be thrown.
|
84
|
+
|
85
|
+
Example:
|
86
|
+
|
87
|
+
```
|
88
|
+
# somefile.yaml
|
89
|
+
|
90
|
+
params:
|
91
|
+
param1: false_prophet
|
92
|
+
param2: also overridden
|
93
|
+
run:
|
94
|
+
- exec:
|
95
|
+
cmd: /bin/bash -c 'echo $param1 $param2 >> hello'
|
96
|
+
```
|
97
|
+
Running `pups --params="param1=true_value,param2=other_true_value" somefile.yaml` will overwrite param1 and param2 with true_value and other_true_value respectively
|
98
|
+
|
79
99
|
#### Docker run argument generation
|
80
100
|
|
81
101
|
The `--gen-docker-run-args` argument is used to make pups output arguments be in the format of `docker run <arguments output>`. Specifically, pups
|
data/lib/pups/cli.rb
CHANGED
@@ -24,6 +24,11 @@ module Pups
|
|
24
24
|
Array,
|
25
25
|
"Run all but listed tagged commands."
|
26
26
|
)
|
27
|
+
opts.on(
|
28
|
+
"--params <param(s)>",
|
29
|
+
Array,
|
30
|
+
"Replace params in the config with params listed."
|
31
|
+
)
|
27
32
|
opts.on("-h", "--help") do
|
28
33
|
puts opts
|
29
34
|
exit
|
@@ -69,7 +74,8 @@ module Pups
|
|
69
74
|
conf,
|
70
75
|
options[:ignore],
|
71
76
|
tags: options[:tags],
|
72
|
-
skip_tags: options[:"skip-tags"]
|
77
|
+
skip_tags: options[:"skip-tags"],
|
78
|
+
extra_params: options[:params]
|
73
79
|
)
|
74
80
|
else
|
75
81
|
config =
|
@@ -77,7 +83,8 @@ module Pups
|
|
77
83
|
input_file,
|
78
84
|
options[:ignore],
|
79
85
|
tags: options[:tags],
|
80
|
-
skip_tags: options[:"skip-tags"]
|
86
|
+
skip_tags: options[:"skip-tags"],
|
87
|
+
extra_params: options[:params]
|
81
88
|
)
|
82
89
|
end
|
83
90
|
|
data/lib/pups/config.rb
CHANGED
@@ -7,8 +7,9 @@ module Pups
|
|
7
7
|
def initialize(
|
8
8
|
config,
|
9
9
|
ignored = nil,
|
10
|
-
tags:
|
11
|
-
skip_tags:
|
10
|
+
tags: nil,
|
11
|
+
skip_tags: nil,
|
12
|
+
extra_params: nil
|
12
13
|
)
|
13
14
|
@config = config
|
14
15
|
|
@@ -41,6 +42,16 @@ module Pups
|
|
41
42
|
)
|
42
43
|
|
43
44
|
@params = @config["params"]
|
45
|
+
if extra_params
|
46
|
+
extra_params.each do |val|
|
47
|
+
key_val = val.split("=", 2)
|
48
|
+
if key_val.length == 2
|
49
|
+
@params[key_val[0]] = key_val[1]
|
50
|
+
else
|
51
|
+
warn "Malformed param #{val}. Expected param to be of the form `key=value`"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
44
55
|
ENV.each { |k, v| @params["$ENV_#{k}"] = v }
|
45
56
|
inject_hooks
|
46
57
|
end
|
@@ -48,14 +59,16 @@ module Pups
|
|
48
59
|
def self.load_file(
|
49
60
|
config_file,
|
50
61
|
ignored = nil,
|
51
|
-
tags:
|
52
|
-
skip_tags:
|
62
|
+
tags: nil,
|
63
|
+
skip_tags: nil,
|
64
|
+
extra_params: nil
|
53
65
|
)
|
54
66
|
Config.new(
|
55
67
|
YAML.load_file(config_file),
|
56
68
|
ignored,
|
57
69
|
tags: tags,
|
58
|
-
skip_tags: skip_tags
|
70
|
+
skip_tags: skip_tags,
|
71
|
+
extra_params: extra_params
|
59
72
|
)
|
60
73
|
rescue Exception
|
61
74
|
warn "Failed to parse #{config_file}"
|
@@ -67,14 +80,16 @@ module Pups
|
|
67
80
|
def self.load_config(
|
68
81
|
config,
|
69
82
|
ignored = nil,
|
70
|
-
tags:
|
71
|
-
skip_tags:
|
83
|
+
tags: nil,
|
84
|
+
skip_tags: nil,
|
85
|
+
extra_params: nil
|
72
86
|
)
|
73
87
|
Config.new(
|
74
88
|
YAML.safe_load(config),
|
75
89
|
ignored,
|
76
90
|
tags: tags,
|
77
|
-
skip_tags: skip_tags
|
91
|
+
skip_tags: skip_tags,
|
92
|
+
extra_params: extra_params
|
78
93
|
)
|
79
94
|
end
|
80
95
|
|
@@ -108,10 +123,7 @@ module Pups
|
|
108
123
|
|
109
124
|
# Filter run commands by tag: by default, keep all commands that contain tags.
|
110
125
|
# If skip_tags argument is true, keep all commands that DO NOT contain tags.
|
111
|
-
def filter_tags(
|
112
|
-
include_tags: include_tags = nil,
|
113
|
-
exclude_tags: exclude_tags = nil
|
114
|
-
)
|
126
|
+
def filter_tags(include_tags: nil, exclude_tags: nil)
|
115
127
|
if include_tags
|
116
128
|
@config["run"] = @config["run"].select do |row|
|
117
129
|
keep = false
|
data/lib/pups/exec_command.rb
CHANGED
data/lib/pups/file_command.rb
CHANGED
data/lib/pups/version.rb
CHANGED
data/pups.gemspec
CHANGED
data/test/cli_test.rb
CHANGED
@@ -140,6 +140,7 @@ module Pups
|
|
140
140
|
Cli.run(["--tags", "1,3", cf.path])
|
141
141
|
assert_equal("1\n3", File.read(f.path).strip)
|
142
142
|
end
|
143
|
+
|
143
144
|
def test_cli_skip_tags
|
144
145
|
# for testing output
|
145
146
|
f = Tempfile.new("test_output")
|
@@ -164,5 +165,28 @@ module Pups
|
|
164
165
|
Cli.run(["--skip-tags", "1,3", cf.path])
|
165
166
|
assert_equal("2", File.read(f.path).strip)
|
166
167
|
end
|
168
|
+
|
169
|
+
def test_cli_params
|
170
|
+
# for testing output
|
171
|
+
f = Tempfile.new("test_output")
|
172
|
+
f.close
|
173
|
+
|
174
|
+
# for testing input
|
175
|
+
cf = Tempfile.new("test_config")
|
176
|
+
cf.puts <<~YAML
|
177
|
+
params:
|
178
|
+
one: 0
|
179
|
+
two: 0
|
180
|
+
run:
|
181
|
+
- exec:
|
182
|
+
cmd: echo $one >> #{f.path}
|
183
|
+
- exec:
|
184
|
+
cmd: echo $two >> #{f.path}
|
185
|
+
YAML
|
186
|
+
cf.close
|
187
|
+
|
188
|
+
Cli.run(["--params", "one=1,two=2", cf.path])
|
189
|
+
assert_equal("1\n2", File.read(f.path).strip)
|
190
|
+
end
|
167
191
|
end
|
168
192
|
end
|
data/test/config_test.rb
CHANGED
@@ -283,5 +283,15 @@ module Pups
|
|
283
283
|
config["run"][1]
|
284
284
|
)
|
285
285
|
end
|
286
|
+
|
287
|
+
def test_extra_params
|
288
|
+
config = <<~YAML
|
289
|
+
params:
|
290
|
+
one: 1
|
291
|
+
YAML
|
292
|
+
config = Config.new(YAML.safe_load(config), extra_params: %w[one=2 two=2])
|
293
|
+
assert_equal("2", config.params["one"])
|
294
|
+
assert_equal("2", config.params["two"])
|
295
|
+
end
|
286
296
|
end
|
287
297
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|