From 94db2eb171e7934e5d773d275bfe0d7558333c56 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Sat, 18 Jul 2020 17:45:26 +0200 Subject: [PATCH] cmd/cue/cmd: include unexported constants for get go Mimic unexported status. Omit `_`, still. Change-Id: Ib89f082fc0022d0186ffaf654eaec353bdd95013 Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6601 Reviewed-by: Marcel van Lohuizen --- cmd/cue/cmd/get_go.go | 2 +- cmd/cue/cmd/testdata/code/go/pkg1/file1.go | 11 +++++++++++ .../cue/cmd/testdata/code/go/pkg1/file1_go_gen.cue | 7 +++++++ .../api/core/v1/annotation_key_constants_go_gen.cue | 1 + .../apimachinery/pkg/api/resource/math_go_gen.cue | 13 +++++++++++++ .../pkg/api/resource/quantity_go_gen.cue | 6 ++++++ .../apimachinery/pkg/apis/meta/v1/types_go_gen.cue | 7 ++++++- .../apimachinery/pkg/runtime/codec_go_gen.cue | 5 +++++ .../k8s.io/apimachinery/pkg/watch/mux_go_gen.cue | 4 ++++ 9 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/math_go_gen.cue diff --git a/cmd/cue/cmd/get_go.go b/cmd/cue/cmd/get_go.go index 759b15447..a84c83f4a 100644 --- a/cmd/cue/cmd/get_go.go +++ b/cmd/cue/cmd/get_go.go @@ -681,7 +681,7 @@ func (e *extractor) reportDecl(x *ast.GenDecl) (a []cueast.Decl) { } for i, name := range v.Names { - if !ast.IsExported(name.Name) { + if name.Name == "_" { continue } f := e.def(v.Doc, name.Name, nil, k == 0) diff --git a/cmd/cue/cmd/testdata/code/go/pkg1/file1.go b/cmd/cue/cmd/testdata/code/go/pkg1/file1.go index 1aa7be518..a1a183ff9 100644 --- a/cmd/cue/cmd/testdata/code/go/pkg1/file1.go +++ b/cmd/cue/cmd/testdata/code/go/pkg1/file1.go @@ -67,6 +67,17 @@ type Foozer struct { Unsupported map[int]string } +type Identifier string + +const ( + internalIdentifier Identifier = "internal" +) + +const _ = true + +// appease linter +var _ = internalIdentifier + // Level gives an indication of the extent of stuff. type Level int diff --git a/cmd/cue/cmd/testdata/pkg/cuelang.org/go/cmd/cue/cmd/testdata/code/go/pkg1/file1_go_gen.cue b/cmd/cue/cmd/testdata/pkg/cuelang.org/go/cmd/cue/cmd/testdata/code/go/pkg1/file1_go_gen.cue index 516402651..a2f483ccf 100644 --- a/cmd/cue/cmd/testdata/pkg/cuelang.org/go/cmd/cue/cmd/testdata/code/go/pkg1/file1_go_gen.cue +++ b/cmd/cue/cmd/testdata/pkg/cuelang.org/go/cmd/cue/cmd/testdata/code/go/pkg1/file1_go_gen.cue @@ -47,6 +47,13 @@ import ( } @go(,struct{CustomJSON}) } +#Identifier: string // #enumIdentifier + +#enumIdentifier: + _#internalIdentifier + +_#internalIdentifier: #Identifier & "internal" + // Level gives an indication of the extent of stuff. #Level: int // #enumLevel diff --git a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/api/core/v1/annotation_key_constants_go_gen.cue b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/api/core/v1/annotation_key_constants_go_gen.cue index 83bf89897..889e56f95 100644 --- a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/api/core/v1/annotation_key_constants_go_gen.cue +++ b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/api/core/v1/annotation_key_constants_go_gen.cue @@ -48,6 +48,7 @@ package v1 // annotation key prefix used to identify non-convertible json paths. #NonConvertibleAnnotationPrefix: "non-convertible.kubernetes.io" +_#kubectlPrefix: "kubectl.kubernetes.io/" // LastAppliedConfigAnnotation is the annotation used to store the previous // configuration of a resource for use in a three way diff by UpdateApplyAnnotation. diff --git a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/math_go_gen.cue b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/math_go_gen.cue new file mode 100644 index 000000000..711f2096f --- /dev/null +++ b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/math_go_gen.cue @@ -0,0 +1,13 @@ +// Code generated by cue get go. DO NOT EDIT. + +//cue:generate cue get go k8s.io/apimachinery/pkg/api/resource + +package resource + +// maxInt64Factors is the highest value that will be checked when removing factors of 10 from an int64. +// It is also the maximum decimal digits that can be represented with an int64. +_#maxInt64Factors: 18 + +_#mostNegative: -9223372036854775808 + +_#mostPositive: 9223372036854775807 diff --git a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/quantity_go_gen.cue b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/quantity_go_gen.cue index 6eb94146b..704348fcd 100644 --- a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/quantity_go_gen.cue +++ b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/quantity_go_gen.cue @@ -78,3 +78,9 @@ package resource #DecimalExponent: #Format & "DecimalExponent" #BinarySI: #Format & "BinarySI" #DecimalSI: #Format & "DecimalSI" + +// splitREString is used to separate a number from its suffix; as such, +// this is overly permissive, but that's OK-- it will be checked later. +_#splitREString: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$" + +_#int64QuantityExpectedBytes: 18 diff --git a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/apis/meta/v1/types_go_gen.cue b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/apis/meta/v1/types_go_gen.cue index 997841d93..a221e9485 100644 --- a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/apis/meta/v1/types_go_gen.cue +++ b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/apis/meta/v1/types_go_gen.cue @@ -858,7 +858,8 @@ import ( #CauseTypeFieldValueInvalid | #CauseTypeFieldValueNotSupported | #CauseTypeUnexpectedServerResponse | - #CauseTypeFieldManagerConflict + #CauseTypeFieldManagerConflict | + #CauseTypeResourceVersionTooLarge // CauseTypeFieldValueNotFound is used to report failure to find a requested value // (e.g. looking up an ID). @@ -889,6 +890,10 @@ import ( // It should only be returned for a request using server-side apply. #CauseTypeFieldManagerConflict: #CauseType & "FieldManagerConflict" +// CauseTypeResourceVersionTooLarge is used to report that the requested resource version +// is newer than the data observed by the API server, so the request cannot be served. +#CauseTypeResourceVersionTooLarge: #CauseType & "ResourceVersionTooLarge" + // List holds a list of objects, which may not be known by the server. #List: { #TypeMeta diff --git a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/runtime/codec_go_gen.cue b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/runtime/codec_go_gen.cue index 39bbb1f20..c1b70758f 100644 --- a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/runtime/codec_go_gen.cue +++ b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/runtime/codec_go_gen.cue @@ -9,7 +9,12 @@ package runtime Decoder: #Decoder } +_#noopEncoderIdentifier: #Identifier & "noop" + // NoopDecoder converts an Encoder to a Serializer or Codec for code that expects them but only uses encoding. #NoopDecoder: { Encoder: #Encoder } + +_#internalGroupVersionerIdentifier: "internal" +_#disabledGroupVersionerIdentifier: "disabled" diff --git a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/watch/mux_go_gen.cue b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/watch/mux_go_gen.cue index 46d1c8965..5c52678c1 100644 --- a/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/watch/mux_go_gen.cue +++ b/doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/watch/mux_go_gen.cue @@ -14,3 +14,7 @@ package watch #WaitIfChannelFull: #FullChannelBehavior & 0 #DropIfChannelFull: #FullChannelBehavior & 1 + +_#incomingQueueLength: 25 + +_#internalRunFunctionMarker: "internal-do-function"