Skip to content

Use of mixin with spread gives unexpected result #562

Answered by holzensp
dshatokhin asked this question in Q&A
Discussion options

You must be logged in to vote

I ask, because you're defining Pkl's amending quite precisely there. It sounds like you want a MyParams.pkl (upper case, because a template with defaults and type definitions, meant to be amended) with something like:

class HttpRequest {
  hidden type: *"GET"|"POST"|"PUT" //...
  path: String(startsWith("/")) = "/"
  port: *"http"|"https"|Int(isBetween(1,65535))
}

class LivenessProbe {
  httpGet: HttpRequest(type == "GET")
}

livenessProbe: LivenessProbe

output {
  renderer = new YamlRenderer {}
}

and in a subdirectory, somewhere, you might have myParams.pkl (lower case, because amending a template);

amends ".../MyParams.pkl"

path = "/live"

Now when you pkl eval myParams.pkl, you get

l…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@holzensp
Comment options

@dshatokhin
Comment options

@holzensp
Comment options

@holzensp
Comment options

Answer selected by dshatokhin
@dshatokhin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants