Skip to content

Commit

Permalink
Abstract away configmap interface
Browse files Browse the repository at this point in the history
  • Loading branch information
joyliu-q committed Oct 22, 2023
1 parent 2d202d3 commit dcc058e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
18 changes: 9 additions & 9 deletions cdk/kittyhawk/src/application/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ export interface RedisApplicationProps {
/**
* Override the default redis ConfigMap configuration and creates a custom ConfigMap object.
*/
readonly configMap?: {
readonly redisConfigMap?: {
readonly name: string;
readonly data: {
readonly "redis-config": string;
};
readonly config: string;
};
}

Expand All @@ -51,12 +49,14 @@ export class RedisApplication extends Application {
) {
const CONFIG_MAP_NAME = "redis-config";

if (redisProps.configMap) {
new KubeConfigMap(scope, redisProps.configMap.name, {
if (redisProps.redisConfigMap) {
new KubeConfigMap(scope, redisProps.redisConfigMap.name, {
metadata: {
name: redisProps.configMap.name,
name: redisProps.redisConfigMap.name,
},
data: {
"redis-config": redisProps.redisConfigMap.config,
},
data: redisProps.configMap.data,
});
}

Expand Down Expand Up @@ -123,7 +123,7 @@ export class RedisApplication extends Application {
{
name: "config",
configMap: {
name: redisProps.configMap?.name ?? CONFIG_MAP_NAME,
name: redisProps.redisConfigMap?.name ?? CONFIG_MAP_NAME,
items: [
{
key: "redis-config",
Expand Down
6 changes: 2 additions & 4 deletions cdk/kittyhawk/test/application/redis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ const redisTestConfig = {
},
},
customConfigMap: {
configMap: {
redisConfigMap: {
name: "custom-config-map",
data: {
"redis-config": "custom-config",
},
config: "custom-config",
},
},
};
Expand Down

0 comments on commit dcc058e

Please sign in to comment.