Skip to content

Commit 1c46ff0

Browse files
committed
Add helper method to access DataServiceConfig
1 parent 7887b4e commit 1c46ff0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/kubernetes-client-angular/projects/kubernetes-client-angular/src/lib/kubernetes-data-service-factory.service.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,21 @@ export abstract class KubernetesDataServiceFactoryConfig {
4545
[key: string]: DataServiceConfig
4646
}
4747
}
48+
49+
/**
50+
* Gets the {@link DataServiceConfig} for the given entity, with the default config as fallback.
51+
* @param config the config instance
52+
* @param entityName the entity name
53+
* @return the config in `overrides`, fallback to `default` or undefined if no default is set either.
54+
*/
55+
export function getDataServiceConfigOrDefault(
56+
entityName: string,
57+
config?: KubernetesDataServiceFactoryConfig
58+
): DataServiceConfig | undefined {
59+
if (!config) return undefined
60+
if (config.overrides) {
61+
const override = config.overrides[entityName]
62+
return override ? override : config.default
63+
}
64+
return config.default
65+
}

0 commit comments

Comments
 (0)