-
Notifications
You must be signed in to change notification settings - Fork 297
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
Document usage of intstr.IntOrString in the k8s tutorial #148
Comments
Original reply by @mpvl in cuelang/cue#148 (comment) @grantzvolsky If you look at the generated definition of Even though one should not edit generated files, one can without harm define files alongside it with new definitions that get unified with the existing ones. So in
As long as the the name does not end with |
Original reply by @grantzvolsky in cuelang/cue#148 (comment)
That doesn't seem to be so in my case. Following your instructions I get
I'm using go 1.13.1 and cue 0.0.11. |
Original reply by @mpvl in cuelang/cue#148 (comment) Very strange indeed. I've tried to reproduce the error, using different versions including the one you mentioned, but for me it always generates Could you maybe provide more information, such as the OS, exact K8s commit you were extracting from? |
Original reply by @grantzvolsky in cuelang/cue#148 (comment) I'm on a different laptop now and the issue prevails. Below is a screencast demonstrating the problem. It was recorded in a fresh Asciinema (Ubuntu 18.04) docker container. Step 1: Step 2-n: [skip 0:40-1:20 and 2:35-4:15] https://asciinema.org/a/qBMKNMdX3gsCLClmdvqNP5a0J |
Original reply by @lizzabees in cuelang/cue#148 (comment) i'm experiencing this behavior too and struggling to understand where it's breaking. i don't believe it's impacted by cue version -- i've tested with all versions back to 0.0.4 with no change in behavior. this is what i'm seeing (using 0.0.14): i have one machine that generates the correct definition ( on other machines/VMs it generates the incorrect definition
what i'm not understanding is that even if i check out the same revision of apimachinery as on the working machine and do a i'm also seeing similar discrepancies in generated definitions for other k8s resources (for instance, resource request/limits) |
Original reply by @mpvl in cuelang/cue#148 (comment) @lizzabees you can try
|
Original reply by @mpvl in cuelang/cue#148 (comment) @lizzabees I looked at the differences between the versions and don't see any difference of importance. @grantzvolsky: I followed your install almost to the step using a Docker ubuntu:18.04 image (I don't have your install scripts, but otherwise identical). I'm still getting the correct output. Wild. What are the Go versions used on each of the machines? |
Original reply by @mpvl in cuelang/cue#148 (comment) FYI, I've used go1.13.1 (the version Grant mentioned he used) and the latest CUE. |
Original reply by @grantzvolsky in cuelang/cue#148 (comment) @mpvl I reduced the problem demonstration to a single Dockerfile:
When I run
|
Original reply by @grantzvolsky in cuelang/cue#148 (comment) It turns out that installing cue via To reproduce: run Dockerfile
|
Original reply by @santoshborse in cuelang/cue#148 (comment) I was facing slightly similar issue with,
with error,
It worked in this way
|
Original reply by @a-palchikov in cuelang/cue#148 (comment) I'm consistently getting
I've tried go1.12.17 and go1.13.9 and installing cue with |
Original reply by @a-palchikov in cuelang/cue#148 (comment) It looks like it silently fails if cue is not installed with the expected module path of
The following seems to fix it but I'm not sure this is the correct fix: import stdruntime "runtime"
// ...
func initInterfaces() error {
_, file, _, _ := stdruntime.Caller(0)
cfg := &packages.Config{
Dir: filepath.Join(filepath.Dir(file), "interfaces"),
Mode: packages.LoadAllSyntax,
}
p, err := packages.Load(cfg, "cuelang.org/go/cmd/cue/cmd/interfaces")
if err != nil {
return err
}
for _, pp := range p {
if len(pp.Errors) != 0 {
return pp.Errors[0] // do not ignore package load errors
}
}
// ... skipped
} After that, it works as expected:
|
Original reply by @mgoodness in cuelang/cue#148 (comment) Ran into this issue with v0.2.2 installed from Homebrew. Can confirm that |
Original reply by @myitcv in cuelang/cue#148 (comment) This issue generally feels like a symptom of the the various issues I summarised in The short version however is:
Please feel free to raise any further questions/issues over there, or in a separate issue if you think it a separate issue. Thanks |
Picking up from cue-lang#147 and cue-lang#148
Originally opened by @grantzvolsky in cuelang/cue#148
The kubernetes tutorial shows how to Extract CUE templates directly from Go source.
The generated Cue templates include intstr.
The question is how to use this struct with Cue.
How could one e.g. configure a service
targetPort
? Neither of the configurations below work.Error 1:
Error 2:
Invalid output (yaml dump):
A possible workaround would be to define IntOrString as
IntOrString :: int | string
, but that would go against the instructions in the template ("// Code generated by cue get go. DO NOT EDIT.
").The text was updated successfully, but these errors were encountered: