-
Notifications
You must be signed in to change notification settings - Fork 51
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
Follow conventions when creating objects #67
base: master
Are you sure you want to change the base?
Conversation
46d46f0
to
a145d2a
Compare
It seems that shape of the object produced by individual jsonnet library agreed to be following: ``` { hidden:: { ... } component: { resource1: { apiVersion: ... , kind: .... }, resource2: { apiVersion: ... , kind: .... }, } } ``` so that std.objectFields(obj) returns an object made of kubernetes object to apply. Hidden fields are then can be used for cooperation on values, such as `_config::` This commit brings produced output in line with convention above
a145d2a
to
ba95ada
Compare
hm, is Travis CI webhook stuck? |
If there is no dashboards, then no /grafana-dashboard-definitions/0/ is created and Grafana becomes upset, because it's provisioning config points there.
b60dbbe
to
138c136
Compare
[ | ||
grafana.dashboardDefinitions, |
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?
Yes , change is that now it is not a JSON array, but a single Kubernetes 'kind: List' object
…-------- Original Message --------
On 28 May 2019, 13:36, Frederic Branczyk wrote:
@brancz commented on this pull request.
---------------------------------------------------------------
In [README.md](#67 (comment)):
> [
+ grafana.dashboardDefinitions,
Last time I checked lists couldn't be nested, which is why we did what we did. Has this changed recently?
—
You are receiving this because you authored the thread.
Reply to this email directly, [view it on GitHub](#67?email_source=notifications&email_token=AAAEB4FKACA6ZICHSXVLPFTPXURNRA5CNFSM4HOWR4XKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOBZ3FV5Q#pullrequestreview-242637558), or [mute the thread](https://github.com/notifications/unsubscribe-auth/AAAEB4H7I2HGSLUWVLQVVPLPXURNRANCNFSM4HOWR4XA).
|
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( |
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.
see here, it used to be a []
, but now a single { kind: ConfigmapList, items: [] }
object, it allows embedding it
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.
right, but when you render out a kind: List
, does kubectl actually create deep lists recursively?
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.
Doesn't seem so. See same transformation in kube-prometheus:
kubectl seems to flatten kind: List
items, at least one level deep for sure. here we are exactly one level deep, so should be fine
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.
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.
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.
let me run few tests, I'll come back to you
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.
correct :)
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.
"library" object should still have "standard" shape:
{ key: { kind: ... } }
to make it easier to use it in other jsonnet deployments.
it is only examples which need to change. I can go with
local grafana =
((import 'grafana/grafana.libsonnet') + .... ).grafana;
local flatten(lst) = std.foldl(function(acc, r) if ! std.endsWith(r.kind, "List") then acc + [r] else acc + r.items, lst, []);
k.core.v1.list.new(flatten([grafana[k] for k in grafana]))
what do you think?
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.
yeah, I quite like that
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.
Another approach would be to return plain array and change exampes to call jsonnet --yaml-stream
.
Either way output is pipeable into kubectl . Which one do you prefer?
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.
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.
It seems that shape of the object produced by individual
jsonnet library set to be following:
so that std.objectFields(obj) returns an object
made of kubernetes object to apply.
Hidden fields are then can be used for cooperation
on values, such as
_config::
This commit brings produced output in line with convention above