upbound / up

The @upbound CLI
Apache License 2.0
52 stars 41 forks source link

Require configurations for creating control planes #298

Closed jastang closed 1 year ago

jastang commented 1 year ago

Description of your changes

Control plane creation now has a mandatory flag configuration-name referencing the root Configuration to deploy into the managed control plane.

We also add support for configuration delete, which has a standard hook to force confirmation of the delete operation. In lieu of the API returning a 400 when the configuration is still in use (i.e. deployed) by one or more control planes, we also show the user the control planes in the current account that have the configuration deployed.

I have:

How has this code been tested

➜  bin ./up cfg list
NAME         TEMPLATE ID                 PROVIDER   REPO        BRANCH   CREATED AT                      SYNCED AT                           
eks-api      upbound/configuration-eks   github     eks-api     main     2023-02-22 14:03:30 +0000 UTC   2023-02-22 14:03:35.034903 +0000 UTC
not-in-use   upbound/configuration-rds   github     test-repo   main     2023-03-06 19:16:31 +0000 UTC   2023-03-06 19:16:38.476371 +0000 UTC
➜  bin ./up cfg delete eks-api
up: error: this configuration is still in use by control plane(s): [jason-mcp sdk-test cli-two]
➜  bin ./up cfg delete not-in-use 
Are you sure you want to delete this configuration? [y/n]: n
up: error: operation canceled
➜  bin ./up cfg delete not-in-use
Are you sure you want to delete this configuration? [y/n]: y
Deleting configuration not-in-use. This cannot be undone,
not-in-use deleted
➜  bin ./up cfg list
NAME      TEMPLATE ID                 PROVIDER   REPO      BRANCH   CREATED AT                      SYNCED AT                           
eks-api   upbound/configuration-eks   github     eks-api   main     2023-02-22 14:03:30 +0000 UTC   2023-02-22 14:03:35.034903 +0000 UTC
➜  bin ./up ctp create no-config-not-allowed
up: error: missing flags: --configuration-id=STRING

➜  bin ./up ctp create cli-test --configuration-id=26f3ffb8-3cf7-413e-9e5f-9e93175bdcfe
cli-test created

➜  bin ./up ctp list
NAME        ID                                     STATUS
jason-mcp   ae7bac57-84d9-4a18-b965-564c81620a48   ready 
sdk-test    8b9865f9-5a69-4202-b17b-4e1ac8b3cfa4   ready 
cli-test    459fbe47-7d69-4967-9dcb-c314c7d03620   ready