blob: 3fd9c5e17473d8eecdd208092738ec90d64d11f5 [file] [log] [blame]
#include "bmc/gmi_reader.h"
#include <filesystem> // NOLINT(build/c++17)
#include <string>
#include "gmi/machine_identity.pb.h"
#include "proto_reader.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
namespace gmi_reader {
using security_prodid::GoogleMachineIdentityProto;
absl::StatusOr<std::string> ReadGmiHostName(
const std::filesystem::path& gmi_path) {
absl::StatusOr<GoogleMachineIdentityProto> id_proto =
proto_reader::ReadProto<GoogleMachineIdentityProto>(gmi_path);
if (!id_proto.ok()) {
LOG(ERROR) << "Failed to deserialize the GMI file";
return absl::InvalidArgumentError("Failed to deserialize the GMI file");
}
return id_proto->fqdn();
}
} // namespace gmi_reader