Commit 42a5b166 authored by jennybuckley's avatar jennybuckley

run hack/godep-save.sh

parent 28cd9598
......@@ -453,7 +453,7 @@
},
{
"ImportPath": "github.com/container-storage-interface/spec/lib/go/csi/v0",
"Comment": "v0.1.0-5-g7ab01a9",
"Comment": "v0.1.0-19-g31c1670",
"Rev": "31c167062b1a62a9810e4fd94d7c986113b490b8"
},
{
......
......@@ -63,7 +63,7 @@ filegroup(
"//vendor/github.com/cockroachdb/cmux:all-srcs",
"//vendor/github.com/codedellemc/goscaleio:all-srcs",
"//vendor/github.com/codegangsta/negroni:all-srcs",
"//vendor/github.com/container-storage-interface/spec/lib/go/csi:all-srcs",
"//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:all-srcs",
"//vendor/github.com/containerd/console:all-srcs",
"//vendor/github.com/containerd/containerd/api/services/containers/v1:all-srcs",
"//vendor/github.com/containerd/containerd/api/services/tasks/v1:all-srcs",
......
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
......@@ -23,6 +23,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strconv"
"strings"
......@@ -40,10 +41,11 @@ import (
// before calling AddFlags.
func Default() *GeneratorArgs {
return &GeneratorArgs{
OutputBase: DefaultSourceTree(),
GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/gengo/boilerplate/boilerplate.go.txt"),
GeneratedBuildTag: "ignore_autogenerated",
defaultCommandLineFlags: true,
OutputBase: DefaultSourceTree(),
GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/gengo/boilerplate/boilerplate.go.txt"),
GeneratedBuildTag: "ignore_autogenerated",
GeneratedByCommentTemplate: "// Code generated by GENERATOR_NAME. DO NOT EDIT.",
defaultCommandLineFlags: true,
}
}
......@@ -64,6 +66,11 @@ type GeneratorArgs struct {
// Where to get copyright header text.
GoHeaderFilePath string
// If GeneratedByCommentTemplate is set, generate a "Code generated by" comment
// below the bloilerplate, of the format defined by this string.
// Any instances of "GENERATOR_NAME" will be replaced with the name of the code generator.
GeneratedByCommentTemplate string
// If true, only verify, don't write anything.
VerifyOnly bool
......@@ -103,6 +110,16 @@ func (g *GeneratorArgs) LoadGoBoilerplate() ([]byte, error) {
return nil, err
}
b = bytes.Replace(b, []byte("YEAR"), []byte(strconv.Itoa(time.Now().Year())), -1)
if g.GeneratedByCommentTemplate != "" {
if len(b) != 0 {
b = append(b, byte('\n'))
}
generatorName := path.Base(os.Args[0])
generatedByComment := strings.Replace(g.GeneratedByCommentTemplate, "GENERATOR_NAME", generatorName, -1)
s := fmt.Sprintf("%s\n\n", generatedByComment)
b = append(b, []byte(s)...)
}
return b, nil
}
......
......@@ -203,11 +203,6 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
packages := generator.Packages{}
header := append([]byte(fmt.Sprintf("// +build !%s\n\n", arguments.GeneratedBuildTag)), boilerplate...)
header = append(header, []byte(
`
// This file was autogenerated by defaulter-gen. Do not edit it manually!
`)...)
// Accumulate pre-existing default functions.
// TODO: This is too ad-hoc. We need a better way.
......@@ -470,6 +465,9 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
case types.Slice, types.Array:
if child := c.build(t.Elem, false); child != nil {
child.index = true
if t.Elem.Kind == types.Pointer {
child.elem = true
}
parent.children = append(parent.children, *child)
}
case types.Map:
......@@ -748,7 +746,7 @@ func (n *callNode) WriteMethod(varName string, depth int, ancestors []*callNode,
"var": varName,
}
isPointer := n.elem
isPointer := n.elem && !n.index
if isPointer && len(ancestors) > 0 {
sw.Do("if $.var$ != nil {\n", vars)
}
......@@ -756,7 +754,12 @@ func (n *callNode) WriteMethod(varName string, depth int, ancestors []*callNode,
switch {
case n.index:
sw.Do("for $.index$ := range $.var$ {\n", vars)
sw.Do("$.local$ := &$.var$[$.index$]\n", vars)
if n.elem {
sw.Do("$.local$ := $.var$[$.index$]\n", vars)
} else {
sw.Do("$.local$ := &$.var$[$.index$]\n", vars)
}
n.writeCalls(local, true, sw)
for i := range n.children {
n.children[i].WriteMethod(local, depth+1, append(ancestors, n), sw)
......
......@@ -53,11 +53,7 @@ func Packages(_ *generator.Context, arguments *args.GeneratorArgs) generator.Pac
return generator.Packages{&generator.DefaultPackage{
PackageName: "sets",
PackagePath: arguments.OutputPackagePath,
HeaderText: append(boilerplate, []byte(
`
// This file was autogenerated by set-gen. Do not edit it manually!
`)...),
HeaderText: boilerplate,
PackageDocumentation: []byte(
`// Package sets has auto-generated set types.
`),
......
/*
Copyright 2017 The Kubernetes Authors.
Copyright 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.
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by set-gen. Do not edit it manually!
// Code generated by set-gen. DO NOT EDIT.
package sets
......
/*
Copyright 2017 The Kubernetes Authors.
Copyright 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.
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by set-gen. Do not edit it manually!
// Code generated by set-gen. DO NOT EDIT.
// Package sets has auto-generated set types.
package sets
/*
Copyright 2017 The Kubernetes Authors.
Copyright 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.
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by set-gen. Do not edit it manually!
// Code generated by set-gen. DO NOT EDIT.
package sets
......
/*
Copyright 2017 The Kubernetes Authors.
Copyright 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.
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by set-gen. Do not edit it manually!
// Code generated by set-gen. DO NOT EDIT.
package sets
......
/*
Copyright 2017 The Kubernetes Authors.
Copyright 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.
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by set-gen. Do not edit it manually!
// Code generated by set-gen. DO NOT EDIT.
package sets
......
/*
Copyright 2017 The Kubernetes Authors.
Copyright 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.
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by set-gen. Do not edit it manually!
// Code generated by set-gen. DO NOT EDIT.
package sets
......
......@@ -22,6 +22,8 @@ import (
"k8s.io/gengo/types"
)
var consonants = "bcdfghjklmnpqrsttvwxyz"
type pluralNamer struct {
// key is the case-sensitive type name, value is the case-insensitive
// intended output.
......@@ -56,13 +58,63 @@ func (r *pluralNamer) Name(t *types.Type) string {
if plural, ok = r.exceptions[singular]; ok {
return r.finalize(plural)
}
switch string(singular[len(singular)-1]) {
case "s", "x":
plural = singular + "es"
case "y":
plural = singular[:len(singular)-1] + "ies"
if len(singular) < 2 {
return r.finalize(plural)
}
switch rune(singular[len(singular)-1]) {
case 's', 'x', 'z':
plural = esPlural(singular)
case 'y':
sl := rune(singular[len(singular)-2])
if isConsonant(sl) {
plural = iesPlural(singular)
} else {
plural = sPlural(singular)
}
case 'h':
sl := rune(singular[len(singular)-2])
if sl == 'c' || sl == 's' {
plural = esPlural(singular)
} else {
plural = sPlural(singular)
}
case 'e':
sl := rune(singular[len(singular)-2])
if sl == 'f' {
plural = vesPlural(singular[:len(singular)-1])
} else {
plural = sPlural(singular)
}
case 'f':
plural = vesPlural(singular)
default:
plural = singular + "s"
plural = sPlural(singular)
}
return r.finalize(plural)
}
func iesPlural(singular string) string {
return singular[:len(singular)-1] + "ies"
}
func vesPlural(singular string) string {
return singular[:len(singular)-1] + "ves"
}
func esPlural(singular string) string {
return singular + "es"
}
func sPlural(singular string) string {
return singular + "s"
}
func isConsonant(char rune) bool {
for _, c := range consonants {
if char == c {
return true
}
}
return false
}
......@@ -578,7 +578,7 @@ func splitLines(str string) []string {
}
func tcFuncNameToName(in string) types.Name {
name := strings.TrimLeft(in, "func ")
name := strings.TrimPrefix(in, "func ")
nameParts := strings.Split(name, "(")
return tcNameToName(nameParts[0])
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment