Open moooofly opened 6 years ago
create a global label by swagger UI
but you will find nothing in harbor UI
run it again, you will get
make the body content more reasonable, and try again
still get nothing
and
harborctl
[#454#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -h
This endpoint let user creates a label.
Usage:
harborctl label create [flags]
Flags:
-c, --color string The color code of this label. (e.g. Format: #A9B6BE)
--creation_time string The creation time of this label.
--deleted The label is deleted or not.
-d, --description string The description of this label.
-h, --help help for create
-i, --id int The ID of the label.
-n, --name string The name of this label.
-j, --project_id int The project ID if the label is a project label. ('0' indicates global label, others indicate specific project)
-s, --scope string The scope of this label. ('p' for project scope, 'g' for global scope)
--update_time string The update time of this label.
Global Flags:
--config string config file (default is $HOME/, working dir (.), and ./conf dir)
[#455#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#455#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create
==> POST https://localhost/api/labels
<==
<== Rsp Status: 400 Bad Request
<== Rsp Body: name cannot be empty
scope invalid:
[#456#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
From the response we know that parameters name
and scope
are required.
name
and scope
after updating the codes
[#460#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create
Error: required flag(s) "name", "scope" not set
Usage:
harborctl label create [flags]
Flags:
-c, --color string The color code of this label. (e.g. Format: #A9B6BE)
--creation_time string The creation time of this label.
--deleted The label is deleted or not.
-d, --description string The description of this label.
-h, --help help for create
-i, --id int The ID of the label.
-n, --name string (REQUIRED) The name of this label.
-j, --project_id int The project ID if the label is a project label. ('0' indicates global label, others indicate specific project)
-s, --scope string (REQUIRED) The scope of this label. ('p' for project scope, 'g' for global scope)
--update_time string The update time of this label.
Global Flags:
--config string config file (default is $HOME/, working dir (.), and ./conf dir)
required flag(s) "name", "scope" not set
[#461#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#461#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#461#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#461#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n label-1 -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 500 Internal Server Error
<== Rsp Body:
[#462#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
it will trigger "500 | Internal Server Error", and you can get the same result from swagger UI
[#461#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n label-1 -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 500 Internal Server Error
<== Rsp Body:
[#462#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#462#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#462#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#462#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n "label-1" -s "g"
==> POST https://localhost/api/labels
<==
<== Rsp Status: 500 Internal Server Error
<== Rsp Body:
[#463#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n "label" -s "g"
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#464#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#464#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n label_one -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#465#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n label_1 -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#466#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#466#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n label_@ -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#467#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#468#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n "label_@#$%^&*()" -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#469#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
from harbor UI you will see
[#481#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n string -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 500 Internal Server Error
<== Rsp Body:
[#483#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n string1 -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#484#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n string1 -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 409 Conflict
<== Rsp Body:
[#485#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n int -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#486#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n bool -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#487#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n integer -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#488#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#488#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n func -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#489#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n interface -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#490#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n string -s g
==> POST https://localhost/api/labels
<==
<== Rsp Status: 500 Internal Server Error
<== Rsp Body:
[#491#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
harborctl
, show success[#544#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -h
This endpoint let user creates a label.
Usage:
harborctl label create [flags]
Flags:
-c, --color string The color code of this label. (e.g. Format: #A9B6BE)
--creation_time string The creation time of this label.
--deleted The label is deleted or not.
-d, --description string The description of this label.
-h, --help help for create
-i, --id int The ID of the label.
-n, --name string (REQUIRED) The name of this label.
-j, --project_id int The project ID if the label is a project label. ('0' indicates global label, others indicate specific project)
-s, --scope string (REQUIRED) The scope of this label. ('p' for project scope, 'g' for global scope)
--update_time string The update time of this label.
Global Flags:
--config string config file (default is $HOME/, working dir (.), and ./conf dir)
[#545#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#545#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n fly -s g -d "the color of fly" -c "#F52F52" -j 0 -i 2000 --deleted
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#546#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#546#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n fly -s g -d "the color of fly" -c "#F52F52" -j 0 -i 2000 --deleted
==> POST https://localhost/api/labels
<==
<== Rsp Status: 500 Internal Server Error
<== Rsp Body:
[#547#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#547#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label get -i 2000
==> GET https://localhost/api/labels/2000
<==
<== Rsp Status: 404 Not Found
<== Rsp Body: label 2000 not found
[#548#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
another one
[#548#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n flyAgain -s g -d "the color of flyAgain" -c "#F52F52" -j 0 -i 3000 --deleted
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#549#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#549#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label get -i 3000
==> GET https://localhost/api/labels/3000
<==
<== Rsp Status: 404 Not Found
<== Rsp Body: label 3000 not found
[#550#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
This issue must be related with --deleted
parameter which means "Mark the label is deleted or not."
If you call this API with --deleted
, you actually create a label that has been marked "Deleted", and you can get it by any means.
This behavior will cause a obscure problem:
--deleted
and succeed.--deleted
this time).Here is the question: What is the role of --deleted
in fact?
[#554#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -h
This endpoint let user creates a label.
Usage:
harborctl label create [flags]
Flags:
-c, --color string The color code of this label. (e.g. Format: #A9B6BE)
--creation_time string The creation time of this label.
--deleted The label is deleted or not.
-d, --description string The description of this label.
-h, --help help for create
-i, --id int The ID of the label.
-n, --name string (REQUIRED) The name of this label.
-j, --project_id int The project ID if the label is a project label. ('0' indicates global label, others indicate specific project)
-s, --scope string (REQUIRED) The scope of this label. ('p' for project scope, 'g' for global scope)
--update_time string The update time of this label.
Global Flags:
--config string config file (default is $HOME/, working dir (.), and ./conf dir)
[#555#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#555#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#555#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n flyAgainAgain -s g -d "the color of flyAgainAgain" -c "#F52F52" -j 0 -i 5000
==> POST https://localhost/api/labels
<==
<== Rsp Status: 201 Created
<== Rsp Body:
[#556#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#556#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label get -i 5000
==> GET https://localhost/api/labels/5000
<==
<== Rsp Status: 200 OK
<== Rsp Body: {
"id": 5000,
"name": "flyAgainAgain",
"description": "the color of flyAgainAgain",
"color": "#F52F52",
"scope": "g",
"project_id": 0,
"creation_time": "2018-11-06T09:59:19.097633Z",
"update_time": "2018-11-06T09:59:19.097633Z",
"deleted": false
}
[#557#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#557#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label create -n flyAgainAgain -s g -d "the color of flyAgainAgain" -c "#F52F52" -j 0 -i 5000
==> POST https://localhost/api/labels
<==
<== Rsp Status: 409 Conflict
<== Rsp Body:
[#558#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
you can get it from harbor UI
[#559#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label delete -i 5000
==> DELETE https://localhost/api/labels/5000
<==
<== Rsp Status: 200 OK
<== Rsp Body:
[#560#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#560#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl label get -i 5000
==> GET https://localhost/api/labels/5000
<==
<== Rsp Status: 404 Not Found
<== Rsp Body: label 5000 not found
[#561#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
by swagger file
This API has the same issue as #7 , #20 and #21