2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-07-05 08:39:17 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2022-12-08 05:26:51 -05:00
|
|
|
"cloud.google.com/go/compute/apiv1/computepb"
|
2022-07-05 08:39:17 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// getMetadataByKey returns the value of the metadata key in the given metadata.
|
|
|
|
func getMetadataByKey(metadata *computepb.Metadata, key string) string {
|
|
|
|
if metadata == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
for _, item := range metadata.Items {
|
|
|
|
if item.Key == nil || item.Value == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if *item.Key == key {
|
|
|
|
return *item.Value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|