apigee / apigeecli

This is a tool to interact with Apigee APIs. The tool lets you manage (create, del, get, list) environments, proxies, etc.
Apache License 2.0
54 stars 31 forks source link

feat: adds wait option to multiple cmds #518 #519

Closed srinandan closed 3 months ago

kurtkanaskie commented 3 months ago

Attaching an env to an instance waits but displays incorrect messages

gorun --org=$ORG instances attachments attach --name=us-east1 --env=test --wait
{
    "name": "organizations/apigeex-mint-kurt/operations/09f307e8-93fb-4e81-9b2b-e64e6cd12c2e",
    "metadata": {
        "@type": "type.googleapis.com/google.cloud.apigee.v1.OperationMetadata",
        "operationType": "INSERT",
        "targetResourceName": "organizations/apigeex-mint-kurt/instances/us-east1/attachments/93a3e83c-ea04-4106-a23c-4c2ff9bc77e2",
        "state": "IN_PROGRESS"
    }
}

Checking creation status in 10 seconds
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment status is: %!s(<nil>). Waiting 10 seconds.
Instance attachment completed
kurtkanaskie commented 3 months ago

instances delete and other APIs that return an LRO should include --wait

Error condition waits 10 seconds even on immediate result

gorun instances create --org=$ORG --location=us-east1 --name=us-east1 --wait
{
  "error": {
    "code": 409,
    "message": "instance \"organizations/apigeex-custom/instances/us-east1\" already exists",
    "status": "ALREADY_EXISTS",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.RequestInfo",
        "requestId": "2905311160183436725"
      }
    ]
  }
}

Checking creation status in 10 seconds
Instance creation failed with status:  CREATING
srinandan commented 3 months ago

This addresses the bug when an instance already exists or otherwise fails.

This PR doesn't contain wait for deletion.

kurtkanaskie commented 3 months ago

LGTM