Initial commit, pt. 6

This commit is contained in:
Dmitrii Okunev
2024-04-20 21:49:00 +01:00
parent a4aff24989
commit e68174a7a0
5 changed files with 257 additions and 16 deletions

View File

@@ -126,12 +126,22 @@ func GetPlatformConfig[T any, S StreamProfile](
logger.Debugf(ctx, "config '%s' was not found in cfg: %#+v", id, cfg)
return nil
}
return ConvertPlatformConfig[T, S](ctx, platCfg, id)
}
func ConvertPlatformConfig[T any, S StreamProfile](
ctx context.Context,
platCfg *AbstractPlatformConfig,
id PlatformName,
) *PlatformConfig[T, S] {
platCfgCfg, ok := platCfg.Config.(*T)
if !ok {
var zeroValue T
logger.Errorf(ctx, "unable to get the config: expected type '%T', but received type '%T'", zeroValue, platCfg.Config)
return nil
}
return &PlatformConfig[T, S]{
Config: *platCfgCfg,
StreamProfiles: GetStreamProfiles[S](platCfg.StreamProfiles),