Introducing “GCP Project Switcher” Extension for VS Code — My Weekend Project

Márton Kodok
Nov 10 · 3 min read

Writing, debugging and deploying from Visual Studio Code for Google Cloud Platform is working out great as you have multiple options to interact with Google Cloud products:

All these work based on the project that your environment is setup.

However, the VS Code screen was missing key info: displaying the current project. There was no easy way to switch projects from the IDE. Until now!

Introducing the “GCP Project Switcher” extension for VS Code.

Introducing “GCP Project Switcher” extension for VS Code.
Introducing “GCP Project Switcher” extension for VS Code.
“GCP Project Switcher” extension for VS Code

A weekend project with Typescript

So, this weekend in early November, I had some free time as it was without any conference speaking opportunity which I usually do. The weekend turned out to be productive as I was able to release the extension after two days of small work. Also, I share a secret, this is my first project written in Typescript that got into “production”. It was a nice way to learn how Typescript works, compiles and runs.

Developers love to see on which Git branch are. I always was fascinated by how these are smartly applied to shell’s, screen and tmux instances on Linux systems.

Turns out on VS Code you are able to create your own extension that would add functionality to almost any section of the IDE, but my interest was for the status bar.

The GCP Project Switcher extension creates a status bar item. It uses the gcloud tool to obtain the current project, and it’s refreshed in the background so external changes are handled.

VSCode status bar with GCP Project Switcher Extension installed.
VSCode status bar with GCP Project Switcher Extension installed.
VSCode status bar with GCP Project Switcher Extension installed.

When clicking the status bar item a quick pick pane opens, and you are able to search either by project name or by ID. In order for the pane to be fast — as pulling projects list has a latency — all the polling is done in the background and it’s cached.

Suppose there is a new project that is not on the list, there is a refresh icon to force polling the projects lists. This helps to get started quickly on newly created projects.

Google Cloud Platform Project Switcher pane
Google Cloud Platform Project Switcher pane
Google Cloud Platform Project Switcher pane

Limitations: the gcloud utility must be available in your PATH, as the extension is using that to poll and switch the project on your environment. I plan to add a configuration option to customize the path of the gcloud tool for those who don’t have it globally available in the PATH.

Future work is already planned, I want to maintain a list of “recent” used projects, and populate the list with the recent projects at the top.

Grab the extension either from VS Code Extensions pane, or from Marketplace. Also you can post a Review and Rating in the Marketplace.

The extension is open-source, you can contribute via Github.

Bonus: A sample .vscode/tasks.json definition to deploy a Cloud Workflow.

Image for post
Image for post

Google Cloud - Community

Google Cloud community articles and blogs

Márton Kodok

Written by

Speaker at conferences, a Google Developer Expert top user on Stackoverflow, software architect at REEA.net, co-founder IT Mures, life-long learner, mentor

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Márton Kodok

Written by

Speaker at conferences, a Google Developer Expert top user on Stackoverflow, software architect at REEA.net, co-founder IT Mures, life-long learner, mentor

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store