cli icon indicating copy to clipboard operation
cli copied to clipboard

There should be a programmatic way to get the current space guid

Open giner opened this issue 6 years ago • 6 comments

What's the user value of this feature request? Improve scripting capabilities of cf curl ...

Who is the functionality for? CF users and CI / CD builders

How often will this functionality be used by the user? It is going to be used in scripts and CI/CDs. It is hard to say how often.

Who else is affected by the change? Not a breaking change

Is your feature request related to a problem? Please describe. There is no reliable scriptable way of checking if an application exists in the current space unless:

  • we know guid of the current space (GET /v3/apps?names=APPNAME&space_guids=SPACE_GUID) OR
  • we know guid of the application itself OR
  • cf app appname produces a parsable response so that there is no need to check for unreliable App 'APPNAME' not found

Describe the solution you'd like cf target or cf space should have an option to get guid of the current space

Describe alternatives you've considered Another option would be to parse ~/.cf/config.json though I'm not sure if this file has a stable format and supposed to be read by users. I'd expect this not to be the case.

giner avatar Jul 18 '19 05:07 giner

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/167365054

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar Jul 18 '19 05:07 cf-gitbot

Hi @giner thanks for creating this issue. Could you help me understand why the current --guid flag on space is not sufficient:

USAGE:
   cf space SPACE [--guid] [--security-group-rules]

Thanks for clarifying.

abbyachau avatar Aug 01 '19 23:08 abbyachau

cf space ... requires to know the space name.

giner avatar Aug 01 '19 23:08 giner

@giner may I suggest as a workaround:

cf space $(cf target | awk '/space:/ { print $2 }') --guid

ericpromislow avatar Sep 05 '19 22:09 ericpromislow

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed.

github-actions[bot] avatar Sep 27 '24 17:09 github-actions[bot]

@giner may I suggest as a workaround:

cf space $(cf target | awk '/space:/ { print $2 }') --guid

What's more stable and consistent, the cf target output or the ~/.cf/config.json structure? I guess both are not considered official "API".

Btw. it would help if cf target would have a flag to output JSON (see also https://github.com/cloudfoundry/cli/issues/604).

alxsap avatar Nov 21 '24 08:11 alxsap