Add meaningful error message when project id is missing

This commit is contained in:
2022-01-21 13:32:52 +01:00
parent 5be7742f07
commit c3a83c7666

View File

@@ -28,6 +28,9 @@ func (i Instance) GetAddress(private bool) string {
func GetInstances(target string) ([]Instance, error) { func GetInstances(target string) ([]Instance, error) {
project := viper.GetString("gcp.projectid") project := viper.GetString("gcp.projectid")
if project == "" {
return nil, fmt.Errorf("missing Google Cloud project ID, consider adding it to your config file: %s", viper.ConfigFileUsed())
}
gcpClient, err := NewGCPClient() gcpClient, err := NewGCPClient()
if err != nil { if err != nil {