diff --git a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/gogo b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/gogo new file mode 100755 index 00000000000..e3a069748ff Binary files /dev/null and b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/gogo differ diff --git a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD index 529dfd022a7..23ed1f089f6 100644 --- a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD +++ b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD @@ -37,6 +37,7 @@ go_test( srcs = [ "cmd_test.go", "namer_test.go", + "parser_test.go", ], embed = [":go_default_library"], ) diff --git a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser_test.go b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser_test.go index de959974066..7fa6e23176c 100644 --- a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser_test.go +++ b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser_test.go @@ -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 + A X // regular fields + B *X // pointer fields + C // embedded type field + + // qualified embedded type fields use an in the AST + v1.TypeMeta // X=v1, Sel=TypeMeta + + // fields without a direct name, but + // a in the go-AST + *D // type field embedded as pointer + *v1.ListMeta // qualified type field embedded as pointer + // with pointing to + } +*/ + 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,