Version Control

Tích hợp Git để backup, versioning, và rollback cấu hình — device, rule chain, dashboard, asset dưới dạng code

Version Control

Version Control tích hợp Git trực tiếp vào VieLang IoT, cho phép lưu cấu hình dưới dạng code. Mọi thay đổi có thể commit, review, và rollback như code thông thường.

Entities được quản lý

✓ Devices ✓ Device Profiles ✓ Assets ✓ Asset Profiles ✓ Rule Chains ✓ Dashboards ✓ Entity Views ✓ Customers ✓ Widgets ✓ Widget Bundles ✓ Queues ✓ Scheduler Jobs

Cấu hình Git Repository

Advanced Features > Version Control:

Repository URI: https://github.com/company/iot-config.git Branch: main Auth type: Username/Password hoặc SSH Private Key Username: git-username Password/Token: ghp_xxxxxxxxxxxx (GitHub Personal Access Token)

SSH:

Repository URI: git@github.com:company/iot-config.git Private Key: [PEM private key] Password: (nếu key có passphrase)

Auto-Commit

Bật tự động commit khi có thay đổi:

Enable auto-commit: ✓ Auto-commit message: Auto-save by ${userFirstName} ${userLastName} [${date}]

Mỗi lần lưu entity → tự động commit lên Git với message đã cấu hình.


Export Entity (Manual Commit)

Một entity

Device > Actions > Export to Git Rule Chain > Save & Export

Hộp thoại:

Branch: main Commit message: Update rule chain: Add temperature alert

Nhiều entities

Advanced Features > Version Control > Export:

Entity types: [Device Profile, Rule Chain, Dashboard] Customer: (tùy chọn) Branch: release/v2.0 Commit: Release v2.0 configuration

Cấu trúc Repository

. ├── device/ │ ├── Temperature-Sensor-01.json │ └── Energy-Meter-02.json ├── deviceProfile/ │ └── Smart-Meter-Profile.json ├── ruleChain/ │ ├── Root-Rule-Chain.json │ └── Energy-Processing.json ├── dashboard/ │ └── Energy-Dashboard.json └── entityView/ └── Customer-A-View.json

Xem Version History

Device > Version History (hoặc bất kỳ entity nào):

v5 2024-01-15 09:30 john@company.com "Update threshold to 85°C" v4 2024-01-14 14:20 admin@company.com "Add humidity sensor" v3 2024-01-13 10:05 john@company.com "Fix rule chain connection" v2 2024-01-12 16:00 admin@company.com "Initial configuration" v1 2024-01-10 09:00 admin@company.com "Auto-save by Admin [10/01/2024]"

Rollback về phiên bản cũ

Version History > [chọn version] > Restore

Xác nhận → Entity được khôi phục về state cũ. Hành động này không thể hoàn tác (nhưng state hiện tại trước rollback cũng đã được commit).


Restore từ Git (Disaster Recovery)

Khi cần khôi phục toàn bộ cấu hình từ Git:

Advanced Features > Version Control > Restore:

Branch: main Commit: HEAD (mới nhất) hoặc commit hash cụ thể

Chọn entity types cần restore và xác nhận.


Workflow khuyến nghị

Cho môi trường Development

dev branch ← thay đổi hàng ngày ↓ (test xong) main branch ← stable configuration

Cho Production

hotfix/xxx ← sửa khẩn cấp feature/xxx ← tính năng mới ↓ (review + test) staging ← kiểm tra trước khi lên production ↓ (approve) main ← production configuration

Ví dụ use cases

Backup cấu hình trước khi nâng cấp:

# Trước khi upgrade platform Export all entities → Git commit "Pre-upgrade backup v3.1.0" # Nếu upgrade lỗi → Restore từ commit này

Rollout cấu hình rule chain mới:

1. Sửa rule chain trên dev environment 2. Export → branch feature/new-alert-rules 3. Tạo Pull Request để review 4. Merge → main 5. Import vào production

Audit thay đổi cấu hình:

git log --all --oneline # Xem lịch sử git diff v5 v4 ruleChain/Root-Rule-Chain.json # Xem thay đổi cụ thể