Skip to content

Commit 97d8648

Browse files
authored
Merge pull request #273 from ruriky/fix_pack_install
Use column "ref" when checking already installed packs.
2 parents f5c9b75 + 91a216d commit 97d8648

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
(Enhancement)
2424
Contributed by @nmaludy
2525

26+
- Already installed packs are now recognized by their configured "ref" variable instead of "name"
27+
(Enhancement)
28+
Contributed by @ruriky
29+
2630
## 1.4.0 (Feb 13, 2019)
2731

2832
- Added new tasks to communicate with the StackStorm CLI. The naming standard and parameters

lib/puppet/provider/st2_pack/default.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def exists?
3030

3131
def list_installed_packs
3232
token = st2_authenticate
33-
output = exec_st2('pack', 'list', '-a', 'name', '-j', '-t', token)
33+
output = exec_st2('pack', 'list', '-a', 'ref', '-j', '-t', token)
3434
parse_output_json(output)
3535
end
3636

@@ -39,7 +39,7 @@ def parse_output_json(raw)
3939
result = []
4040
if raw && !raw.empty?
4141
pack_list = JSON.parse(raw)
42-
result = pack_list.map { |pack| pack['name'] }
42+
result = pack_list.map { |pack| pack['ref'] }
4343
debug("Installed packs: #{result}")
4444
end
4545
result

spec/unit/puppet/provider/st2_pack/default_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@
8787
'-p', 'st2_password')
8888
.and_return('token')
8989
expect(provider).to receive(:exec_st2).with('pack', 'list',
90-
'-a', 'name',
90+
'-a', 'ref',
9191
'-j',
9292
'-t', 'token')
93-
.and_return('[{"name": "pack1"}, {"name": "pack2"}]')
93+
.and_return('[{"ref": "pack1"}, {"ref": "pack2"}]')
9494
expect(provider.list_installed_packs).to eq ['pack1', 'pack2']
9595
end
9696
end
@@ -105,7 +105,7 @@
105105
end
106106

107107
it 'extracts pack names from a JSON string' do
108-
expect(provider.parse_output_json('[{"name": "core"}, {"name": "examples"}]')).to eq ['core', 'examples']
108+
expect(provider.parse_output_json('[{"ref": "core"}, {"ref": "examples"}]')).to eq ['core', 'examples']
109109
end
110110
end
111111

0 commit comments

Comments
 (0)