-
Notifications
You must be signed in to change notification settings - Fork 171
Document usage of intstr.IntOrString in the k8s tutorial #148
Comments
@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 |
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. |
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? |
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 |
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) |
@lizzabees you can try
|
@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? |
FYI, I've used go1.13.1 (the version Grant mentioned he used) and the latest CUE. |
@mpvl I reduced the problem demonstration to a single Dockerfile:
When I run
|
It turns out that installing cue via To reproduce: run Dockerfile
|
I was facing slightly similar issue with,
with error,
It worked in this way
|
I'm consistently getting
I've tried go1.12.17 and go1.13.9 and installing cue with |
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:
|
Ran into this issue with v0.2.2 installed from Homebrew. Can confirm that |
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 |
This issue has been migrated to cue-lang/cue#148. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
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: