mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +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 = [
|
srcs = [
|
||||||
"cmd_test.go",
|
"cmd_test.go",
|
||||||
"namer_test.go",
|
"namer_test.go",
|
||||||
|
"parser_test.go",
|
||||||
],
|
],
|
||||||
embed = [":go_default_library"],
|
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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -21,12 +21,33 @@ import (
|
|||||||
"testing"
|
"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) {
|
func TestProtoParser(t *testing.T) {
|
||||||
ident := ast.NewIdent("FieldName")
|
ident := ast.NewIdent("FieldName")
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
expr ast.Expr
|
expr ast.Expr
|
||||||
err bool
|
err bool
|
||||||
}{
|
}{
|
||||||
|
// valid struct field expressions
|
||||||
{
|
{
|
||||||
expr: ident,
|
expr: ident,
|
||||||
err: false,
|
err: false,
|
||||||
@ -60,6 +81,7 @@ func TestProtoParser(t *testing.T) {
|
|||||||
err: false,
|
err: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// something else should provide an error
|
||||||
{
|
{
|
||||||
expr: &ast.KeyValueExpr{
|
expr: &ast.KeyValueExpr{
|
||||||
Key: ident,
|
Key: ident,
|
||||||
|
Loading…
Reference in New Issue
Block a user