Skip to content

Commit 94db2eb

Browse files
committed
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 <[email protected]>
1 parent 8a0ac3e commit 94db2eb

File tree

9 files changed

+54
-2
lines changed

9 files changed

+54
-2
lines changed

cmd/cue/cmd/get_go.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func (e *extractor) reportDecl(x *ast.GenDecl) (a []cueast.Decl) {
681681
}
682682

683683
for i, name := range v.Names {
684-
if !ast.IsExported(name.Name) {
684+
if name.Name == "_" {
685685
continue
686686
}
687687
f := e.def(v.Doc, name.Name, nil, k == 0)

cmd/cue/cmd/testdata/code/go/pkg1/file1.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ type Foozer struct {
6767
Unsupported map[int]string
6868
}
6969

70+
type Identifier string
71+
72+
const (
73+
internalIdentifier Identifier = "internal"
74+
)
75+
76+
const _ = true
77+
78+
// appease linter
79+
var _ = internalIdentifier
80+
7081
// Level gives an indication of the extent of stuff.
7182
type Level int
7283

cmd/cue/cmd/testdata/pkg/cuelang.org/go/cmd/cue/cmd/testdata/code/go/pkg1/file1_go_gen.cue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ import (
4747
} @go(,struct{CustomJSON})
4848
}
4949

50+
#Identifier: string // #enumIdentifier
51+
52+
#enumIdentifier:
53+
_#internalIdentifier
54+
55+
_#internalIdentifier: #Identifier & "internal"
56+
5057
// Level gives an indication of the extent of stuff.
5158
#Level: int // #enumLevel
5259

doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/api/core/v1/annotation_key_constants_go_gen.cue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ package v1
4848

4949
// annotation key prefix used to identify non-convertible json paths.
5050
#NonConvertibleAnnotationPrefix: "non-convertible.kubernetes.io"
51+
_#kubectlPrefix: "kubectl.kubernetes.io/"
5152

5253
// LastAppliedConfigAnnotation is the annotation used to store the previous
5354
// configuration of a resource for use in a three way diff by UpdateApplyAnnotation.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Code generated by cue get go. DO NOT EDIT.
2+
3+
//cue:generate cue get go k8s.io/apimachinery/pkg/api/resource
4+
5+
package resource
6+
7+
// maxInt64Factors is the highest value that will be checked when removing factors of 10 from an int64.
8+
// It is also the maximum decimal digits that can be represented with an int64.
9+
_#maxInt64Factors: 18
10+
11+
_#mostNegative: -9223372036854775808
12+
13+
_#mostPositive: 9223372036854775807

doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/api/resource/quantity_go_gen.cue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,9 @@ package resource
7878
#DecimalExponent: #Format & "DecimalExponent"
7979
#BinarySI: #Format & "BinarySI"
8080
#DecimalSI: #Format & "DecimalSI"
81+
82+
// splitREString is used to separate a number from its suffix; as such,
83+
// this is overly permissive, but that's OK-- it will be checked later.
84+
_#splitREString: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"
85+
86+
_#int64QuantityExpectedBytes: 18

doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/apis/meta/v1/types_go_gen.cue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ import (
858858
#CauseTypeFieldValueInvalid |
859859
#CauseTypeFieldValueNotSupported |
860860
#CauseTypeUnexpectedServerResponse |
861-
#CauseTypeFieldManagerConflict
861+
#CauseTypeFieldManagerConflict |
862+
#CauseTypeResourceVersionTooLarge
862863

863864
// CauseTypeFieldValueNotFound is used to report failure to find a requested value
864865
// (e.g. looking up an ID).
@@ -889,6 +890,10 @@ import (
889890
// It should only be returned for a request using server-side apply.
890891
#CauseTypeFieldManagerConflict: #CauseType & "FieldManagerConflict"
891892

893+
// CauseTypeResourceVersionTooLarge is used to report that the requested resource version
894+
// is newer than the data observed by the API server, so the request cannot be served.
895+
#CauseTypeResourceVersionTooLarge: #CauseType & "ResourceVersionTooLarge"
896+
892897
// List holds a list of objects, which may not be known by the server.
893898
#List: {
894899
#TypeMeta

doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/runtime/codec_go_gen.cue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ package runtime
99
Decoder: #Decoder
1010
}
1111

12+
_#noopEncoderIdentifier: #Identifier & "noop"
13+
1214
// NoopDecoder converts an Encoder to a Serializer or Codec for code that expects them but only uses encoding.
1315
#NoopDecoder: {
1416
Encoder: #Encoder
1517
}
18+
19+
_#internalGroupVersionerIdentifier: "internal"
20+
_#disabledGroupVersionerIdentifier: "disabled"

doc/tutorial/kubernetes/quick/cue.mod/gen/k8s.io/apimachinery/pkg/watch/mux_go_gen.cue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ package watch
1414

1515
#WaitIfChannelFull: #FullChannelBehavior & 0
1616
#DropIfChannelFull: #FullChannelBehavior & 1
17+
18+
_#incomingQueueLength: 25
19+
20+
_#internalRunFunctionMarker: "internal-do-function"

0 commit comments

Comments
 (0)