Skip to content

pkgctl search command

Jelle van der Waa requested to merge pkg-search into master

We'd like to be able to search our packaging repos easily from CLI, since pkgctl is bash this is kinda hard as we need to do pagination

  • Figure out how to efficiently resolve the project_id, only seems to be possible to do with this api and then selecting id_before / id_after based on the returned results otherwise we'll have to do an O(n) lookup
  • Figure out the default output format
  • Figure out how to do pagination, Gitlab does not return the pagination via json but you have to specify per_page=X and then look at the returned headers: x-total-pages: 17 and x-next-page: 2 and x-page: 1. This can be done with curl --dump-headers /tmp/headers and then parsing this in bash.... and figuring out how to merge the output arrays for --raw possibly like:
[jelle@natrium][~/projects/devtools]%cat example.json
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: example.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [{
   2   │     "error": 1,
   3   │     "message": 1
   4   │ }]
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[jelle@natrium][~/projects/devtools]%cat example2.json
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: example2.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [{
   2   │     "error": 4,
   3   │     "message": 5
   4   │ }]
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[jelle@natrium][~/projects/devtools]%cat  example.json example2.json| jq -s 'add'
[
  {
    "error": 1,
    "message": 1
  },
  {
    "error": 4,
    "message": 5
  }
]

Open To DO's

  • -r (--raw mode) don't emit anything else over stderr which breaks jq
  • Querying projects in group archlinux/packaging/packages... is super slow
Edited by Levente Polyak

Merge request reports