trying to rework database migrations
This commit is contained in:
6
packs.dev/.gitignore
vendored
Normal file
6
packs.dev/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# Ignore all files in packs.dev except examples and documentation
|
||||
*
|
||||
!.gitignore
|
||||
!README.md
|
||||
!examples/
|
||||
!examples/**
|
||||
153
packs.dev/README.md
Normal file
153
packs.dev/README.md
Normal file
@@ -0,0 +1,153 @@
|
||||
# Development Packs Directory
|
||||
|
||||
This directory is for developing and testing custom packs outside of the core pack. Packs placed here are automatically available in Docker containers.
|
||||
|
||||
## Usage
|
||||
|
||||
### 1. Create a New Pack
|
||||
|
||||
```bash
|
||||
cd packs.dev
|
||||
mkdir my-pack
|
||||
cd my-pack
|
||||
```
|
||||
|
||||
### 2. Create pack.yaml
|
||||
|
||||
```yaml
|
||||
ref: my-pack
|
||||
label: "My Custom Pack"
|
||||
description: "My custom automation pack"
|
||||
version: "1.0.0"
|
||||
author: "Your Name"
|
||||
email: "you@example.com"
|
||||
|
||||
# Pack configuration
|
||||
system: false
|
||||
enabled: true
|
||||
```
|
||||
|
||||
### 3. Add Actions
|
||||
|
||||
```bash
|
||||
mkdir actions
|
||||
cat > actions/hello.yaml << 'YAML'
|
||||
name: hello
|
||||
ref: my-pack.hello
|
||||
description: "Say hello"
|
||||
runner_type: shell
|
||||
enabled: true
|
||||
entry_point: hello.sh
|
||||
parameters:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: "Name to greet"
|
||||
default: "World"
|
||||
required: []
|
||||
output:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: "Greeting message"
|
||||
YAML
|
||||
|
||||
cat > actions/hello.sh << 'BASH'
|
||||
#!/bin/bash
|
||||
echo "{\"message\": \"Hello, ${ATTUNE_ACTION_name}!\"}"
|
||||
BASH
|
||||
|
||||
chmod +x actions/hello.sh
|
||||
```
|
||||
|
||||
### 4. Access in Docker
|
||||
|
||||
The pack will be automatically available at `/opt/attune/packs.dev/my-pack` in all containers.
|
||||
|
||||
To load the pack into the database:
|
||||
|
||||
```bash
|
||||
# Via API
|
||||
curl -X POST http://localhost:8080/api/v1/packs \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"ref": "my-pack",
|
||||
"label": "My Custom Pack",
|
||||
"description": "My custom automation pack",
|
||||
"version": "1.0.0",
|
||||
"system": false,
|
||||
"enabled": true,
|
||||
"author": "Your Name",
|
||||
"email": "you@example.com"
|
||||
}'
|
||||
|
||||
# Or via CLI
|
||||
attune pack register /opt/attune/packs.dev/my-pack
|
||||
```
|
||||
|
||||
## Development Workflow
|
||||
|
||||
1. **Create pack structure** in `packs.dev/`
|
||||
2. **Edit files** on your host machine
|
||||
3. **Changes are immediately visible** in containers (bind mount)
|
||||
4. **Test** by creating rules/workflows that use your pack
|
||||
5. **Iterate** without rebuilding containers
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
packs.dev/
|
||||
├── README.md (this file)
|
||||
└── my-pack/
|
||||
├── pack.yaml
|
||||
├── actions/
|
||||
│ ├── my_action.yaml
|
||||
│ └── my_action.sh
|
||||
├── triggers/
|
||||
│ └── my_trigger.yaml
|
||||
├── sensors/
|
||||
│ └── my_sensor.yaml
|
||||
└── workflows/
|
||||
└── my_workflow.yaml
|
||||
```
|
||||
|
||||
## Important Notes
|
||||
|
||||
- This directory is for **development only**
|
||||
- Production packs should be properly packaged and installed
|
||||
- Files are mounted **read-write** so be careful with modifications from containers
|
||||
- The core pack is in `/opt/attune/packs` (read-only in containers)
|
||||
- Dev packs are in `/opt/attune/packs.dev` (read-write in containers)
|
||||
|
||||
## Example Packs
|
||||
|
||||
See the `examples/` subdirectory for starter pack templates:
|
||||
- `examples/basic-pack/` - Minimal pack with shell action
|
||||
- `examples/python-pack/` - Pack with Python actions
|
||||
- `examples/workflow-pack/` - Pack with workflows
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Pack not found
|
||||
- Ensure `pack.yaml` exists and is valid
|
||||
- Check pack ref matches directory name (recommended)
|
||||
- Verify pack is registered in database via API
|
||||
|
||||
### Actions not executing
|
||||
- Check `entry_point` matches actual file name
|
||||
- Ensure scripts are executable (`chmod +x`)
|
||||
- Check action runner_type matches script type
|
||||
- View worker logs: `docker logs attune-worker-shell`
|
||||
|
||||
### Permission errors
|
||||
- Ensure files are readable by container user (UID 1000)
|
||||
- Check file permissions: `ls -la packs.dev/my-pack/`
|
||||
|
||||
## See Also
|
||||
|
||||
- [Pack Structure Documentation](../docs/packs/pack-structure.md)
|
||||
- [Action Development Guide](../docs/actions/action-development.md)
|
||||
- [Workflow Development Guide](../docs/workflows/workflow-development.md)
|
||||
8
packs.dev/examples/basic-pack/actions/echo.sh
Executable file
8
packs.dev/examples/basic-pack/actions/echo.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Get parameter from environment
|
||||
MESSAGE="${ATTUNE_ACTION_message:-Hello from basic-pack!}"
|
||||
|
||||
# Output JSON result
|
||||
echo "{\"result\": \"$MESSAGE\"}"
|
||||
27
packs.dev/examples/basic-pack/actions/echo.yaml
Normal file
27
packs.dev/examples/basic-pack/actions/echo.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
name: echo
|
||||
ref: basic-pack.echo
|
||||
description: "Echo a message"
|
||||
runner_type: shell
|
||||
enabled: true
|
||||
entry_point: echo.sh
|
||||
|
||||
parameters:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: "Message to echo"
|
||||
default: "Hello from basic-pack!"
|
||||
required: []
|
||||
|
||||
output:
|
||||
type: object
|
||||
properties:
|
||||
result:
|
||||
type: string
|
||||
description: "The echoed message"
|
||||
|
||||
tags:
|
||||
- basic
|
||||
- shell
|
||||
- example
|
||||
14
packs.dev/examples/basic-pack/pack.yaml
Normal file
14
packs.dev/examples/basic-pack/pack.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
ref: basic-pack
|
||||
label: "Basic Example Pack"
|
||||
description: "A minimal example pack with a shell action"
|
||||
version: "1.0.0"
|
||||
author: "Attune Team"
|
||||
email: "dev@attune.io"
|
||||
|
||||
system: false
|
||||
enabled: true
|
||||
|
||||
tags:
|
||||
- example
|
||||
- basic
|
||||
- shell
|
||||
18
packs.dev/examples/python-pack/actions/hello.py
Executable file
18
packs.dev/examples/python-pack/actions/hello.py
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
|
||||
# Get parameters from environment
|
||||
name = os.environ.get('ATTUNE_ACTION_name', 'Python User')
|
||||
count = int(os.environ.get('ATTUNE_ACTION_count', '1'))
|
||||
|
||||
# Generate greetings
|
||||
greetings = [f"Hello, {name}! (greeting {i+1})" for i in range(count)]
|
||||
|
||||
# Output result as JSON
|
||||
result = {
|
||||
"greetings": greetings,
|
||||
"total_count": len(greetings)
|
||||
}
|
||||
|
||||
print(json.dumps(result))
|
||||
37
packs.dev/examples/python-pack/actions/hello.yaml
Normal file
37
packs.dev/examples/python-pack/actions/hello.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
name: hello
|
||||
ref: python-pack.hello
|
||||
description: "Python hello world action"
|
||||
runner_type: python
|
||||
enabled: true
|
||||
entry_point: hello.py
|
||||
|
||||
parameters:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: "Name to greet"
|
||||
default: "Python User"
|
||||
count:
|
||||
type: integer
|
||||
description: "Number of times to greet"
|
||||
default: 1
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
required: []
|
||||
|
||||
output:
|
||||
type: object
|
||||
properties:
|
||||
greetings:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: "List of greeting messages"
|
||||
total_count:
|
||||
type: integer
|
||||
description: "Total number of greetings"
|
||||
|
||||
tags:
|
||||
- python
|
||||
- example
|
||||
13
packs.dev/examples/python-pack/pack.yaml
Normal file
13
packs.dev/examples/python-pack/pack.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
ref: python-pack
|
||||
label: "Python Example Pack"
|
||||
description: "Example pack with Python actions"
|
||||
version: "1.0.0"
|
||||
author: "Attune Team"
|
||||
email: "dev@attune.io"
|
||||
|
||||
system: false
|
||||
enabled: true
|
||||
|
||||
tags:
|
||||
- example
|
||||
- python
|
||||
Reference in New Issue
Block a user