|
47 | 47 | {}
|
48 | 48 | ),
|
49 | 49 |
|
| 50 | + local folder_mounts = |
| 51 | + // Dedupe folder names through a map fold first, |
| 52 | + // just incase two mixins go into the same folder. |
| 53 | + local folderShards = std.foldr( |
| 54 | + function(mixinName, acc) |
| 55 | + local mixin = $.mixins[mixinName]; |
| 56 | + if !$.isFolderedMixin(mixin) |
| 57 | + then acc |
| 58 | + else acc { |
| 59 | + [$.folderID(mixin.grafanaDashboardFolder)]: |
| 60 | + if std.objectHas(mixin, 'grafanaDashboardShards') |
| 61 | + then mixin.grafanaDashboardShards |
| 62 | + else 1, |
| 63 | + }, |
| 64 | + std.objectFields($.mixins), |
| 65 | + {}, |
| 66 | + ); |
| 67 | + std.foldr( |
| 68 | + function(folderName, acc) |
| 69 | + local config_map_name = 'dashboards-%s' % folderName; |
| 70 | + local shards = folderShards[folderName]; |
| 71 | + sharded_config_map_mounts(config_map_name, shards) + acc, |
| 72 | + std.objectFields(folderShards), |
| 73 | + {}, |
| 74 | + ), |
| 75 | + |
50 | 76 | grafana_deployment:
|
51 | 77 | deployment.new('grafana', 1, [$.grafana_container]) +
|
52 | 78 | // Use configMapVolumeMount to automatically include the hash of the config
|
|
61 | 87 | sharded_config_map_mounts('dashboards', $._config.dashboard_config_maps)
|
62 | 88 | ) + (
|
63 | 89 | // Add config map mounts for each folder for dashboards.
|
64 |
| - std.foldr( |
65 |
| - function(mixinName, acc) |
66 |
| - local mixin = $.mixins[mixinName]; |
67 |
| - if !$.isFolderedMixin(mixin) |
68 |
| - then acc |
69 |
| - else |
70 |
| - local config_map_name = 'dashboards-%s' % $.folderID(mixin.grafanaDashboardFolder); |
71 |
| - local shards = |
72 |
| - if std.objectHas(mixin, 'grafanaDashboardShards') |
73 |
| - then mixin.grafanaDashboardShards |
74 |
| - else 1; |
75 |
| - sharded_config_map_mounts(config_map_name, shards) + acc, |
76 |
| - std.objectFields($.mixins), |
77 |
| - {}, |
78 |
| - ) |
| 90 | + folder_mounts |
79 | 91 | ) +
|
80 | 92 | $.util.podPriority('critical'),
|
81 | 93 |
|
|
0 commit comments