moooofly / harborctl

A CLI tool for the Docker Registry Harbor. This project offer a command-line interface to the Harbor API, you can use it to manager your users, projects, repositories, etc. (This project aims to refactor harbor-go-client based on Harbor v1.6.0)
MIT License
28 stars 6 forks source link

[NOTE] The format of "begin_timestamp" and "end_timestamp" within API "GET /projects/{project_id}/logs" is unknown #2

Open moooofly opened 6 years ago

moooofly commented 6 years ago

HELP

[#1069#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -h
This endpoint let user search access logs filtered by operations and date time ranges.

Usage:
  harborctl project log [flags]

Flags:
  -b, --beginTimestamp string   The begin timestamp (format is unknown).
  -e, --endTimestamp string     The end timestamp (format is unknown).
  -h, --help                    help for log
  -o, --operation string        The operation.
  -p, --page int                The page nubmer, default is 1. (default 1)
  -s, --page_size int           The size of per page, default is 10, maximum is 100. (default 10)
  -j, --project_id int          (REQUIRED) Relevant project ID.
  -r, --repository string       The name of repository.
  -t, --tag string              The name of tag.
  -n, --username string         Username of the operator.

Global Flags:
      --config string   config file (default is $HOME/, working dir (.), and ./conf dir)
[#1070#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$

TEST

[#1070#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=&end_timestamp=&page=1&page_size=10
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "log_id": 245,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:42.137786Z"
  },
  {
    "log_id": 244,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:41.991681Z"
  },
  {
    "log_id": 243,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:41.850003Z"
  },
  {
    "log_id": 242,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:41.668839Z"
  },
  {
    "log_id": 241,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:41.506809Z"
  },
  {
    "log_id": 240,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:41.269879Z"
  },
  {
    "log_id": 239,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:40.973655Z"
  },
  {
    "log_id": 238,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:40.816387Z"
  },
  {
    "log_id": 237,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:40.639359Z"
  },
  {
    "log_id": 236,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v3",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:40.385278Z"
  }
]
[#1071#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#1071#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -s 3
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=&end_timestamp=&page=1&page_size=3
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "log_id": 245,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:42.137786Z"
  },
  {
    "log_id": 244,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:41.991681Z"
  },
  {
    "log_id": 243,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:41.850003Z"
  }
]
[#1072#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#1072#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -o push
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=push&begin_timestamp=&end_timestamp=&page=1&page_size=10
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "log_id": 240,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:41.269879Z"
  },
  {
    "log_id": 237,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:40.639359Z"
  },
  {
    "log_id": 227,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v3",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:38.836888Z"
  },
  {
    "log_id": 225,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v2",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:38.386891Z"
  },
  {
    "log_id": 224,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v1",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:38.083195Z"
  }
]
[#1073#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#1073#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -t v4
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=v4&operation=&begin_timestamp=&end_timestamp=&page=1&page_size=10
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "log_id": 239,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:40.973655Z"
  },
  {
    "log_id": 238,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:40.816387Z"
  },
  {
    "log_id": 237,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v4",
    "guid": "",
    "operation": "push",
    "op_time": "2018-11-02T06:58:40.639359Z"
  }
]
[#1074#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#1074#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -r temp_10/hello-world -s 1
==> GET https://localhost/api/projects/11/logs?username=&repository=temp_10/hello-world&tag=&operation=&begin_timestamp=&end_timestamp=&page=1&page_size=1
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "log_id": 245,
    "username": "admin",
    "project_id": 11,
    "repo_name": "temp_10/hello-world",
    "repo_tag": "v5",
    "guid": "",
    "operation": "pull",
    "op_time": "2018-11-02T06:58:42.137786Z"
  }
]
[#1075#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#1075#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -r temp_10/hello-world-again -s 1
==> GET https://localhost/api/projects/11/logs?username=&repository=temp_10/hello-world-again&tag=&operation=&begin_timestamp=&end_timestamp=&page=1&page_size=1
<==
<== Rsp Status: 200 OK
<== Rsp Body: []
[#1076#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$

TIMESTAMP issue

[#1076#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -b "2018-11-01T06:58:40.639359Z" -e "2018-11-03T06:58:40.639359Z"
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=2018-11-01T06:58:40.639359Z&end_timestamp=2018-11-03T06:58:40.639359Z&page=1&page_size=10
<==
<== Rsp Status: 400 Bad Request
<== Rsp Body: invalid begin_timestamp: 2018-11-01T06:58:40.639359Z

[#1077#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
[#1077#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -b "2018-11-01T06:58:40" -e "2018-11-03T06:58:40.639359Z"
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=2018-11-01T06:58:40&end_timestamp=2018-11-03T06:58:40.639359Z&page=1&page_size=10
<==
<== Rsp Status: 400 Bad Request
<== Rsp Body: invalid begin_timestamp: 2018-11-01T06:58:40

[#1078#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -b "2018-11-01T" -e "2018-11-03T06:58:40.639359Z"
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=2018-11-01T&end_timestamp=2018-11-03T06:58:40.639359Z&page=1&page_size=10
<==
<== Rsp Status: 400 Bad Request
<== Rsp Body: invalid begin_timestamp: 2018-11-01T

[#1079#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -b "2018-11-01" -e "2018-11-03T06:58:40.639359Z"
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=2018-11-01&end_timestamp=2018-11-03T06:58:40.639359Z&page=1&page_size=10
<==
<== Rsp Status: 400 Bad Request
<== Rsp Body: invalid begin_timestamp: 2018-11-01

[#1080#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -b "20181101" -e "2018-11-03T06:58:40.639359Z"
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=20181101&end_timestamp=2018-11-03T06:58:40.639359Z&page=1&page_size=10
<==
<== Rsp Status: 400 Bad Request
<== Rsp Body: invalid end_timestamp: 2018-11-03T06:58:40.639359Z

[#1081#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl project log -j 11 -b "20181101" -e "20181103"
==> GET https://localhost/api/projects/11/logs?username=&repository=&tag=&operation=&begin_timestamp=20181101&end_timestamp=20181103&page=1&page_size=10
<==
<== Rsp Status: 200 OK
<== Rsp Body: []
[#1082#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$