I had a jsonnet file where there is a file config.json which is hard coded in the variable. What I want to do is to have the ability to pass config_v1.json or config.v*.json as an argument to the config. How do I do that in the jsonnet ?
local config(
args,
resources,
nodeAffinity,
replicas=1,
ttl='',
fullName=naming.NewFullName('allm', namespace),
image=naming.WithRegistry('allm:' + env.global.User + '-latest'),
routes=null,
command=null,
) = (
local configMap = {
apiVersion: 'v1',
kind: 'ConfigMap',
metadata: {
name: fullName.name,
namespace: fullName.namespace,
labels: { app: fullName.name },
},
data: {
'conf-multiturn.json': std.manifestJsonEx(confData, ' '),
},
};
Given that you want the configData JSON to be verbatim manifested, you really don't need to manipulate it further.
In the below example, I use
importstrto loadconfigdata.jsonas-is, then build two data fields: one verbatim from loaded JSON, then another one with one of its fields changed via jsonnet just to show you how the possible transformations should be done (not needed in your original use case):foo.jsonnet
configdata.json
output