Explorar el Código

prevent error if description is empty

Signed-off-by: nickcurie <nick.curie64@gmail.com>
nickcurie hace 3 años
padre
commit
3c8d153c1c
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      pkg/cloud/gcpprovider.go

+ 4 - 2
pkg/cloud/gcpprovider.go

@@ -472,8 +472,10 @@ func (gcp *GCP) GetOrphanedResources() ([]OrphanedResource, error) {
 				// GCP gives us description as a string formatted as a map[string]string, so we need to
 				// GCP gives us description as a string formatted as a map[string]string, so we need to
 				// deconstruct it back into a map[string]string to match the OR struct
 				// deconstruct it back into a map[string]string to match the OR struct
 				desc := map[string]string{}
 				desc := map[string]string{}
-				if err := json.Unmarshal([]byte(disk.Description), &desc); err != nil {
-					return nil, fmt.Errorf("error converting string to map: %s", err)
+				if disk.Description != "" {
+					if err := json.Unmarshal([]byte(disk.Description), &desc); err != nil {
+						return nil, fmt.Errorf("error converting string to map: %s", err)
+					}
 				}
 				}
 
 
 				// Converts https://www.googleapis.com/compute/v1/projects/xxxxx/zones/us-central1-c to us-central1-c
 				// Converts https://www.googleapis.com/compute/v1/projects/xxxxx/zones/us-central1-c to us-central1-c