adamrodger / gcloud-ctx Goto Github PK
View Code? Open in Web Editor NEWManage Google Cloud Platform gcloud configurations easily and quickly
License: MIT License
Manage Google Cloud Platform gcloud configurations easily and quickly
License: MIT License
... e.g. scoop
When creating a configuration, if a region is not supplied then it should be inferred from the zone (e.g. zone europe-west1-d
implies region europe-west1
).
It'll probably be the case that the region almost always matches the zone so it'll save some typing, plus the option is there to override it if necessary.
Steps
fzf
is installed and on PATH
gctx activate
Ctrl+C
to exit fzf
without a selectionExpected
Nothing happens because the selection was cancelled
Actual
Error: Unable to find configuration ''
is shown
Would be good to have automated builds using Travis or similar for stable and nightly rust versions.
Look at using https://docs.rs/dialoguer/0.6.2/dialoguer/struct.Select.html instead of fzf
since we're using dialoguer
elsewhere anyway. Then we won't need external programs installed
Create a new command to allow copying an existing configuration, optionally overriding supported properties from the source configuration. For example:
gctx copy <existing> <new name> --project bar
would copy the existing configuration entirely, but with the project setting overridden (so the account, zone, etc would all be the same)
The zone/region formatted is to be validated in #29 which would catch some simple typos, but it would still let you type invalid zones/regions. Instead, we should validate the zone/region actually exists.
The challenge is that this data is not really static so we can't hard-code it into the executable. We'll need to do a web request to get the current valid list (and probably cache it locally somewhere).
Why tag.gz.zip?
... e.g. brew
If the active configuration is renamed then the new name is not marked as activated. The active config then points to an invalid configuration.
The CI currently only runs on Linux but it should also run on Windows and Mac as well.
Make sure output has appropriate colours in the terminal, e.g. highlight the name of a configuration when activating it
Follow https://no-color.org/ to allow disabling colour output
Use GitHub Actions to generate releases automatically with pre-built binaries for Windows, Linux and Mac
When creating a new configuration, verify the account argument is a valid email address
There are placeholder tests for gctx create --interactive
but they are set to ignored because they don't work. The assert_cmd
crate used to write the integration tests does not support interactive programs so you can't send multiple lines to stdin
after each prompt for a field.
It may be that another crate is needed to test that, such as rexpect
Add a new command to support creating a new configuration. This command will allow you to specify:
gcloud
allows the default location to be overridden using CLOUDSDK_CONFIG
. We should respect that value also.
Add the ability to run gctx describe
without a configuration name and default to use the current configuration
It can be tedious having to type out all the flags for creating a new configuration. It would be a better user experience to have an option to be prompted for each property instead so you could just type them as you go e.g.:
$ gctx create --interactive
Creating a new configuration interactively
Please enter the following properties
Name: my-name
Warning: a configuration named 'my-name' already exists, overwrite? [yN]: y
Project: my-project
Account: [email protected]
Zone: europe-west1-d
Region (optional):
Activate? [yN]: y
Successfully created configuration 'my-name'
Configuration 'my-name' is now active
The zone/region have no validation currently. It would be good to at least verify the format (e.g. (continent)-(geography)(id)-(id)
). Something like the regex ^[a-z]+-[a-z]+\d-[a-z]$
to match europe-west1-d
.
The list of zones/regions is here to verify they all follow that pattern
Replace fzf
external tool usage with skim
: https://github.com/lotabout/skim
This has the advantages:
Add the ability to delete a configuration
On a Mac, gcloud
stores config in ~/.config/gcloud
just like on Linux. However, gctx
uses the Apple developer guidelines to look in ~/Library/Application Support/gcloud
, which obviously doesn't work.
There will need to be a platform-specific override for forcing Mac to use the proper location.
Add some documentation at the crate level ready for publishing to crates.io
Some of the APIs allow force-overwriting, e.g. if trying to create a configuration which already exists, but they do so by specifying a boolean flag, like this:
store.rename("foo", "bar", true);
Instead that should work off an enum to make the API more ergonomic
gcloud uses a regex to validate config names when creating. gctx doesn't currently match this.
Use svg-term to create a demo screencast and it to the README
Currently gctx --version
doesn't display a version number
Currently gctx
has no tests at all. This is tricky because:
std::fs::*
methods, so you'd need to do lots of filesystem stuff or find a way to mock out the filesystem callsdirs
crate. Perhaps a #[cfg(test)]
could be used to allow tests to override the location to a temp directory during tests?std::fs::*
to do stuffIn reality I think some refactoring is just required to separate out the filesystem calls from the logic so that the logic can be tested in isolation. Then there can be a few select integration tests using a temp dir where necessary.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.