Skip to content

Commit d108fe9

Browse files
authored
Merge pull request #1 from StackStorm-Exchange/transfer
Transfer from StackStorm-Exchange/incubator
2 parents 7a7b809 + 72e25cf commit d108fe9

34 files changed

Lines changed: 1268 additions & 0 deletions

.gitmodules

Whitespace-only changes.

.scripts/prepare-repo.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
PACK_DIRECTORY=$(find . -maxdepth 1 -type d -not -path '*/\.*' -not -path '\.' | head -1 | sed -e 's/^\.\///')
4+
5+
if [[ -z "${PACK_DIRECTORY}" ]]; then
6+
echo "Unable to find pack directory"
7+
exit 1
8+
fi
9+
10+
echo "Found pack directory: ${PACK_DIRECTORY}"
11+
12+
PACK_NAME=$(cat ${PACK_DIRECTORY}/pack.yaml | grep "name:" | sed -e 's/^name:[ \t]*//')
13+
14+
if [[ -z "${PACK_NAME}" ]]; then
15+
echo "Unable to retrieve pack name from ${PACK_DIRECTORY}/pack.yaml"
16+
exit 1
17+
fi
18+
19+
echo "Found pack name: ${PACK_NAME}"
20+
21+
22+
# Copy pack files in root dir so the checks work
23+
echo "Exporting PACK_NAME and removing pack directory"
24+
25+
cp -r ${PACK_DIRECTORY}/* .
26+
rm -rf ${PACK_DIRECTORY}
27+
28+
ls -la .
29+
30+
echo "export PACK_NAME=$PACK_NAME" >> ~/.circlerc
31+
echo "export FORCE_CHECK_ALL_FILES=true" >> ~/.circlerc

.yo-rc.json

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"generator-st2pack": {
3+
"promptValues": {
4+
"features": [
5+
"Sensors",
6+
"Rules",
7+
"Policies",
8+
"Aliases"
9+
],
10+
"pack_ref": "nexus3",
11+
"pack_name": "Sontatype Nexus3",
12+
"pack_desc": "Sontatype nexus3 stackstorm pack"
13+
},
14+
"actions": {},
15+
"aliases": {
16+
"greet": {
17+
"name": "greet",
18+
"pack": "nexus3",
19+
"description": "Greet StackStorm",
20+
"action_ref": "nexus3.greet",
21+
"formats": [
22+
"greet {{greeting}}"
23+
]
24+
}
25+
},
26+
"rules": {
27+
"on_hello_event1": {
28+
"name": "on_hello_event1",
29+
"pack": "nexus3",
30+
"description": "Sample rule firing on nexus3.event1.",
31+
"enabled": true,
32+
"trigger": {
33+
"type": "nexus3.event1"
34+
},
35+
"action": {
36+
"ref": "nexus3.greet",
37+
"parameters": {
38+
"greeting": "Yo"
39+
}
40+
}
41+
}
42+
},
43+
"sensors": {
44+
"HelloSensor": {
45+
"class_name": "HelloSensor",
46+
"entry_point": "sensor1.py",
47+
"description": "Test sensor that emits triggers.",
48+
"trigger_types": [
49+
{
50+
"name": "event1",
51+
"description": "An example trigger.",
52+
"payload_schema": {
53+
"type": "object"
54+
}
55+
}
56+
]
57+
}
58+
},
59+
"policies": {
60+
"http.retry": {
61+
"name": "http.retry",
62+
"description": "Retry core.http action on timeout.",
63+
"enabled": true,
64+
"resource_ref": "core.http",
65+
"policy_type": "action.retry",
66+
"parameters": {
67+
"retry_on": "timeout",
68+
"max_retry_count": 2,
69+
"delay": 2
70+
}
71+
},
72+
"greet.concurrency": {
73+
"name": "greet.concurrency",
74+
"pack": "nexus3",
75+
"description": "Limits the concurrent executions of the greet action.",
76+
"enabled": true,
77+
"resource_ref": "nexus3.greet",
78+
"policy_type": "action.concurrency",
79+
"parameters": {
80+
"threshold": 10
81+
}
82+
}
83+
},
84+
"pack": {
85+
"ref": "nexus3",
86+
"name": "Sontatype Nexus3",
87+
"description": "Sontatype nexus3 stackstorm pack"
88+
}
89+
}
90+
}

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Stackstorm-Nexus3
2+
3+
[Sontatype nexus3](https://www.sonatype.com/nexus-repository-oss) stackstorm pack
4+
5+
## Installation
6+
7+
Install this pack with: `st2 pack install file://$PWD`
8+
9+
Or if in remote repository: `st2 pack install https://github.com/MY/PACK`
10+
11+
## Configuration
12+
13+
Copy the example configuration in [nexus3.yaml.example](./nexus3.yaml.example)
14+
to `/opt/stackstorm/configs/nexus3.yaml` and edit as required.
15+
16+
add nexus3 server connection profile:
17+
18+
* ``url`` - URL of the nexus3 server (e.g. ``http://localhost:8081``)
19+
* ``user`` - username
20+
* ``password`` - Password
21+
* ``verify`` - https tls verify, only used if the `url` option specifies an `https` connection
22+
23+
You can also add multiple profiles:
24+
25+
When you add multiple profile, above parameters becomes defaults for any key missing in the profile.
26+
27+
``` yaml
28+
---
29+
url: "http://localhost:8081"
30+
user: "admin"
31+
password: "admin123"
32+
verify: True
33+
default_profile: "dev" # use this to make for missing config_profile parameter when calling any action
34+
profiles:
35+
"dev":
36+
url: "http://localhost:8081"
37+
user: "dev-user"
38+
password: "mypas"
39+
verify: True
40+
"dev-2":
41+
user: "dev2-user"
42+
password: "mypass2"
43+
# url : fallback to url: "http://localhost:8081"
44+
# verify: fallback to verify: True
45+
```
46+
47+
**Note** : When modifying the configuration in `/opt/stackstorm/configs/` please
48+
remember to tell StackStorm to load these new values by running
49+
`st2ctl reload --register-configs`
50+
51+
## Actions
52+
53+
While naming actions following convention is used:
54+
55+
< VERB >_< RESOURCE(plural) >
56+
eg.
57+
list_repositories
58+
get_scripts
59+
60+
Supported Resources
61+
62+
* Repositories
63+
* Scripts
64+
65+
### Available actions
66+
67+
* **list_repositories** : List nexus3 repositories
68+
* **get_repositories** : get nexus3 repositories
69+
* **create_repositories** : create nexus3 repository
70+
* **delete_repositories** : delete nexus3 repository
71+
72+
* **list_scripts** : List nexus3 scripts
73+
* **get_scripts** : get nexus3 scripts
74+
* **create_scripts** : create(& upload) if missing, groovy script
75+
* **delete_scripts** : delete nexus3 script
76+
77+
## Policies
78+
79+
* **http.retry** : Retry core.http action on timeout.
80+
81+
## Aliases
82+
83+
--NIL--
84+
85+
## Rules
86+
87+
--NIL--
88+
89+
## Sensors
90+
91+
--NIL--
92+
93+
## Testing
94+
95+
While testing you can leverage [Makefile](./tests/Makefile) to ease writing and testing actions. Read the Makefile for the list of useful commands.
96+
97+
## Contributing
98+
99+
Before submitting make sure python linter is happy with your changes first
100+
101+
``` bash
102+
pip install flake8
103+
104+
#executing flake8 ./
105+
make -f tests/Makefile lint
106+
```

actions/create_repositories.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
name: create_repositories
3+
runner_type: python-script
4+
description: Create a repository
5+
enabled: true
6+
entry_point: run.py
7+
parameters:
8+
action:
9+
default: create_repositories
10+
immutable: true
11+
type: string
12+
config_profile:
13+
type: string
14+
description: Select which nexus config profile to use.
15+
required: false
16+
name:
17+
type: string
18+
description: A unique identifier for this repository
19+
required: true
20+
format:
21+
type: string
22+
description: The format of the repository (i.e. maven2, docker, raw, nuget...)
23+
required: true
24+
enum:
25+
- bower
26+
- docker
27+
- gitlfs
28+
- maven
29+
- npm
30+
- nuget
31+
- pypi
32+
- raw
33+
- rubygems
34+
- yum
35+
type:
36+
type: string
37+
description: The type of repository (i.e. group, hosted, or proxy)
38+
required: true
39+
enum:
40+
- hosted
41+
- proxy
42+
version_policy:
43+
type: string
44+
description: What type of artifacts does this repository store?
45+
required: false
46+
default: RELEASE
47+
enum:
48+
- RELEASE
49+
- SNAPSHOT
50+
- MIXED
51+
layout_policy:
52+
type: string
53+
description: Validate that all paths are maven artifact or metadata paths
54+
required: false
55+
default: STRICT
56+
enum:
57+
- STRICT
58+
- PERMISSIVE
59+
blob_store_name:
60+
type: string
61+
description: Blob store used to store asset contents
62+
required: true
63+
default: "default"
64+
strict_content_type_validation:
65+
type: boolean
66+
description: Validate that all content uploaded to this repository is of a MIME type appropriate for the repository format
67+
required: true
68+
default: false
69+
write_policy:
70+
type: string
71+
description: Controls if deployments of and updates to artifacts are allowed
72+
required: true
73+
default: ALLOW
74+
enum:
75+
- ALLOW_ONCE
76+
- ALLOW
77+
- DENY

actions/create_scripts.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: create_scripts
3+
runner_type: python-script
4+
description: create a script
5+
enabled: true
6+
entry_point: run.py
7+
parameters:
8+
action:
9+
default: create_scripts
10+
immutable: true
11+
type: string
12+
config_profile:
13+
type: string
14+
description: Select which nexus config profile to use.
15+
required: false
16+
data:
17+
type: object
18+
description: instance of script to be created.
19+
required: false

actions/delete_repositories.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: delete_repositories
3+
runner_type: python-script
4+
description: delete all repositories of nexus3
5+
enabled: true
6+
entry_point: run.py
7+
parameters:
8+
action:
9+
default: delete_repositories
10+
immutable: true
11+
type: string
12+
config_profile:
13+
type: string
14+
description: Select which nexus config profile to use.
15+
required: false
16+
name:
17+
type: string
18+
description: A unique identifier of the repository to delete
19+
required: true

actions/delete_scripts.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: delete_scripts
3+
runner_type: python-script
4+
description: delete a script
5+
enabled: true
6+
entry_point: run.py
7+
parameters:
8+
action:
9+
default: delete_scripts
10+
immutable: true
11+
type: string
12+
config_profile:
13+
type: string
14+
description: Select which nexus config profile to use.
15+
required: false
16+
name:
17+
type: string
18+
description: name of script to be deleted
19+
required: true

actions/get_repositories.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: get_repositories
3+
runner_type: python-script
4+
description: get repository identified by a unique identifier
5+
enabled: true
6+
entry_point: run.py
7+
parameters:
8+
action:
9+
default: get_repositories
10+
immutable: true
11+
type: string
12+
config_profile:
13+
type: string
14+
description: Select which nexus config profile to use.
15+
required: false
16+
name:
17+
type: string
18+
description: A unique identifier of the repository to fetch
19+
required: true

0 commit comments

Comments
 (0)