Fix panics on empty config

This commit is contained in:
Dmitrii Okunev
2024-10-21 20:34:42 +01:00
parent c284735c34
commit c9ab76a0f3
6 changed files with 84 additions and 11 deletions

View File

@@ -287,6 +287,9 @@ func ConvertPlatformConfig[T any, S StreamProfile](
ctx context.Context,
platCfg *AbstractPlatformConfig,
) *PlatformConfig[T, S] {
if platCfg == nil {
platCfg = &AbstractPlatformConfig{}
}
return &PlatformConfig[T, S]{
Enable: platCfg.Enable,
Config: GetPlatformSpecificConfig[T](ctx, platCfg.Config),
@@ -299,6 +302,10 @@ func GetPlatformSpecificConfig[T any](
ctx context.Context,
platCfgCfg any,
) T {
if platCfgCfg == nil {
var zeroValue T
return zeroValue
}
switch platCfgCfg := platCfgCfg.(type) {
case T:
return platCfgCfg