This Go application lists running services in one or more Google Cloud projects, including Cloud Run, App Engine, Compute Engine, and Kubernetes Engine. It also provides a progress bar to indicate the progress of the operations.
gcup/
|-- main.go
|-- services/
| |-- appengine.go
| |-- cloudrun.go
| |-- compute.go
| |-- kubernetes.go
| |-- utils.go
- Go 1.16 or later
- Google Cloud SDK (for authentication)
- Internet access to download dependencies
-
Clone the repository:
git clone https://github.com/Benabra/gcup.git cd gcup
-
Initialize your Go module (if not already initialized):
go mod init gcup
-
Install necessary dependencies:
go get github.com/schollz/progressbar/v3 github.com/olekukonko/tablewriter google.golang.org/api/option google.golang.org/api/run/v1 google.golang.org/api/appengine/v1 google.golang.org/api/compute/v1 google.golang.org/api/container/v1
-
Authenticate with Google Cloud:
Ensure you are authenticated with Google Cloud:
gcloud auth application-default login
-
Run the program with your Google Cloud project IDs:
go run main.go -projects=PROJECT_ID_1,PROJECT_ID_2,PROJECT_ID_3
Replace
PROJECT_ID_1
,PROJECT_ID_2
,PROJECT_ID_3
, etc., with your actual Google Cloud project IDs.
- main.go: The entry point of the application.
- services/: Contains Go files for each GCP service and utility functions.
- appengine.go: Lists App Engine services.
- cloudrun.go: Lists Cloud Run services.
- compute.go: Lists Compute Engine instances.
- kubernetes.go: Lists Kubernetes Engine clusters.
- utils.go: Contains utility functions such as error handling.
Running the application will display a progress bar and then output tables of running services and any errors encountered:
[###-------------------------------] 1/4
Checking services for project: project-id-1
==================================================
Running Services:
+------------------+------------+---------+
| SERVICE | RESOURCE | STATUS |
+------------------+------------+---------+
| Cloud Run | service1 | RUNNING |
| App Engine | service2 | RUNNING |
| Compute Engine | instance1 | RUNNING |
| Kubernetes Engine| cluster1 | RUNNING |
+------------------+------------+---------+
==================================================
Checking services for project: project-id-2
==================================================
No running services found for project: project-id-2
==================================================
Checking services for project: project-id-3
==================================================
Running Services:
+------------------+------------+---------+
| SERVICE | RESOURCE | STATUS |
+------------------+------------+---------+
| Cloud Run | service3 | RUNNING |
| App Engine | service4 | RUNNING |
| Compute Engine | instance2 | RUNNING |
| Kubernetes Engine| cluster2 | RUNNING |
+------------------+------------+---------+
Errors:
+------------+------------------+-------------------+----------------------------------------+
| Project | Service | Resource | Reason |
+------------+------------------+-------------------+----------------------------------------+
| project-id | Cloud Run | Cloud Run Service | Permission denied for Cloud Run. |
+------------+------------------+-------------------+----------------------------------------+
- Fork the repository.
- Create your feature branch (
git checkout -b feature/fooBar
). - Commit your changes (
git commit -am 'Add some fooBar'
). - Push to the branch (
git push origin feature/fooBar
). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.