jsonnet-libs / k8s

Code generator for Jsonnet Kubernetes libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HPA `withScaleTargetRef` custom function returns error

pharaujo opened this issue · comments

Minimal project that shows the problem follows:

Running tk init in an empty dir, then adding the test code to environments/default/main.jsonnet:

local k = import 'k.libsonnet';
{
  deployment: k.apps.v1.deployment.new('sample', containers=[]),
  hpa:
    k.autoscaling.v2beta2.horizontalPodAutoscaler.new('sample') +
    k.autoscaling.v2beta2.horizontalPodAutoscaler.spec.withScaleTargetRef($.deployment),
}

Running tk show environments/default/ returns the following error:

Error: evaluating jsonnet: RUNTIME ERROR: couldn't manifest function as JSON
	Field "withApiVersion"
	Field "scaleTargetRef"
	Field "spec"
	Field "hpa"
	During manifestation

I believe this is caused by the merge of withApiVersion here:

{ spec+: { scaleTargetRef+: withApiVersion {

I left a comment in the PR that added this customization asking what was the original purpose, but I believe taking it out should solve the issue.