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

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.
“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.

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

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, the Quick Run pane extensions is here.

--

--

--

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.

Recommended from Medium

Must Do’s & Don’ts While Outsourcing iOS App Development

Create a React Project from scratch with TypeScript & Parcel

Class is not a class. Extends doesn’t Extend in JS

Frontend Weekly Digest #210 (10–16 May 2021)

Asynchronous Tasks with Redux

Every action will either reach reducers via middlewares or won’t propagate beyond some middleware.

Why do Front-end developers prefer AngularJs for Front End Development?

Linear-Gradient Underline Text

Race For Tech: What is the right technology for my app?

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
Márton Kodok

Márton Kodok

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

More from Medium

Host Private Node.JS Packages on the Google Cloud with Artifact Registry

Migrating Collections from MongoDB to Cloud Firestore

Deploying VueJS With NodeJS Backend on GCP GKE using HELM

Create a Custom CLI Tool and Distribute with HomeBrew Using Goreleaser and Github Actions