mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-27 16:39:38 -05:00
bd63aa3c6b
sed -i '1i/*\nCopyright (c) Edgeless Systems GmbH\n\nSPDX-License-Identifier: AGPL-3.0-only\n*/\n' `grep -rL --include='*.go' 'DO NOT EDIT'` gofumpt -w .
28 lines
535 B
Go
28 lines
535 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package client
|
|
|
|
import (
|
|
computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
|
|
)
|
|
|
|
// 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 ""
|
|
}
|