harborctl
harborctl copied to clipboard
[NOTE] API "POST /policies/replication" not work as expect
by swagger file
- create a policy
the content of policyinfo
used
{
"name": "sync-fifth",
"description": "fifth",
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"replicate_existing_image_now": true,
"replicate_deletion": false,
"filters": [],
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": true,
"current_user_role_id": 1,
"repo_count": 1,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
]
}
- get it back
but can not find it in Harbor UI (NOTE: this is my mistake, you can find them by "Next Page" button)
by harborctl
for test purpose, I have called "POST /policies/replication" API several times from swagger UI.
You will find multiple policies with almost same values except for the value of "id
" (label ID).
[#935#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl policy replication list -n sync-fifth -j 6
==> GET https://localhost/api/policies/replication?name=sync-fifth&project_id=6&page=1&page_size=10
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
{
"id": 8,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:48:33Z",
"update_time": "2018-11-08T05:48:33Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 9,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:48:39Z",
"update_time": "2018-11-08T05:48:39Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 10,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:49:05Z",
"update_time": "2018-11-08T05:49:05Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 11,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:49:23Z",
"update_time": "2018-11-08T05:49:23Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 12,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:49:23Z",
"update_time": "2018-11-08T05:49:23Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 13,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:49:26Z",
"update_time": "2018-11-08T05:49:26Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 14,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:50:52Z",
"update_time": "2018-11-08T05:50:52Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 15,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:50:53Z",
"update_time": "2018-11-08T05:50:53Z",
"replicate_existing_image_now": false,
"error_job_count": 1
},
{
"id": 16,
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T05:54:43Z",
"update_time": "2018-11-08T05:54:43Z",
"replicate_existing_image_now": false,
"error_job_count": 1
}
]
[#936#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
have a try with the content below (setting "id")
{
"id": 100, // -- set this in order to specify the label ID
"name": "sync-fifth",
"description": "fifth",
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"replicate_existing_image_now": true,
"replicate_deletion": false,
"filters": [],
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": true,
"current_user_role_id": 1,
"repo_count": 1,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
]
}
and you will get
...
{
"id": 17, // not 100, but 17
"name": "sync-fifth",
"description": "fifth",
"filters": null,
"replicate_deletion": false,
"trigger": {
"kind": "Scheduled",
"schedule_param": {
"type": "Weekly",
"weekday": 1,
"offtime": 0
}
},
"projects": [
{
"project_id": 6,
"owner_id": 1,
"name": "temp_5",
"creation_time": "2018-11-02T06:58:11Z",
"update_time": "2018-11-02T06:58:11Z",
"deleted": false,
"owner_name": "",
"togglable": false,
"current_user_role_id": 0,
"repo_count": 0,
"metadata": {
"public": "true"
}
}
],
"targets": [
{
"id": 1,
"endpoint": "http://11.11.11.22",
"name": "fake endpoint",
"username": "admin",
"password": "",
"type": 0,
"insecure": true,
"creation_time": "2018-11-07T14:42:31.876842Z",
"update_time": "2018-11-07T14:42:31.876842Z"
}
],
"creation_time": "2018-11-08T06:05:49Z",
"update_time": "2018-11-08T06:05:49Z",
"replicate_existing_image_now": false,
"error_job_count": 1
}
]
The result shows that it has no way to set label ID manually, and the value of label ID is generated by Harbor service one by one.
So, "409 | Policy name already used or policy already exists with the same project and target." will never be triggered.