Skip to content

Commit 1eec258

Browse files
author
Meir Wahnon
committed
Merge pull request #1 from meirwah/add_tests_for_csr
Add tests for csr
2 parents 014bad4 + c87ccb6 commit 1eec258

File tree

111 files changed

+2413
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+2413
-253
lines changed

CHANGELOG.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Changelog
44
in development
55
--------------
66

7+
* Add support for script arguments to the Windows script runner. (new feature)
8+
[James Sigurðarson]
9+
* Allow user to filter executions on trigger instance id.
10+
[Sayli Karmarkar]
11+
12+
0.11 - June 5, 2015
13+
-------------------
14+
715
* Allow user to configure the CLI using an ini style config file located at ``~/.st2rc``.
816
(new-feature)
917
* Add support for caching of the retrieved auth tokens to the CLI. (new-feature)
@@ -20,9 +28,16 @@ in development
2028
(new-feature)
2129
* Rules should be part of a pack. (improvement)
2230
* Update Windows runner code so it also works with a newer versions of winexe (> 1.0).
23-
(improvements)
31+
(improvement)
2432
[James Sigurðarson]
2533
* CLI now has ``get`` and ``list`` commands for triggerinstance. (new-feature)
34+
* Validate parameters during rule creation for system triggers. (improvement)
35+
* CLI now has ``re-emit`` command for triggerinstance. (new-feature)
36+
37+
v0.9.2 - May 26, 2015
38+
---------------------
39+
40+
* Fix broken ``packs.download`` action. (bug-fix)
2641

2742
v0.9.1 - May 12, 2015
2843
---------------------

contrib/core/actions/send_mail/send_mail

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ TO=$1
99
shift
1010
SUBJECT=$1
1111
shift
12+
SEND_EMPTY_BODY=$1
13+
shift
1214
BODY="$@"
1315

14-
${MAIL} <<EOF
16+
if [[ -z "${BODY// }" && $SEND_EMPTY_BODY == 'True' ]] || [[ -n $BODY ]]; then
17+
${MAIL} <<EOF
1518
TO: ${TO}
1619
FROM: ${FROM}
1720
SUBJECT: ${SUBJECT}
@@ -23,6 +26,8 @@ ${FOOTER}
2326
2427
EOF
2528

29+
fi
30+
2631
if [ $? -ne 0 ]; then
2732
echo "Failed to send mail to ${TO}"
2833
exit 2

contrib/core/actions/sendmail.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name: sendmail
66
parameters:
77
body:
88
description: Body of the email.
9-
position: 2
9+
position: 3
1010
required: true
1111
type: string
1212
subject:
@@ -21,4 +21,10 @@ parameters:
2121
position: 0
2222
required: true
2323
type: string
24+
send_empty_body:
25+
description: Send a message even if the body is empty.
26+
position: 2
27+
required: false
28+
type: boolean
29+
default: True
2430
runner_type: "local-shell-script"

contrib/examples/actions/chains/mistral_examples.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@
66
params:
77
cmd: "hostname"
88
on-success: "mistral-handle-error"
9-
on-failure: "mistral-handle-error"
109
-
1110
name: "mistral-handle-error"
1211
ref: "examples.mistral-handle-error"
1312
params: {}
14-
on-success: "mistral-handle-retry"
1513
on-failure: "mistral-handle-retry"
1614
-
1715
name: "mistral-handle-retry"
1816
ref: "examples.mistral-handle-retry"
1917
params: {}
2018
on-success: "mistral-repeat-with-items"
21-
on-failure: "mistral-repeat-with-items"
2219
-
2320
name: "mistral-repeat-with-items"
2421
ref: "examples.mistral-repeat-with-items"
@@ -27,36 +24,31 @@
2724
- "hostname"
2825
- "date"
2926
on-success: "mistral-repeat"
30-
on-failure: "mistral-repeat"
3127
-
3228
name: "mistral-repeat"
3329
ref: "examples.mistral-repeat"
3430
params:
3531
cmd: "hostname"
3632
on-success: "mistral-workbook-basic"
37-
on-failure: "mistral-workbook-basic"
3833
-
3934
name: "mistral-workbook-basic"
4035
ref: "examples.mistral-workbook-basic"
4136
params:
4237
cmd: "hostname"
4338
on-success: "mistral-workbook-complex"
44-
on-failure: "mistral-workbook-complex"
4539
-
4640
name: "mistral-workbook-complex"
4741
ref: "examples.mistral-workbook-complex"
4842
params:
4943
vm_name: "fake-host-1"
5044
on-success: "mistral-workbook-multiple-subflows"
51-
on-failure: "mistral-workbook-multiple-subflows"
5245
-
5346
name: "mistral-workbook-multiple-subflows"
5447
ref: "examples.mistral-workbook-multiple-subflows"
5548
params: {}
5649
on-success: "mistral-workbook-subflows"
57-
on-failure: "mistral-workbook-subflows"
5850
-
5951
name: "mistral-workbook-subflows"
6052
ref: "examples.mistral-workbook-subflows"
6153
params: {}
62-
default: "mistral-basic"
54+
default: "mistral-basic"

contrib/examples/actions/echochain.meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ parameters:
1515
default:
1616
- c2
1717
notify:
18-
on_complete:
18+
on-complete:
1919
message: "\"@channel: Action succeeded.\""
2020
channels:
2121
- "slack"

contrib/examples/actions/local.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ enabled: true
44
entry_point: ''
55
name: local-notify
66
notify:
7-
on_complete:
7+
on-complete:
88
channels:
99
- slack
1010
message: '"@channel: Action succeeded."'

contrib/examples/actions/mistral-basic-two-tasks-with-notifications.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ parameters:
2222
immutable: true
2323
type: string
2424
notify:
25-
on_complete:
25+
on-complete:
2626
message: "\"@channel: Action succeeded.\""
2727
channels:
2828
- "slack"

contrib/packs/actions/download.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
type: "string"
1212
repo_url:
1313
type: "string"
14-
default: "https://github.com/StackStorm/st2contrib.git"
14+
default: "StackStorm/st2contrib"
1515
branch:
1616
type: "string"
1717
default: "master"
1818
abs_repo_base:
1919
type: "string"
2020
default: "/opt/stackstorm/packs/"
2121
immutable: true
22+
subtree:
23+
type: "boolean"
24+
default: false
2225
verifyssl:
2326
type: "boolean"
2427
default: true

contrib/packs/actions/info.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: "info"
3+
runner_type: "python-script"
4+
description: "Get currently deployed pack information"
5+
enabled: true
6+
entry_point: "pack_mgmt/info.py"
7+
parameters:
8+
pack:
9+
type: "string"
10+
description: "Name of pack to introspect"
11+
required: true
12+

contrib/packs/actions/pack_mgmt/download.py

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import shutil
33
import hashlib
4+
import re
5+
import json
46

57
import six
68
from git.repo import Repo
@@ -11,20 +13,30 @@
1113
ALL_PACKS = '*'
1214
PACK_REPO_ROOT = 'packs'
1315
MANIFEST_FILE = 'pack.yaml'
16+
CONFIG_FILE = 'config.yaml'
17+
GITINFO_FILE = '.gitinfo'
1418
PACK_RESERVE_CHARACTER = '.'
1519

1620

1721
class InstallGitRepoAction(Action):
18-
def run(self, packs, repo_url, abs_repo_base, verifyssl=True, branch='master'):
19-
repo_name = repo_url[repo_url.rfind('/') + 1: repo_url.rfind('.')]
22+
def run(self, packs, repo_url, abs_repo_base, verifyssl=True, branch='master', subtree=False):
23+
self._subtree = self._eval_subtree(repo_url, subtree)
24+
self._repo_url = self._eval_repo_url(repo_url)
25+
26+
repo_name = self._repo_url[self._repo_url.rfind('/') + 1: self._repo_url.rfind('.')]
2027
lock_name = hashlib.md5(repo_name).hexdigest() + '.lock'
2128

2229
with LockFile('/tmp/%s' % (lock_name)):
23-
abs_local_path = self._clone_repo(repo_url=repo_url, verifyssl=verifyssl,
30+
abs_local_path = self._clone_repo(repo_url=self._repo_url, verifyssl=verifyssl,
2431
branch=branch)
2532
try:
26-
# st2-contrib repo has a top-level packs folder that actually contains the
27-
pack_abs_local_path = os.path.join(abs_local_path, PACK_REPO_ROOT)
33+
if self._subtree:
34+
# st2-contrib repo has a top-level packs folder that actually contains the
35+
pack_abs_local_path = os.path.join(abs_local_path, PACK_REPO_ROOT)
36+
else:
37+
pack_abs_local_path = abs_local_path
38+
39+
self._tag_pack(pack_abs_local_path, packs, self._subtree)
2840
result = self._move_packs(abs_repo_base, packs, pack_abs_local_path)
2941
finally:
3042
self._cleanup_repo(abs_local_path)
@@ -58,6 +70,10 @@ def _move_packs(self, abs_repo_base, packs, abs_local_path):
5870
if os.path.exists(dest_pack_path):
5971
self.logger.debug('Removing existing pack %s in %s to replace.', pack,
6072
dest_pack_path)
73+
# Ensure to preserve any existing configuration
74+
old_config_file = os.path.join(dest_pack_path, CONFIG_FILE)
75+
new_config_file = os.path.join(abs_pack_temp_location, CONFIG_FILE)
76+
shutil.move(old_config_file, new_config_file)
6177
shutil.rmtree(dest_pack_path)
6278
self.logger.debug('Moving pack from %s to %s.', abs_pack_temp_location, to)
6379
shutil.move(abs_pack_temp_location, to)
@@ -115,3 +131,38 @@ def _validate_result(result, packs, repo_url):
115131
raise Exception(message)
116132

117133
return sanitized_result
134+
135+
@staticmethod
136+
def _eval_subtree(repo_url, subtree):
137+
st2_repos = re.compile("st2(contrib|incubator)")
138+
match = True if st2_repos.search(repo_url) else False
139+
return subtree ^ match
140+
141+
@staticmethod
142+
def _eval_repo_url(repo_url):
143+
"""Allow passing short GitHub style URLs"""
144+
if len(repo_url.split('/')) == 2 and not "git@" in repo_url:
145+
return "https://github.com/{}.git".format(repo_url)
146+
else:
147+
return "{}.git".format(repo_url)
148+
149+
@staticmethod
150+
def _tag_pack(pack_dir, packs, subtree):
151+
"""Add git information to pack directory for retrieval later"""
152+
for pack in packs:
153+
repo = Repo(pack_dir)
154+
payload = {
155+
"branch": repo.active_branch.name,
156+
"ref": repo.head.commit.hexsha
157+
}
158+
159+
if subtree:
160+
info_file = os.path.join(pack_dir, pack, GITINFO_FILE)
161+
else:
162+
info_file = os.path.join(pack_dir, GITINFO_FILE)
163+
164+
try:
165+
gitinfo = open(info_file, "w")
166+
gitinfo.write(json.dumps(payload))
167+
finally:
168+
gitinfo.close()

0 commit comments

Comments
 (0)