Skip to content

Commit 5206960

Browse files
Aneri ThakkarAneri Thakkar
authored andcommitted
Merge branch 'stable' into at.rbac
2 parents cf86a85 + 06290b1 commit 5206960

67 files changed

Lines changed: 6905 additions & 372 deletions

Some content is hidden

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

.github/workflows/docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,3 @@ jobs:
4949
with:
5050
branch: gh-pages
5151
folder: site
52-
53-
# Made with Bob

.secrets.baseline

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-12-25T19:13:06Z",
6+
"generated_at": "2026-01-14T11:35:47Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -143,6 +143,16 @@
143143
"verified_result": null
144144
}
145145
],
146+
"test/src/test_backup.py": [
147+
{
148+
"hashed_secret": "4dfd3a58b4820476afe7efa2e2c52b267eec876a",
149+
"is_secret": false,
150+
"is_verified": false,
151+
"line_number": 753,
152+
"type": "Secret Keyword",
153+
"verified_result": null
154+
}
155+
],
146156
"test/src/test_db2.py": [
147157
{
148158
"hashed_secret": "a4b48a81cdab1e1a5dd37907d6c85ca1c61ddc7c",

AGENT_INSTRUCTIONS.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# python-devops AI Coding Instructions
2+
3+
## Project Overview
4+
Python package for IBM Maximo DevOps utilities. Provides command-line tools for deployment automation, database validation, Slack notifications, and user management. Distributed as installable package with `setup.py`/`pyproject.toml` and standalone scripts in `bin/`.
5+
6+
## Architecture
7+
- **bin/**: Executable CLI scripts (entry points)
8+
- `mas-devops-*`: Command-line tools for specific operations
9+
- Scripts import from `src/` package for implementation
10+
- Each script typically wraps a single operational task
11+
- **src/**: Main package source code
12+
- Organized by module/function (import path: `from mas_devops import ...`)
13+
- Core utilities: configuration management, API clients, database handlers
14+
- **test/**: Test suite (pytest structure)
15+
- Mirror `src/` structure in test files
16+
- Run with `pytest` or `make test`
17+
- **build/**: Generated artifacts (don't edit)
18+
- `*.egg-info/`: Package metadata
19+
- `dist/`, `*.whl`: Distribution packages
20+
- **setup.py** / **pyproject.toml**: Package definition
21+
- Entry points defined in setup.py pointing to `bin/` scripts
22+
- Dependencies in both files (must keep in sync)
23+
- Version defined once (check both files)
24+
25+
## Key Patterns
26+
- **CLI Tool Pattern**: `bin/mas-devops-*` scripts are thin wrappers
27+
- Import main logic from `src/mas_devops/`
28+
- Handle argument parsing and error reporting
29+
- Example: `mas-devops-notify-slack` → calls slack notification module
30+
- **Dependency Management**:
31+
- Core dependencies in `setup.py` `install_requires`
32+
- Dev dependencies in `setup.py` `extras_require['dev']`
33+
- `requirements.txt` for pinned versions (reproducible installs)
34+
- Keep all three in sync
35+
- **Entry Points**: `setup.py` defines CLI commands
36+
- Format: `'mas-devops-task-name = mas_devops.module:main_function'`
37+
- Creates executable scripts in `bin/` when package installed
38+
- **Module Organization**: Import directly from package
39+
- `from mas_devops.db2_validator import validate_config`
40+
- Avoid deep nesting; keep public API clear
41+
42+
## Development Workflow
43+
```bash
44+
make install # Install package in dev mode (pip install -e .)
45+
make test # Run pytest suite
46+
make test-verbose # Pytest with verbose output
47+
make build # Build distribution (wheel/tarball)
48+
make clean # Remove build artifacts
49+
make all # Clean, test, build
50+
```
51+
52+
## Important Conventions
53+
- **Python Version**: Check `setup.py` for `python_requires` (e.g., `>=3.8`)
54+
- **Entry Points**: Adding new CLI tool requires editing `setup.py` entry_points section
55+
- **Error Handling**: CLI scripts should catch exceptions and exit with meaningful error messages
56+
- **Logging**: Use Python logging module; configure in main module
57+
- **Testing**: Test structure mirrors source; test file for `src/module.py` is `test/test_module.py`
58+
- **Documentation**: Docstrings in functions should describe parameters, return, exceptions
59+
- **Imports**: Use absolute imports from package (`from mas_devops import ...`), not relative
60+
61+
## Common CLI Tools (Reference)
62+
- `mas-devops-create-initial-users-for-saas`: User provisioning (SaaS)
63+
- `mas-devops-db2-validate-config`: Validate DB2 configuration
64+
- `mas-devops-notify-slack`: Send notifications
65+
- `mas-devops-saas-job-cleaner`: Cleanup SaaS jobs
66+
67+
## Integration Points
68+
- **ansible-devops**: Playbooks call these Python utilities for infrastructure setup
69+
- **playbook**: Runbooks document procedures; Python tools automate them
70+
- **Standalone Usage**: Scripts can be called independently or from other tools via entry points
71+
- **Distribution**: Package installed via pip; entry points register CLI commands globally
72+
73+
## When Adding New CLI Tool
74+
1. Create implementation module in `src/mas_devops/`
75+
2. Create script in `bin/mas-devops-tool-name` or update `setup.py` entry_points
76+
3. Add entry to `setup.py` entry_points section
77+
4. Add tests in `test/` matching module structure
78+
5. Update `requirements.txt` if adding dependencies
79+
6. Test with `make install` then run `mas-devops-tool-name --help`
80+
81+
## Packaging & Distribution
82+
- Build: `python -m build` or `make build`
83+
- Outputs: wheel file in `dist/` ready for pip install
84+
- Version managed in `setup.py` (check both setup.py and pyproject.toml)

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include src/mas/devops/templates/*.json.j2
22
include src/mas/devops/templates/*.yml.j2
33
include src/mas/devops/data/catalogs/*.yaml
4+
include src/mas/devops/data/*.yaml

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,4 @@ mas-devops-create-initial-users-for-saas \
8888
Example of initial_users secret:
8989
```json
9090
{"john.smith1@example.com":"primary,john1,smith1","john.smith2@example.com":"primary,john2,smith2","john.smith3@example.com":"secondary,john3,smith3"}
91-
```
92-
91+
```

bin/mas-devops-create-initial-users-for-saas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if __name__ == "__main__":
3434
parser.add_argument("--coreapi-port", required=False, default=443)
3535
parser.add_argument("--admin-dashboard-port", required=False, default=443)
3636
parser.add_argument("--manage-api-port", required=False, default=443)
37+
parser.add_argument("--mas-version", required=False, default="9.0")
3738

3839
group = parser.add_mutually_exclusive_group(required=True)
3940
group.add_argument("--initial-users-yaml-file")
@@ -56,6 +57,7 @@ if __name__ == "__main__":
5657

5758
mas_instance_id = args.mas_instance_id
5859
mas_workspace_id = args.mas_workspace_id
60+
mas_version = args.mas_version
5961
initial_users_yaml_file = args.initial_users_yaml_file
6062
initial_users_secret_name = args.initial_users_secret_name
6163
coreapi_port = args.coreapi_port
@@ -66,6 +68,7 @@ if __name__ == "__main__":
6668
logger.info("--------------")
6769
logger.info(f"mas_instance_id: {mas_instance_id}")
6870
logger.info(f"mas_workspace_id: {mas_workspace_id}")
71+
logger.info(f"mas_version: {mas_version}")
6972
logger.info(f"initial_users_yaml_file: {initial_users_yaml_file}")
7073
logger.info(f"initial_users_secret_name: {initial_users_secret_name}")
7174
logger.info(f"log_level: {log_level}")
@@ -83,7 +86,7 @@ if __name__ == "__main__":
8386
config.load_kube_config()
8487
logger.debug("Loaded kubeconfig file")
8588

86-
user_utils = MASUserUtils(mas_instance_id, mas_workspace_id, client.api_client.ApiClient(), coreapi_port=coreapi_port, admin_dashboard_port=admin_dashboard_port, manage_api_port=manage_api_port)
89+
user_utils = MASUserUtils(mas_instance_id, mas_workspace_id, client.api_client.ApiClient(), mas_version, coreapi_port=coreapi_port, admin_dashboard_port=admin_dashboard_port, manage_api_port=manage_api_port)
8790

8891
if initial_users_secret_name is not None:
8992

mkdocs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,3 @@ extra:
112112
social:
113113
- icon: fontawesome/brands/github
114114
link: https://github.com/ibm-mas/python-devops
115-
116-
# Made with Bob

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def get_version(rel_path):
6464
'semver', # BSD License
6565
'boto3', # Apache Software License
6666
'slack_sdk', # MIT License
67+
"packaging", # Apache Software License
6768
],
6869
extras_require={
6970
'dev': [

0 commit comments

Comments
 (0)