Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cmd/cue/cmd: include unexported constants for get go
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mpvl committed Jul 18, 2020
1 parent 8a0ac3e commit 94db2eb
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/get_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions cmd/cue/cmd/testdata/code/go/pkg1/file1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ package watch

#WaitIfChannelFull: #FullChannelBehavior & 0
#DropIfChannelFull: #FullChannelBehavior & 1

_#incomingQueueLength: 25

_#internalRunFunctionMarker: "internal-do-function"

0 comments on commit 94db2eb

Please sign in to comment.