Skip to content

Commit

Permalink
fix(ksonnet-util): allow overriding root level k import (grafana#428)
Browse files Browse the repository at this point in the history
* fix(ksonnet-util): allow overriding root level k import

* don't expect vanilla import to call top level function
  • Loading branch information
Duologic authored Jan 19, 2021
1 parent 6aa643b commit 2cef89c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ksonnet-util/kausal.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

(import 'grafana.libsonnet')
+ {
local this = self,
_config+:: {
enable_rbac: true,
enable_pod_priorities: false,
namespace: error 'Must define a namespace',
},

util+::
(import 'util.libsonnet')
(import 'util.libsonnet').withK(this)
+ {
rbac(name, rules)::
if $._config.enable_rbac
Expand Down
7 changes: 5 additions & 2 deletions ksonnet-util/util.libsonnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// util.libsonnet provides a number of useful (opinionated) shortcuts to replace boilerplate code
local k = import 'grafana.libsonnet';

{
local util(k) = {
// mapToFlags converts a map to a set of golang-style command line flags.
mapToFlags(map, prefix='-'): [
'%s%s=%s' % [prefix, key, map[key]]
Expand Down Expand Up @@ -243,4 +242,8 @@ local k = import 'grafana.libsonnet';
local deployment = k.apps.v1.deployment,
podPriority(p):
deployment.mixin.spec.template.spec.withPriorityClassName(p),
};

util((import 'grafana.libsonnet')) + {
withK(k):: util(k),
}

0 comments on commit 2cef89c

Please sign in to comment.