-
Notifications
You must be signed in to change notification settings - Fork 51
Follow conventions when creating objects #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; | ||
| local configMapList = k.core.v1.configMapList; | ||
|
|
||
| { | ||
| _config+:: { | ||
|
|
@@ -32,7 +33,7 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; | |
| }, | ||
| }, | ||
| }, | ||
| grafanaDashboards: {}, | ||
| grafanaDashboards:: {}, | ||
| grafana+: { | ||
| [if std.length($._config.grafana.config) > 0 then 'config']: | ||
| local secret = k.core.v1.secret; | ||
|
|
@@ -42,13 +43,15 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; | |
| secret.mixin.metadata.withNamespace($._config.namespace), | ||
| dashboardDefinitions: | ||
| local configMap = k.core.v1.configMap; | ||
| [ | ||
| local dashboardName = 'grafana-dashboard-' + std.strReplace(name, '.json', ''); | ||
| configMap.new(dashboardName, { [name]: std.manifestJsonEx($._config.grafana.dashboards[name], ' ') }) + | ||
| configMap.mixin.metadata.withNamespace($._config.namespace) | ||
| configMapList.new( | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see here, it used to be a
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, but when you render out a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't seem so. See same transformation in kube-prometheus: kubectl seems to flatten
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That only works because what is generated is not a List object but a directory of objects, where one of the files happens to be a ConfigMapList, so for kubectl the ConfigMapList is actually the top level item.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me run few tests, I'll come back to you
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct :)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "library" object should still have "standard" shape: to make it easier to use it in other jsonnet deployments. it is only examples which need to change. I can go with what do you think?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I quite like that
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another approach would be to return plain array and change exampes to call Either way output is pipeable into kubectl . Which one do you prefer?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I prefer the first, as that way when people want to they can still make use of the *List types for grouping, in the way I think it's good that the dashboard configmaps are currently grouped that way. |
||
| [ | ||
| local dashboardName = 'grafana-dashboard-' + std.strReplace(name, '.json', ''); | ||
| configMap.new(dashboardName, { [name]: std.manifestJsonEx($._config.grafana.dashboards[name], ' ') }) + | ||
| configMap.mixin.metadata.withNamespace($._config.namespace) | ||
|
|
||
| for name in std.objectFields($._config.grafana.dashboards) | ||
| ], | ||
| for name in std.objectFields($._config.grafana.dashboards) | ||
| ] | ||
| ), | ||
| dashboardSources: | ||
| local configMap = k.core.v1.configMap; | ||
| local dashboardSources = import 'configs/dashboard-sources/dashboards.libsonnet'; | ||
|
|
@@ -111,8 +114,8 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; | |
| [ | ||
| storageVolumeMount, | ||
| datasourcesVolumeMount, | ||
| dashboardsVolumeMount, | ||
| ] + | ||
| (if std.length(self.dashboardDefinitions.items) > 0 then [dashboardsVolumeMount] else []) + | ||
| [ | ||
| local dashboardName = std.strReplace(name, '.json', ''); | ||
| containerVolumeMount.new('grafana-dashboard-' + dashboardName, '/grafana-dashboard-definitions/0/' + dashboardName) | ||
|
|
@@ -124,8 +127,8 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; | |
| [ | ||
| storageVolume, | ||
| datasourcesVolume, | ||
| dashboardsVolume, | ||
| ] + | ||
| (if std.length(self.dashboardDefinitions.items) > 0 then [dashboardsVolume] else []) + | ||
| [ | ||
| local dashboardName = 'grafana-dashboard-' + std.strReplace(name, '.json', ''); | ||
| volume.withName(dashboardName) + | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last time I checked lists couldn't be nested, which is why we did what we did. Has this changed recently?