mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
add docu + fix copyright year
This commit is contained in:
parent
3c9831d18d
commit
52063cab17
BIN
staging/src/k8s.io/code-generator/cmd/go-to-protobuf/gogo
Executable file
BIN
staging/src/k8s.io/code-generator/cmd/go-to-protobuf/gogo
Executable file
Binary file not shown.
@ -37,6 +37,7 @@ go_test(
|
||||
srcs = [
|
||||
"cmd_test.go",
|
||||
"namer_test.go",
|
||||
"parser_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
Copyright 2020 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -21,12 +21,33 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
/*
|
||||
struct fields in go AST:
|
||||
|
||||
type Struct struct {
|
||||
// fields with a direct field Name as <Ident>
|
||||
A X // regular fields
|
||||
B *X // pointer fields
|
||||
C // embedded type field
|
||||
|
||||
// qualified embedded type fields use an <SelExpr> in the AST
|
||||
v1.TypeMeta // X=v1, Sel=TypeMeta
|
||||
|
||||
// fields without a direct name, but
|
||||
// a <StarExpr> in the go-AST
|
||||
*D // type field embedded as pointer
|
||||
*v1.ListMeta // qualified type field embedded as pointer
|
||||
// with <StarExpr> pointing to <SelExpr>
|
||||
}
|
||||
*/
|
||||
|
||||
func TestProtoParser(t *testing.T) {
|
||||
ident := ast.NewIdent("FieldName")
|
||||
tests := []struct {
|
||||
expr ast.Expr
|
||||
err bool
|
||||
}{
|
||||
// valid struct field expressions
|
||||
{
|
||||
expr: ident,
|
||||
err: false,
|
||||
@ -60,6 +81,7 @@ func TestProtoParser(t *testing.T) {
|
||||
err: false,
|
||||
},
|
||||
|
||||
// something else should provide an error
|
||||
{
|
||||
expr: &ast.KeyValueExpr{
|
||||
Key: ident,
|
||||
|
Loading…
Reference in New Issue
Block a user