Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable 20160510 #19

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
359a5ee
UPSTREAM: <carry>: remove types.generated.go
liggitt Mar 10, 2016
3d7a573
UPSTREAM: <carry>: Disable UIs for Kubernetes and etcd
deads2k Aug 11, 2015
2fbabb2
UPSTREAM: <carry>: Back n forth downward/metadata conversions
deads2k Oct 16, 2015
ad4d268
UPSTREAM: <carry>: SCC
deads2k Oct 16, 2015
c12d229
UPSTREAM: <carry>: Add deprecated fields to migrate 1.0.0 k8s v1 data
liggitt Jan 23, 2016
8372e36
UPSTREAM: <carry>: reallow the ability to post across namespaces in api
pweil- Aug 11, 2015
10fc1ea
UPSTREAM: <carry>: update describer for dockercfg secrets
deads2k Aug 11, 2015
6df8081
UPSTREAM: <carry>: support pointing oc exec to old openshift server
deads2k Aug 11, 2015
0488611
UPSTREAM: <carry>: v1beta3
deads2k Aug 11, 2015
a3941ff
UPSTREAM: <carry>: add kubelet timeouts
soltysh Dec 21, 2015
9e96666
UPSTREAM: <carry>: OpenShift 3.0.2 nodes report v1.1.0-alpha
smarterclayton Oct 30, 2015
66979f3
UPSTREAM: <carry>: Tolerate node ExternalID changes with no cloud pro…
DirectXMan12 Jan 12, 2016
6ad3145
UPSTREAM: <carry>: allow hostDNS to be included along with ClusterDNS…
soltysh Jan 25, 2016
835a73f
UPSTREAM: <carry>: Add our types to kubectl get error
smarterclayton Oct 11, 2015
aa82707
UPSTREAM: <carry>: Allow overriding default generators for run
liggitt Mar 16, 2016
f409136
UPSTREAM: <carry>: Suppress aggressive output of warning
smarterclayton Mar 23, 2016
fe78904
UPSTREAM: <carry>: force import ordering for stable codegen
deads2k Apr 29, 2016
25ea395
UPSTREAM: <drop>: merge multiple registrations for the same group
deads2k Feb 1, 2016
cf5ce56
UPSTREAM: <drop>: make etcd error determination support old client un…
deads2k Feb 5, 2016
a10b2c6
UPSTREAM: 16146: Fix validate event for non-namespaced kinds
feihujiang Oct 23, 2015
0a715bc
UPSTREAM: 20847: Force a dependency order between extensions and api
smarterclayton Feb 8, 2016
82bf818
UPSTREAM: 22919: Allow starting test etcd with http
liggitt Mar 13, 2016
97b3462
UPSTREAM: 22857: partial - ensure DetermineEffectiveSC retains the co…
pweil- Mar 10, 2016
b026808
UPSTREAM: 24153: make optional generic etcd fields optional
mfojtik May 11, 2016
2e2dc0b
UPSTREAM: 24052: Rate limiting requeue
deads2k Apr 27, 2016
2a70426
UPSTREAM: 24128: Allow cluster DNS verification to be overriden
smarterclayton Apr 12, 2016
0fa7bce
UPSTREAM: 25033: Make conversion gen downstream consumable
smarterclayton May 2, 2016
9d765d5
UPSTREAM: 25018: Don't convert objects in the destination version
smarterclayton May 2, 2016
a7e0622
UPSTREAM: 25369: Return 'too old' errors from watch cache via watch s…
liggitt May 9, 2016
1b69434
UPSTREAM: 25472: tolerate nil error in HandleError
deads2k May 11, 2016
fd4da8f
UPSTREAM: 25501: SplitHostPort is needed since Request.RemoteAddr has…
soltysh May 11, 2016
18634cd
UPSTREAM: 25537: e2e make ForEach fail if filter is empty, fix no-op …
derekwaynecarr May 12, 2016
5bae608
UPSTREAM: 25617: Rolling updater should indicate progress
smarterclayton May 8, 2016
f045508
UPSTREAM: 25690: Fixes panic on round tripper when TLS under a proxy
fabianofranz May 16, 2016
e8e6343
UPSTREAM: 25898: make admission plugins configurable based on externa…
deads2k May 19, 2016
1af96fc
UPSTREAM: 23858: Convert service account token controller to use a wo…
liggitt May 23, 2016
12a3be3
UPSTREAM: 25907: Fix detection of docker cgroup on RHEL
May 19, 2016
03e0cb8
UPSTREAM: 25161: Sort resources in quota errors to avoid duplicate ev…
derekwaynecarr May 4, 2016
06f64d5
UPSTREAM: 25487: pod constraints func for quota validates resources
derekwaynecarr May 11, 2016
25d7681
UPSTREAM: <carry>: add service serving cert signer to token controller
deads2k May 26, 2016
0222880
UPSTREAM: 25804: Add batch into clientset_adaption
mfojtik May 18, 2016
3da9799
UPSTREAM: 21373: kubelet: reading cloudinfo from cadvisor
Feb 14, 2016
6289f86
UPSTREAM: 25671: make addIndexers safe for sharedInformer
deads2k May 2, 2016
e21dc74
UPSTREAM: 25669: prevent nil pointer when starting controllers before…
deads2k May 16, 2016
93138ef
UPSTREAM: 26793: expose printer utils
fabianofranz Jun 3, 2016
d9306de
UPSTREAM: 26554: kubectl: make --container-port actually work for expose
0xmichalis Jun 9, 2016
686fe38
UPSTREAM: <drop>: Generated files
liggitt Jun 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
UPSTREAM: 25033: Make conversion gen downstream consumable
  • Loading branch information
smarterclayton authored and liggitt committed Jun 9, 2016
commit 0fa7bcea17f3abbe50401bc00c5cbd957d923091
50 changes: 27 additions & 23 deletions cmd/libs/go2idl/conversion-gen/generators/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ type genConversion struct {
defaulters defaulters
imports namer.ImportTracker
typesForInit []conversionType

globalVariables map[string]interface{}
}

func NewGenConversion(sanitizedName, targetPackage string, preexisting conversions, defaulters defaulters) generator.Generator {
Expand Down Expand Up @@ -459,12 +461,6 @@ func (g *genConversion) isOtherPackage(pkg string) bool {

func (g *genConversion) Imports(c *generator.Context) (imports []string) {
var importLines []string
if g.isOtherPackage(apiPackagePath) {
importLines = append(importLines, "api \""+apiPackagePath+"\"")
}
if g.isOtherPackage(conversionPackagePath) {
importLines = append(importLines, "conversion \""+conversionPackagePath+"\"")
}
for _, singleImport := range g.imports.ImportLines() {
if g.isOtherPackage(singleImport) {
importLines = append(importLines, singleImport)
Expand All @@ -473,7 +469,16 @@ func (g *genConversion) Imports(c *generator.Context) (imports []string) {
return importLines
}

func argsFromType(inType, outType *types.Type) interface{} {
func (g *genConversion) withGlobals(args map[string]interface{}) map[string]interface{} {
for k, v := range g.globalVariables {
if _, ok := args[k]; !ok {
args[k] = v
}
}
return args
}

func argsFromType(inType, outType *types.Type) map[string]interface{} {
return map[string]interface{}{
"inType": inType,
"outType": outType,
Expand All @@ -498,13 +503,20 @@ func (g *genConversion) preexists(inType, outType *types.Type) (*types.Type, boo
}

func (g *genConversion) Init(c *generator.Context, w io.Writer) error {
scheme := c.Universe.Variable(types.Name{Package: apiPackagePath, Name: "Scheme"})
g.imports.AddType(scheme)
scope := c.Universe.Type(types.Name{Package: conversionPackagePath, Name: "Scope"})
g.imports.AddType(scope)
g.globalVariables = map[string]interface{}{
"scheme": scheme,
"Scope": scope,
}

sw := generator.NewSnippetWriter(w, c, "$", "$")
sw.Do("func init() {\n", nil)
if g.targetPackage == apiPackagePath {
sw.Do("if err := Scheme.AddGeneratedConversionFuncs(\n", nil)
} else {
sw.Do("if err := api.Scheme.AddGeneratedConversionFuncs(\n", nil)
}
sw.Do("if err := $.scheme|raw$.AddGeneratedConversionFuncs(\n", map[string]interface{}{
"scheme": scheme,
})
for _, conv := range g.typesForInit {
funcName := g.funcNameTmpl(conv.inType, conv.outType)
sw.Do(fmt.Sprintf("%s,\n", funcName), argsFromType(conv.inType, conv.outType))
Expand All @@ -531,27 +543,19 @@ func (g *genConversion) GenerateType(c *generator.Context, t *types.Type, w io.W

func (g *genConversion) generateConversion(inType, outType *types.Type, sw *generator.SnippetWriter) {
funcName := g.funcNameTmpl(inType, outType)
if g.targetPackage == conversionPackagePath {
sw.Do(fmt.Sprintf("func auto%s(in *$.inType|raw$, out *$.outType|raw$, s Scope) error {\n", funcName), argsFromType(inType, outType))
} else {
sw.Do(fmt.Sprintf("func auto%s(in *$.inType|raw$, out *$.outType|raw$, s conversion.Scope) error {\n", funcName), argsFromType(inType, outType))
}

sw.Do(fmt.Sprintf("func auto%s(in *$.inType|raw$, out *$.outType|raw$, s $.Scope|raw$) error {\n", funcName), g.withGlobals(argsFromType(inType, outType)))
// if no defaulter of form SetDefaults_XXX is defined, do not inline a check for defaulting.
if function, ok := g.defaulters[inType]; ok {
sw.Do("$.|raw$(in)\n", function)
}

g.generateFor(inType, outType, sw)
sw.Do("return nil\n", nil)
sw.Do("}\n\n", nil)

// If there is no public preexisting Convert method, generate it.
if _, ok := g.preexists(inType, outType); !ok {
if g.targetPackage == conversionPackagePath {
sw.Do(fmt.Sprintf("func %s(in *$.inType|raw$, out *$.outType|raw$, s Scope) error {\n", funcName), argsFromType(inType, outType))
} else {
sw.Do(fmt.Sprintf("func %s(in *$.inType|raw$, out *$.outType|raw$, s conversion.Scope) error {\n", funcName), argsFromType(inType, outType))
}
sw.Do(fmt.Sprintf("func %s(in *$.inType|raw$, out *$.outType|raw$, s $.Scope|raw$) error {\n", funcName), g.withGlobals(argsFromType(inType, outType)))
sw.Do(fmt.Sprintf("return auto%s(in, out, s)\n", funcName), argsFromType(inType, outType))
sw.Do("}\n\n", nil)
}
Expand Down
47 changes: 26 additions & 21 deletions cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
for _, p := range context.Universe {
copyableType := false
for _, t := range p.Types {
if copyableWithinPackage(t) {
if copyableWithinPackage(t) && inputs.Has(t.Name.Package) {
copyableType = true
}
}
Expand Down Expand Up @@ -114,6 +114,8 @@ type genDeepCopy struct {
imports namer.ImportTracker
typesForInit []*types.Type
generateInitFunc bool

globalVariables map[string]interface{}
}

func NewGenDeepCopy(sanitizedName, targetPackage string, generateInitFunc bool) generator.Generator {
Expand Down Expand Up @@ -143,9 +145,6 @@ func (g *genDeepCopy) Filter(c *generator.Context, t *types.Type) bool {
}

func copyableWithinPackage(t *types.Type) bool {
if !strings.HasPrefix(t.Name.Package, "k8s.io/kubernetes/") {
return false
}
if types.ExtractCommentTags("+", t.CommentLines)["gencopy"] == "false" {
return false
}
Expand All @@ -172,12 +171,6 @@ func (g *genDeepCopy) isOtherPackage(pkg string) bool {

func (g *genDeepCopy) Imports(c *generator.Context) (imports []string) {
importLines := []string{}
if g.isOtherPackage(apiPackagePath) && g.generateInitFunc {
importLines = append(importLines, "api \""+apiPackagePath+"\"")
}
if g.isOtherPackage(conversionPackagePath) {
importLines = append(importLines, "conversion \""+conversionPackagePath+"\"")
}
for _, singleImport := range g.imports.ImportLines() {
if g.isOtherPackage(singleImport) {
importLines = append(importLines, singleImport)
Expand All @@ -186,7 +179,16 @@ func (g *genDeepCopy) Imports(c *generator.Context) (imports []string) {
return importLines
}

func argsFromType(t *types.Type) interface{} {
func (g *genDeepCopy) withGlobals(args map[string]interface{}) map[string]interface{} {
for k, v := range g.globalVariables {
if _, ok := args[k]; !ok {
args[k] = v
}
}
return args
}

func argsFromType(t *types.Type) map[string]interface{} {
return map[string]interface{}{
"type": t,
}
Expand All @@ -202,19 +204,26 @@ func (g *genDeepCopy) funcNameTmpl(t *types.Type) string {
}

func (g *genDeepCopy) Init(c *generator.Context, w io.Writer) error {
cloner := c.Universe.Type(types.Name{Package: conversionPackagePath, Name: "Cloner"})
g.imports.AddType(cloner)
g.globalVariables = map[string]interface{}{
"Cloner": cloner,
}
if !g.generateInitFunc {
// TODO: We should come up with a solution to register all generated
// deep-copy functions. However, for now, to avoid import cycles
// we register only those explicitly requested.
return nil
}
scheme := c.Universe.Variable(types.Name{Package: apiPackagePath, Name: "Scheme"})
g.imports.AddType(scheme)
g.globalVariables["scheme"] = scheme

sw := generator.NewSnippetWriter(w, c, "$", "$")
sw.Do("func init() {\n", nil)
if g.targetPackage == apiPackagePath {
sw.Do("if err := Scheme.AddGeneratedDeepCopyFuncs(\n", nil)
} else {
sw.Do("if err := api.Scheme.AddGeneratedDeepCopyFuncs(\n", nil)
}
sw.Do("if err := $.scheme|raw$.AddGeneratedDeepCopyFuncs(\n", map[string]interface{}{
"scheme": scheme,
})
for _, t := range g.typesForInit {
sw.Do(fmt.Sprintf("%s,\n", g.funcNameTmpl(t)), argsFromType(t))
}
Expand All @@ -229,11 +238,7 @@ func (g *genDeepCopy) Init(c *generator.Context, w io.Writer) error {
func (g *genDeepCopy) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
sw := generator.NewSnippetWriter(w, c, "$", "$")
funcName := g.funcNameTmpl(t)
if g.targetPackage == conversionPackagePath {
sw.Do(fmt.Sprintf("func %s(in $.type|raw$, out *$.type|raw$, c *Cloner) error {\n", funcName), argsFromType(t))
} else {
sw.Do(fmt.Sprintf("func %s(in $.type|raw$, out *$.type|raw$, c *conversion.Cloner) error {\n", funcName), argsFromType(t))
}
sw.Do(fmt.Sprintf("func %s(in $.type|raw$, out *$.type|raw$, c *$.Cloner|raw$) error {\n", funcName), g.withGlobals(argsFromType(t)))
g.generateFor(t, sw)
sw.Do("return nil\n", nil)
sw.Do("}\n\n", nil)
Expand Down
Loading