ionos-cloud / ionosctl

The IONOS Cloud CLI (ionosctl) gives the ability to manage IONOS Cloud infrastructure directly from Command Line.
Apache License 2.0
30 stars 6 forks source link

label list cannot filter #194

Closed wmendes-ionos closed 2 years ago

wmendes-ionos commented 2 years ago

Description

It seems ionosctl label list cannot properly interpret flags. For some values it even reacts upon, but the resultset is always the same.

Expected behavior

ionosctl label list interpret and apply flags such as --datacenter-id, --resource-type, --server-id etc.

Environment

dev, prod.

Go Version:

go version go1.19 darwin/arm64

Ionosctl version:

IONOS Cloud CLI version: DEV
SDK GO version: 6.1.0
SDK GO DBaaS Postgres version: v1.0.3
SDK GO Auth version: 1.0.4

OS:

darwin/arm64

Shell:

zsh

How to Reproduce

With a dev account try to list labels. for a datacenter. ionosctl label list --datacenter-id ad6eb12c-c20a-4f83-876f-c3a8a9e1fbec try with a server ionosctl label list --datacenter-id ad6eb12c-c20a-4f83-876f-c3a8a9e1fbec --server-id 03fea0d9-0fde-4351-a3e1-9eea2cfa3a38 note the result is always the same. try filter by a resource type ionosctl label list --resource-type lan ionosctl label list --resource-type Volume I still can see other resource-types in the result set. when I use volume --resource-type volume it gives me a 404.

me@~$ io label list --resource-type volume
Error: 404 Not Found {
  "httpStatus" : 404,
  "messages" : [ {
    "errorCode" : "309",
    "message" : "Resource does not exist"
  } ]
}

when I use Volume, I still see other resource-types.

avirtopeanu-ionos commented 2 years ago

Hello!

Thanks for creating this issue! After doing a bit of investigating, I've broken down this issue into these specific/measureable tasks/bugs:

  1. ionosctl label list in conjunction with a valid type* for --resource-type flag requires certain IDs provided. For example, for server, you need to provide server-id and datacenter-id, but these parameters are not marked as required.

  2. Only some resources have valid endpoints* in the labels API. Until the next major release, the flag --resource-type should be responsible for the above set of resources, while for other resources (i.e. nic, lan, k8s nodepools) the users should use -F/--filter for the resourceType column instead of using this flag.

    The default behaivour for unknown --resource-type values is just to do a simple list, as if no value was provided, hence why sometimes this command provides the same result-set at times as you describe with Volume and lan

  3. Filter flag doesn't work for any column

  4. We should reach a common decision as a team on what to do with this duplicate functionality. Depending on limitations and performance, perhaps next major release --resource-type flag could be deprecated, and merged into -F/--filters flag if it provides a performance increase over simple key/value filtering over the resourceType column

* As of now, valid types are datacenter,server,volume,ipblock,snapshot.

Thanks again, for opening this issue! As soon as a PR is ready I'll make sure to link it to this issue.