Add comprehensive README.md documentation
- Project overview and features - Installation and usage instructions for all scripts - Excel file format requirements - Security warnings and best practices - Technical details and API compatibility - Project structure overview 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e3401ec380
commit
9779a488f3
117
README.md
Normal file
117
README.md
Normal file
@ -0,0 +1,117 @@
|
||||
# Harbor 批量管理工具
|
||||
|
||||
Harbor容器镜像仓库的批量用户和项目管理工具集合。
|
||||
|
||||
## 功能概述
|
||||
|
||||
- **用户批量注册** - 从Excel文件批量创建Harbor用户
|
||||
- **用户批量删除** - 删除用户及其所有关联资源(项目、仓库)
|
||||
- **项目批量删除** - 专门删除学生项目(stu01~stu49)
|
||||
|
||||
## 安装依赖
|
||||
|
||||
```bash
|
||||
# 激活虚拟环境(如果有)
|
||||
source venv/bin/activate
|
||||
|
||||
# 安装依赖
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## 使用说明
|
||||
|
||||
### 1. 用户批量注册 (`register.py`)
|
||||
|
||||
从Excel文件批量创建Harbor用户。
|
||||
|
||||
```bash
|
||||
python register.py
|
||||
```
|
||||
|
||||
**Excel文件格式要求(`users.xlsx`):**
|
||||
- 第1行:标题行(会被跳过)
|
||||
- 第1列:用户名 (username)
|
||||
- 第2列:真实姓名 (realname)
|
||||
- 第3列:密码 (password)
|
||||
- 第5列:邮箱地址 (email)
|
||||
|
||||
### 2. 用户批量删除 (`delete_users.py`)
|
||||
|
||||
删除Excel文件中列出的用户及其所有资源。
|
||||
|
||||
```bash
|
||||
python delete_users.py
|
||||
```
|
||||
|
||||
**删除顺序:**
|
||||
1. 删除用户拥有的所有仓库
|
||||
2. 删除用户拥有的所有项目
|
||||
3. 删除用户账户
|
||||
|
||||
### 3. 学生项目删除 (`delete_projects.py`)
|
||||
|
||||
专门删除以stu01~stu49开头的项目和仓库。
|
||||
|
||||
```bash
|
||||
python delete_projects.py
|
||||
```
|
||||
|
||||
**功能特点:**
|
||||
- 精确匹配stu01到stu49开头的项目
|
||||
- 支持预览模式(查看但不删除)
|
||||
- 安全确认机制(需输入'DELETE'确认)
|
||||
|
||||
## 配置说明
|
||||
|
||||
### Harbor服务器配置
|
||||
默认配置在各脚本中:
|
||||
```python
|
||||
HARBOR_URL = "https://harbor.seahi.me"
|
||||
API_BASE = f"{HARBOR_URL}/api/v2.0"
|
||||
```
|
||||
|
||||
### 认证方式
|
||||
所有脚本使用HTTP Basic认证,运行时会提示输入Harbor管理员账号密码。
|
||||
|
||||
## 安全提醒
|
||||
|
||||
⚠️ **重要安全提醒**
|
||||
- 所有删除操作都是**不可逆**的
|
||||
- 删除用户会同时删除其所有项目和仓库
|
||||
- 建议在生产环境使用前先在测试环境验证
|
||||
- Excel文件可能包含敏感信息,已被git忽略
|
||||
|
||||
## 技术细节
|
||||
|
||||
- **分页支持**:自动处理Harbor API分页,确保获取所有数据
|
||||
- **错误处理**:完善的异常处理和用户反馈
|
||||
- **资源依赖**:正确处理Harbor资源删除顺序
|
||||
- **SSL警告**:已禁用不安全HTTPS连接警告
|
||||
|
||||
## API兼容性
|
||||
|
||||
基于Harbor API v2.0开发,支持的主要端点:
|
||||
- `GET /users` - 获取用户列表
|
||||
- `POST /users` - 创建用户
|
||||
- `DELETE /users/{user_id}` - 删除用户
|
||||
- `GET /projects` - 获取项目列表
|
||||
- `DELETE /projects/{project_name}` - 删除项目
|
||||
- `GET /projects/{project_name}/repositories` - 获取仓库列表
|
||||
- `DELETE /projects/{project_name}/repositories/{repository_name}` - 删除仓库
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
├── README.md # 项目说明文档
|
||||
├── CLAUDE.md # Claude Code工作指南
|
||||
├── requirements.txt # Python依赖
|
||||
├── register.py # 用户批量注册
|
||||
├── delete_users.py # 用户批量删除
|
||||
├── delete_projects.py # 学生项目删除
|
||||
├── users.xlsx # Excel数据文件(被git忽略)
|
||||
└── venv/ # Python虚拟环境(被git忽略)
|
||||
```
|
||||
|
||||
## 许可证
|
||||
|
||||
此项目仅供内部使用。
|
Loading…
x
Reference in New Issue
Block a user