Install
openclaw skills install @erickeyhu-hug/huawei-cloud-swr-image-automationHuawei Cloud SWR (Software Repository for Container) image automation and operations skill using hcloud CLI. Use this skill when the user wants to: (1) configure cross-region image sync (auto or manual), (2) manage SWR triggers for auto-deploy to CCE/CCI, (3) query available sync target regions, (4) check sync job status, (5) create/update/delete trigger configurations. Trigger: user mentions "SWR automation", "SWR 自动化", "镜像同步", "SWR sync", "跨区域同步", "cross-region sync", "触发器", "SWR trigger", "自动部署", "auto deploy", "镜像复制", "image replication", "SWR 触发器"
openclaw skills install @erickeyhu-hug/huawei-cloud-swr-image-automationThis skill provides image automation capabilities for Huawei Cloud SWR (Software Repository for Container) using the hcloud CLI, including cross-region image sync and trigger-based auto-deployment.
Architecture: hcloud CLI → SWR Service API → SyncRepo/Trigger/SyncJob/SyncRegion resources
Related Skills:
huawei-cloud-swr-image-management - Image lifecycle management (namespaces, repos, tags, auth, quotas). Image push and authentication (CreateAuthorizationToken, docker login, docker push) are required to verify triggers end-to-end. If not installed, install it first:
npx skills add huaweicloud/huaweicloud-skills --skill huawei-cloud-swr-image-management -y
For the complete image push and authentication flow, refer to the official SWR Quick Start guide: https://support.huaweicloud.com/qs-swr/index.html
huawei-cloud-swr-image-governance - Image governance (permissions, retention, sharing, tags, immutable rules)
huawei-cloud-swr-enterprise-instance - Enterprise instance management
Configure auto-sync to replicate images across regions on push
Manually sync specific image tags to target regions
List available sync target regions
Check sync job execution status
Create and manage triggers for auto-deploy to CCE/CCI workloads
Enable/disable triggers and update trigger configurations
Typical Use Cases:
All write operations (Create, Update, Delete) require explicit user confirmation before execution.
Before executing any write operation, the skill must:
Write operations requiring confirmation:
| Operation | Command | Risk Level | Description |
|---|---|---|---|
| Create auto-sync config | CreateImageSyncRepo | 🟠 High | Creates cross-region image replication. If override=true, overwrites existing images in target region — existing images are unrecoverable. Warn user before proceeding |
| Delete auto-sync config | DeleteImageSyncRepo | 🟡 Medium | Removes auto-sync configuration. New pushes will no longer auto-replicate to target region. Already-synced images are preserved |
| Manual sync tags | CreateManualImageSyncRepo | 🟡 Medium | One-time sync of specific tags. If override=true, overwrites existing images in target region |
| Create trigger | CreateTrigger | 🟡 Medium | Sets up auto-deploy to CCE/CCI. New image pushes will automatically update the target workload — verify trigger condition to avoid unintended deployments |
| Update trigger | UpdateTrigger | 🟡 Medium | Modifies trigger configuration. Enabling/disabling changes auto-deploy behavior immediately |
| Delete trigger | DeleteTrigger | 🟡 Medium | Removes auto-deploy trigger. Target workload will no longer auto-update on new image pushes |
hcloud version to verify installationprintf "y\n" | hcloud version to accept privacy statementhcloud CLI supports two credential modes via environment variables, automatically detected at runtime:
Mode A — Long-term AK/SK (permanent access):
export HUAWEI_CLOUD_AK=<your-ak>
export HUAWEI_CLOUD_SK=<your-sk>
export HUAWEI_CLOUD_REGION=cn-north-4
Mode B — Temporary AK/SK + SecurityToken (recommended for temporary or delegated access):
export HUAWEI_CLOUD_AK=<your-temp-ak>
export HUAWEI_CLOUD_SK=<your-temp-sk>
export HUAWEI_CLOUD_SECURITY_TOKEN=<your-security-token>
export HUAWEI_CLOUD_REGION=cn-north-4
When
HUAWEI_CLOUD_SECURITY_TOKENis present, hcloud CLI automatically uses temporary credential authentication. When only AK/SK are set, it uses long-term credential authentication.
echo $HUAWEI_CLOUD_AK or echo $HUAWEI_CLOUD_SK to check credentialsHUAWEI_CLOUD_AK, HUAWEI_CLOUD_SK, HUAWEI_CLOUD_REGION, HUAWEI_CLOUD_SECURITY_TOKEN⚠️ Important Security Notes:
| API Action | Permission | Purpose |
|---|---|---|
swr:sync:create | Create sync repo | Configure cross-region image sync |
swr:sync:delete | Delete sync repo | Remove sync configuration |
swr:sync:list | List sync repos | Query auto-sync configurations |
swr:syncmanual:create | Manual sync | Trigger manual image sync |
swr:syncregion:list | List sync regions | Query available sync target regions |
swr:syncjob:get | Get sync job status | Check sync execution status |
swr:trigger:create | Create trigger | Set up auto-deploy trigger |
swr:trigger:list | List triggers | Query trigger configurations |
swr:trigger:get | Get trigger | View specific trigger details |
swr:trigger:update | Update trigger | Modify trigger configuration |
swr:trigger:delete | Delete trigger | Remove trigger configuration |
See IAM Permission Policies for complete policy JSON.
Permission Failure Handling:
references/iam-policies.mdListSyncRegions to retrieve available cross-region sync targetsCreateImageSyncRepo (auto-sync) or CreateManualImageSyncRepo (one-time manual sync)CreateTrigger / UpdateTrigger / DeleteTrigger to configure auto-deploy to CCE/CCIListImageAutoSyncReposDetails / ShowTrigger / ListSyncJobsDetails to check sync and trigger statusDeleteImageSyncRepo to stop sync, DeleteTrigger to remove triggerAll commands follow the standard hcloud KooCLI format:
hcloud SWR <Operation> --param1=value1 --param2=value2 --cli-region=<region>
Key conventions:
SWR (uppercase, matches KooCLI Services listing)CreateImageSyncRepo, ListSyncRegions, CreateTrigger)--cli-region=<value> (default: cn-north-4, or HUAWEI_CLOUD_REGION env var)--cli-output=json (for agent processing)--cli-query="<expression>" (to reduce output)--imageTag.1=v1 --imageTag.2=v2 (index starts from 1, not 0)Example — read operation:
hcloud SWR ListSyncRegions --cli-region=cn-north-4 --cli-output=json
Example — write operation (requires user confirmation):
# Step 1: Display command and parameters for user confirmation
# Step 2: After user confirms, execute:
hcloud SWR CreateImageSyncRepo --namespace=pancake --repository=openclaw-sandbox \
--remoteRegionId=cn-east-3 --remoteNamespace=pancake --syncAuto=true --override=false \
--cli-region=cn-north-4
See Task: Image Sync for detailed workflows.
# List available sync target regions
hcloud SWR ListSyncRegions --cli-region=cn-north-4
# Configure auto-sync for a repository to target region
hcloud SWR CreateImageSyncRepo --namespace=group-dev --repository=my-app --remoteRegionId=cn-east-3 --remoteNamespace=group-dev --override=false --syncAuto=true --cli-region=cn-north-4
# List auto-sync configurations for a repository
hcloud SWR ListImageAutoSyncReposDetails --namespace=group-dev --repository=my-app --cli-region=cn-north-4
# Delete auto-sync configuration
hcloud SWR DeleteImageSyncRepo --namespace=group-dev --repository=my-app --remoteRegionId=cn-east-3 --remoteNamespace=group-dev --cli-region=cn-north-4
Auto Sync Behavior: When syncAuto=true, every new image push to the source repository automatically triggers a sync to the target region. When syncAuto=false, sync only occurs on manual trigger.
# Manually sync specific image tags to target region
hcloud SWR CreateManualImageSyncRepo --namespace=group-dev --repository=my-app --remoteRegionId=cn-east-3 --remoteNamespace=group-dev --imageTag.1=v1.0 --imageTag.2=v2.0 --override=false --cli-region=cn-north-4
⚠️ Important: --imageTag uses indexed array format, NOT plain value format:
--imageTag.1=v1.0 --imageTag.2=v2.0--imageTag=v1.0 (missing index)--imageTag=v1.0,v2.0 (comma-separated not supported)# List all regions available as sync targets
hcloud SWR ListSyncRegions --cli-region=cn-north-4
Response Format (verified against actual API):
[
{
"regionID": "cn-north-4"
}
Returns all regions where you can sync images. Use the regionID field value as the --remoteRegionId parameter.
# Check sync job status (--filter is REQUIRED with limit and offset)
hcloud SWR ShowSyncJob --namespace=group-dev --repository=my-app --filter="limit::10|offset::0" --cli-region=cn-north-4
⚠️ Important: --filter is required and must include both limit::N and offset::N (e.g., "limit::10|offset::0"). Without it, the command returns a missing parameter error.
Response format (verified against actual API): Returns a flat JSON array. Returns [] when no sync jobs exist.
See Task: Trigger Management for detailed workflows.
# Create a trigger for auto-deploy to CCE
hcloud SWR CreateTrigger --namespace=group-dev --repository=my-app --name=deploy-trigger --trigger_type=all --condition=".*" --action=update --app_type=deployments --application=my-deployment --cluster_ns=default --enable=true --trigger_mode=cce --cluster_id=<cluster-id> --cluster_name=<cluster-name> --cli-region=cn-north-4
# List all triggers for a repository
hcloud SWR ListTriggersDetails --namespace=group-dev --repository=my-app --cli-region=cn-north-4
# Show trigger details
hcloud SWR ShowTrigger --namespace=group-dev --repository=my-app --trigger=deploy-trigger --cli-region=cn-north-4
# Update a trigger (enable/disable or modify configuration)
hcloud SWR UpdateTrigger --namespace=group-dev --repository=my-app --trigger=deploy-trigger --enable=false --cli-region=cn-north-4
# Delete a trigger
hcloud SWR DeleteTrigger --namespace=group-dev --repository=my-app --trigger=deploy-trigger --cli-region=cn-north-4
Trigger Types:
all: Trigger on any image push (condition=".*")tag: Trigger on specific tag push (condition=tag-name)regular: Trigger on tag matching regex (condition=regex-pattern)Trigger Modes:
cce: Deploy to CCE (Cloud Container Engine) cluster — requires --cluster_idcci: Deploy to CCI (Cloud Container Instance) — no cluster ID needed| Parameter | Required/Optional | Description | Default |
|---|---|---|---|
--cli-region | Required | Huawei Cloud region ID | Config value or HUAWEI_CLOUD_REGION |
--namespace | Context-dependent | SWR namespace (organization) | N/A |
--repository | Context-dependent | Image repository name | N/A |
| Parameter | Required | Description | Constraints |
|---|---|---|---|
--namespace | Yes | Source namespace | Existing namespace name |
--repository | Yes | Source repository | Existing repository name |
--remoteRegionId | Yes | Target region ID | Must be from ListSyncRegions result |
--remoteNamespace | Yes | Target namespace | Namespace name in target region |
--override | No | Overwrite existing images | true or false (default false) |
--syncAuto | No | Auto sync on push | true or false (default false) |
| Parameter | Required | Description | Constraints |
|---|---|---|---|
--namespace | Yes | Source namespace | Existing namespace name |
--repository | Yes | Source repository | Existing repository name |
--remoteRegionId | Yes | Target region ID | Must be from ListSyncRegions result |
--remoteNamespace | Yes | Target namespace | Namespace name in target region |
--imageTag.[N] | Yes | Tag list (indexed array) | --imageTag.1=v1.0 --imageTag.2=v2.0 |
--override | No | Overwrite existing images | true or false (default false) |
| Parameter | Required | Description | Constraints |
|---|---|---|---|
--namespace | Yes | SWR namespace | Existing namespace name |
--repository | Yes | Image repository | Existing repository name |
--name | Yes | Trigger name | Unique within repository |
--trigger_type | Yes | Trigger type | all, tag, regular |
--condition | Yes | Match condition | .* for all, tag name for tag, regex for regular |
--action | Yes | Trigger action | update |
--app_type | Yes | Application type | deployments or statefulsets |
--application | Yes | CCE/CCI application name | Existing deployment name |
--cluster_ns | Yes | Application namespace | Kubernetes namespace (e.g., default) |
--enable | Yes | Enable trigger | true or false |
--trigger_mode | No | Deploy target | cce (default) or cci |
--cluster_id | CCE only | CCE cluster ID | Required for cce mode, empty for cci |
--cluster_name | No | CCE cluster name | Optional cluster name |
--container | No | Target container | Specific container name (default: all) |
Response is a flat JSON array of region objects:
[
{
"regionID": "cn-north-4",
"region_name": "north-1"
}
]
Note: Returns all available sync target regions. Use region_id as --remoteRegionId.
Response format to be verified — returns list of sync repo configurations when they exist. Returns empty when no auto sync configured.
Response format to be verified — returns list of trigger objects when they exist. Returns empty when no triggers configured.
Response format to be verified. Use --namespace, --repository, --trigger (trigger name) as parameters.
Response is a flat JSON array. Returns [] when no sync jobs exist:
[]
Note: Requires --filter="limit::N|offset::N" parameter. See Sync Job Status for usage.
See Verification Method for step-by-step verification.
| Region Name | Region ID |
|---|---|
| North China - Beijing 4 | cn-north-4 |
| North China - Beijing 1 | cn-north-1 |
| East China - Shanghai 1 | cn-east-3 |
| East China - Shanghai 2 | cn-east-2 |
| South China - Guangzhou | cn-south-1 |
| South China - Shenzhen | cn-south-4 |
| Southwest China - Guiyang 1 | cn-southwest-2 |
| Asia Pacific - Bangkok | ap-southeast-2 |
| Asia Pacific - Singapore | ap-southeast-1 |
| Asia Pacific - Hong Kong | ap-southeast-3 |
| Europe - Paris | eu-west-0 |
syncAuto=true for production repositories to ensure images are automatically replicated to target regionsCreateManualImageSyncRepo when you only need to sync specific tags (e.g., production releases)override=true when you intentionally want to overwrite existing images in the target regionprod-deploy-trigger, staging-update-trigger)trigger_type=regular with regex for flexible matching (e.g., v\d+\.\d+\.\d+ for semver tags)enable=false) before deleting to avoid unintended deployments during cleanupListSyncRegions before creating sync configurations to verify the target region is available| Document | Description |
|---|---|
| SWR Automation API Guide | hcloud SWR automation API reference |
| IAM Permission Policies | Required permissions and policy JSON |
| Verification Method | Step-by-step verification |
| Common Pitfalls | Troubleshooting guides |
| Task: Image Sync | Auto/manual sync workflows |
| Task: Trigger Management | Trigger workflows |
| CLI Installation Guide | KooCLI setup and credential config |
| Acceptance Criteria | Correct/error pattern comparison |
CreateManualImageSyncRepo invocation syncs specified tags once--imageTag.[N] uses indexed array format — NOT plain value or comma-separatedhcloud SWR <Operation> formatSee Common Pitfalls & Solutions for detailed troubleshooting guides.
Quick Reference:
| Pitfall | Symptom | Quick Fix |
|---|---|---|
--imageTag wrong format | Manual sync fails | Use indexed: --imageTag.1=v1.0 |
| Target namespace missing | Sync creation fails | Create namespace in target region first |
| Invalid remoteRegionId | Sync creation fails | Check with ListSyncRegions |
| CCE cluster not found | Trigger creation fails | Verify cluster_id with CCE console |
| Trigger already exists | 409 Conflict | Use ShowTrigger to check first |
| Auto-sync unwanted | Images sync unexpectedly | Set syncAuto=false or delete sync config |