Skip to content

Commit

Permalink
Add helper method to access DataServiceConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ccremer committed May 17, 2023
1 parent 7887b4e commit 1c46ff0
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,21 @@ export abstract class KubernetesDataServiceFactoryConfig {
[key: string]: DataServiceConfig
}
}

/**
* Gets the {@link DataServiceConfig} for the given entity, with the default config as fallback.
* @param config the config instance
* @param entityName the entity name
* @return the config in `overrides`, fallback to `default` or undefined if no default is set either.
*/
export function getDataServiceConfigOrDefault(
entityName: string,
config?: KubernetesDataServiceFactoryConfig
): DataServiceConfig | undefined {
if (!config) return undefined
if (config.overrides) {
const override = config.overrides[entityName]
return override ? override : config.default
}
return config.default
}

0 comments on commit 1c46ff0

Please sign in to comment.