[MM-59292] Add metadata to Support Packet (#27573)

Этот коммит содержится в:
Ben Schumacher
2024-07-14 20:26:43 +02:00
коммит произвёл GitHub
родитель a4bdb65037
Коммит ff3ed78124
4 изменённых файлов: 50 добавлений и 7 удалений

Просмотреть файл

@@ -103,18 +103,18 @@ func ParsePacketMetadata(b []byte) (*PacketMetadata, error) {
}
// GeneratePacketMetadata is a utility function to generate metadata for customer provided Packets.
// It will construct it from serverID and optionally a license.
func GeneratePacketMetadata(serverID string, license *License, extra map[string]any) (*PacketMetadata, error) {
// It will construct it from a Packet Type, the telemetryID and optionally a license.
func GeneratePacketMetadata(t PacketType, telemetryID string, license *License, extra map[string]any) (*PacketMetadata, error) {
if extra == nil {
extra = make(map[string]any)
}
md := PacketMetadata{
md := &PacketMetadata{
Version: CurrentMetadataVersion,
Type: PluginPacketType,
Type: t,
GeneratedAt: GetMillis(),
ServerVersion: CurrentVersion,
ServerID: serverID,
ServerID: telemetryID,
Extras: extra,
}
@@ -127,5 +127,5 @@ func GeneratePacketMetadata(serverID string, license *License, extra map[string]
return nil, fmt.Errorf("invalid metadata: %w", err)
}
return &md, nil
return md, nil
}

Просмотреть файл

@@ -162,7 +162,7 @@ func (s *SystemService) GeneratePacketMetadata(path string, pluginMeta map[strin
pluginMeta["plugin_id"] = manifest.Id
pluginMeta["plugin_version"] = manifest.Version
md, err := model.GeneratePacketMetadata(serverID, license, pluginMeta)
md, err := model.GeneratePacketMetadata(model.PluginPacketType, serverID, license, pluginMeta)
if err != nil {
return "", errors.Wrap(err, "failed to get packet metadata")
}