Use path instead of filepath for pkg-paths

This commit is contained in:
Tim Hockin 2024-02-28 14:38:03 -08:00
parent 70d803c1ff
commit ac5664086b
No known key found for this signature in database
18 changed files with 69 additions and 71 deletions

View File

@ -18,7 +18,7 @@ package generators
import (
"io"
"path/filepath"
"path"
"strings"
"k8s.io/gengo/v2/generator"
@ -49,7 +49,7 @@ func (g *applyConfigurationGenerator) Filter(_ *generator.Context, t *types.Type
}
func (g *applyConfigurationGenerator) Namers(*generator.Context) namer.NameSystems {
localPkg := filepath.Join(g.outPkgBase, g.groupVersion.Group.PackageName(), g.groupVersion.Version.PackageName())
localPkg := path.Join(g.outPkgBase, g.groupVersion.Group.PackageName(), g.groupVersion.Version.PackageName())
return namer.NameSystems{
"raw": namer.NewRawNamer(localPkg, g.imports),
"singularKind": namer.NewPublicNamer(0),
@ -92,7 +92,7 @@ func (g *applyConfigurationGenerator) GenerateType(c *generator.Context, t *type
Tags: genclientTags(t),
APIVersion: g.groupVersion.ToAPIVersion(),
ExtractInto: extractInto,
ParserFunc: types.Ref(filepath.Join(g.outPkgBase, "internal"), "Parser"),
ParserFunc: types.Ref(path.Join(g.outPkgBase, "internal"), "Parser"),
OpenAPIType: g.openAPIType,
}

View File

@ -161,7 +161,7 @@ func typeName(t *types.Type) string {
func targetForApplyConfigurationsPackage(outputDirBase, outputPkgBase, pkgSubdir string, boilerplate []byte, gv clientgentypes.GroupVersion, typesToGenerate []applyConfig, refs refGraph, models *typeModels) generator.Target {
outputDir := filepath.Join(outputDirBase, pkgSubdir)
outputPkg := filepath.Join(outputPkgBase, pkgSubdir)
outputPkg := path.Join(outputPkgBase, pkgSubdir)
return &generator.SimpleTarget{
PkgName: gv.Version.PackageName(),
@ -199,7 +199,7 @@ func targetForApplyConfigurationsPackage(outputDirBase, outputPkgBase, pkgSubdir
func targetForUtils(outputDirBase, outputPkgBase string, boilerplate []byte, groupVersions map[string]clientgentypes.GroupVersions, applyConfigsForGroupVersion map[clientgentypes.GroupVersion][]applyConfig, groupGoNames map[string]string) generator.Target {
return &generator.SimpleTarget{
PkgName: filepath.Base(outputPkgBase),
PkgName: path.Base(outputPkgBase),
PkgPath: outputPkgBase,
PkgDir: outputDirBase,
HeaderComment: boilerplate,
@ -221,9 +221,9 @@ func targetForUtils(outputDirBase, outputPkgBase string, boilerplate []byte, gro
func targetForInternal(outputDirBase, outputPkgBase string, boilerplate []byte, models *typeModels) generator.Target {
outputDir := filepath.Join(outputDirBase, "internal")
outputPkg := filepath.Join(outputPkgBase, "internal")
outputPkg := path.Join(outputPkgBase, "internal")
return &generator.SimpleTarget{
PkgName: filepath.Base(outputPkg),
PkgName: path.Base(outputPkg),
PkgPath: outputPkg,
PkgDir: outputDir,
HeaderComment: boilerplate,
@ -263,7 +263,7 @@ func packageTypesForInputs(context *generator.Context, outPkgBase string) map[st
// For example, if openshift/api/cloudnetwork/v1 contains an apigroup cloud.network.openshift.io, the client-gen
// builds a package called cloudnetwork/v1 to contain it. This change makes the applyconfiguration-gen use the same.
_, gvPackageString := util.ParsePathGroupVersion(p.Path)
pkg := filepath.Join(outPkgBase, strings.ToLower(gvPackageString))
pkg := path.Join(outPkgBase, strings.ToLower(gvPackageString))
pkgTypes[pkg] = p
}
return pkgTypes

View File

@ -19,6 +19,7 @@ package generators
import (
"fmt"
"path"
"path/filepath"
"strings"
@ -128,9 +129,9 @@ func DefaultNameSystem() string {
}
func targetForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetDir, clientsetPkg string, groupPkgName string, groupGoName string, apiPath string, inputPkg string, applyBuilderPkg string, boilerplate []byte) generator.Target {
subdir := filepath.Join("typed", strings.ToLower(groupPkgName), strings.ToLower(gv.Version.NonEmpty()))
gvDir := filepath.Join(clientsetDir, subdir)
gvPkg := filepath.Join(clientsetPkg, subdir)
subdir := []string{"typed", strings.ToLower(groupPkgName), strings.ToLower(gv.Version.NonEmpty())}
gvDir := filepath.Join(clientsetDir, filepath.Join(subdir...))
gvPkg := path.Join(clientsetPkg, path.Join(subdir...))
return &generator.SimpleTarget{
PkgName: strings.ToLower(gv.Version.NonEmpty()),
@ -223,7 +224,7 @@ func targetForClientset(args *args.Args, clientsetDir, clientsetPkg string, grou
func targetForScheme(args *args.Args, clientsetDir, clientsetPkg string, groupGoNames map[clientgentypes.GroupVersion]string, boilerplate []byte) generator.Target {
schemeDir := filepath.Join(clientsetDir, "scheme")
schemePkg := filepath.Join(clientsetPkg, "scheme")
schemePkg := path.Join(clientsetPkg, "scheme")
// create runtime.Registry for internal client because it has to know about group versions
internalClient := false
@ -394,7 +395,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
}
clientsetDir := filepath.Join(args.OutputDir, args.ClientsetName)
clientsetPkg := filepath.Join(args.OutputPkg, args.ClientsetName)
clientsetPkg := path.Join(args.OutputPkg, args.ClientsetName)
var targetList []generator.Target

View File

@ -17,6 +17,7 @@ limitations under the License.
package fake
import (
"path"
"path/filepath"
"strings"
@ -31,10 +32,10 @@ import (
func TargetForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetDir, clientsetPkg string, groupPkgName string, groupGoName string, inputPkg string, applyBuilderPackage string, boilerplate []byte) generator.Target {
// TODO: should make this a function, called by here and in client-generator.go
subdir := filepath.Join("typed", strings.ToLower(groupPkgName), strings.ToLower(gv.Version.NonEmpty()))
outputDir := filepath.Join(clientsetDir, subdir, "fake")
outputPkg := filepath.Join(clientsetPkg, subdir, "fake")
realClientPkg := filepath.Join(clientsetPkg, subdir)
subdir := []string{"typed", strings.ToLower(groupPkgName), strings.ToLower(gv.Version.NonEmpty())}
outputDir := filepath.Join(clientsetDir, filepath.Join(subdir...), "fake")
outputPkg := path.Join(clientsetPkg, path.Join(subdir...), "fake")
realClientPkg := path.Join(clientsetPkg, path.Join(subdir...))
return &generator.SimpleTarget{
PkgName: "fake",
@ -92,7 +93,7 @@ func TargetForClientset(args *args.Args, clientsetDir, clientsetPkg string, grou
// TODO: we'll generate fake clientset for different release in the future.
// Package name and path are hard coded for now.
PkgName: "fake",
PkgPath: filepath.Join(clientsetPkg, "fake"),
PkgPath: path.Join(clientsetPkg, "fake"),
PkgDir: filepath.Join(clientsetDir, "fake"),
HeaderComment: boilerplate,
PkgDocComment: []byte("// This package has the automatically generated fake clientset.\n"),

View File

@ -19,7 +19,7 @@ package fake
import (
"fmt"
"io"
"path/filepath"
"path"
"strings"
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
@ -59,8 +59,8 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, group := range g.groups {
for _, version := range group.Versions {
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake")
groupClientPackage := path.Join(g.fakeClientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
fakeGroupClientPackage := path.Join(groupClientPackage, "fake")
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), groupClientPackage))

View File

@ -19,7 +19,7 @@ package fake
import (
"fmt"
"io"
"path/filepath"
"path"
"strings"
"k8s.io/gengo/v2/generator"
@ -64,7 +64,7 @@ func (g *genFakeForGroup) Namers(c *generator.Context) namer.NameSystems {
func (g *genFakeForGroup) Imports(c *generator.Context) (imports []string) {
imports = g.imports.ImportLines()
if len(g.types) != 0 {
imports = append(imports, fmt.Sprintf("%s \"%s\"", strings.ToLower(filepath.Base(g.realClientPackage)), g.realClientPackage))
imports = append(imports, fmt.Sprintf("%s \"%s\"", strings.ToLower(path.Base(g.realClientPackage)), g.realClientPackage))
}
return imports
}
@ -90,7 +90,7 @@ func (g *genFakeForGroup) GenerateType(c *generator.Context, t *types.Type, w io
"type": t,
"GroupGoName": g.groupGoName,
"Version": namer.IC(g.version),
"realClientPackage": strings.ToLower(filepath.Base(g.realClientPackage)),
"realClientPackage": strings.ToLower(path.Base(g.realClientPackage)),
}
if tags.NonNamespaced {
sw.Do(getterImplNonNamespaced, wrapper)

View File

@ -18,7 +18,7 @@ package fake
import (
"io"
"path/filepath"
"path"
"strings"
"k8s.io/gengo/v2/generator"
@ -86,7 +86,7 @@ func hasObjectMeta(t *types.Type) bool {
// GenerateType makes the body of a file implementing the individual typed client for type t.
func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
sw := generator.NewSnippetWriter(w, c, "$", "$")
pkg := filepath.Base(t.Name.Package)
pkg := path.Base(t.Name.Package)
tags, err := util.ParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
if err != nil {
return err
@ -152,7 +152,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
if generateApply {
// Generated apply builder type references required for generated Apply function
_, gvString := util.ParsePathGroupVersion(g.inputPackage)
m["inputApplyConfig"] = types.Ref(filepath.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
m["inputApplyConfig"] = types.Ref(path.Join(g.applyConfigurationPackage, gvString), t.Name.Name+"ApplyConfiguration")
}
if tags.NonNamespaced {
@ -236,7 +236,7 @@ func (g *genFakeForType) GenerateType(c *generator.Context, t *types.Type, w io.
m["resultType"] = &resultType
m["subresourcePath"] = e.SubResourcePath
if e.HasVerb("apply") {
m["inputApplyConfig"] = types.Ref(filepath.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
m["inputApplyConfig"] = types.Ref(path.Join(g.applyConfigurationPackage, inputGVString), inputType.Name.Name+"ApplyConfiguration")
}
if e.HasVerb("get") {

View File

@ -19,7 +19,7 @@ package generators
import (
"fmt"
"io"
"path/filepath"
"path"
"strings"
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
@ -57,7 +57,7 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
for _, group := range g.groups {
for _, version := range group.Versions {
typedClientPath := filepath.Join(g.clientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
typedClientPath := path.Join(g.clientsetPackage, "typed", strings.ToLower(group.PackageName), strings.ToLower(version.NonEmpty()))
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
imports = append(imports, fmt.Sprintf("%s%s \"%s\"", groupAlias, strings.ToLower(version.NonEmpty()), typedClientPath))
}

View File

@ -18,7 +18,7 @@ package generators
import (
"io"
"path/filepath"
"path"
"k8s.io/gengo/v2"
"k8s.io/gengo/v2/generator"
@ -64,7 +64,7 @@ func (g *genGroup) Namers(c *generator.Context) namer.NameSystems {
func (g *genGroup) Imports(c *generator.Context) (imports []string) {
imports = append(imports, g.imports.ImportLines()...)
imports = append(imports, filepath.Join(g.clientsetPackage, "scheme"))
imports = append(imports, path.Join(g.clientsetPackage, "scheme"))
return
}

View File

@ -19,7 +19,6 @@ package generators
import (
"io"
"path"
"path/filepath"
"strings"
"k8s.io/gengo/v2/generator"
@ -81,7 +80,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
defaultVerbTemplates := buildDefaultVerbTemplates(generateApply)
subresourceDefaultVerbTemplates := buildSubresourceDefaultVerbTemplates(generateApply)
sw := generator.NewSnippetWriter(w, c, "$", "$")
pkg := filepath.Base(t.Name.Package)
pkg := path.Base(t.Name.Package)
tags, err := util.ParseClientGenTags(append(t.SecondClosestCommentLines, t.CommentLines...))
if err != nil {
return err
@ -171,7 +170,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
"ApplyPatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "ApplyPatchType"}),
"watchInterface": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/watch", Name: "Interface"}),
"RESTClientInterface": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Interface"}),
"schemeParameterCodec": c.Universe.Variable(types.Name{Package: filepath.Join(g.clientsetPackage, "scheme"), Name: "ParameterCodec"}),
"schemeParameterCodec": c.Universe.Variable(types.Name{Package: path.Join(g.clientsetPackage, "scheme"), Name: "ParameterCodec"}),
"jsonMarshal": c.Universe.Type(types.Name{Package: "encoding/json", Name: "Marshal"}),
}

View File

@ -20,6 +20,7 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"strings"
@ -65,9 +66,9 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) {
if g.CreateRegistry {
// import the install package for internal clientsets instead of the type package with register.go
if version.Version != "" {
packagePath = filepath.Dir(packagePath)
packagePath = path.Dir(packagePath)
}
packagePath = filepath.Join(packagePath, "install")
packagePath = path.Join(packagePath, "install")
imports = append(imports, fmt.Sprintf("%s \"%s\"", groupAlias, packagePath))
break

View File

@ -20,7 +20,7 @@ import (
"bytes"
"fmt"
"io"
"path/filepath"
"path"
"reflect"
"sort"
"strings"
@ -319,7 +319,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
targets = append(targets,
&generator.SimpleTarget{
PkgName: filepath.Base(pkg.Path),
PkgName: path.Base(pkg.Path),
PkgPath: pkg.Path,
PkgDir: pkg.Dir, // output pkg is the same as the input
HeaderComment: boilerplate,

View File

@ -19,7 +19,7 @@ package generators
import (
"fmt"
"io"
"path/filepath"
"path"
"sort"
"strings"
@ -184,7 +184,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
klog.V(3).Infof("Package %q needs generation", i)
targets = append(targets,
&generator.SimpleTarget{
PkgName: strings.Split(filepath.Base(pkg.Path), ".")[0],
PkgName: strings.Split(path.Base(pkg.Path), ".")[0],
PkgPath: pkg.Path,
PkgDir: pkg.Dir, // output pkg is the same as the input
HeaderComment: boilerplate,

View File

@ -21,7 +21,7 @@ import (
"encoding/json"
"fmt"
"io"
"path/filepath"
"path"
"reflect"
"regexp"
"strconv"
@ -256,7 +256,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
// this is a relative dir, which will not work under gomodules.
// join with the local package path, but warn
klog.Warningf("relative path %s=%s will not work under gomodule mode; use full package path (as used by 'import') instead", inputTagName, inputPath)
inputPath = filepath.Join(pkg.Path, inputTags[0])
inputPath = path.Join(pkg.Path, inputTags[0])
}
klog.V(5).Infof(" input pkg %v", inputPath)
@ -409,7 +409,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
targets = append(targets,
&generator.SimpleTarget{
PkgName: filepath.Base(pkg.Path),
PkgName: path.Base(pkg.Path),
PkgPath: pkg.Path,
PkgDir: pkg.Dir, // output pkg is the same as the input
HeaderComment: boilerplate,

View File

@ -18,7 +18,7 @@ package generators
import (
"io"
"path/filepath"
"path"
"strings"
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
@ -70,7 +70,7 @@ func (g *groupInterfaceGenerator) GenerateType(c *generator.Context, t *types.Ty
versions := make([]versionData, 0, len(g.groupVersions.Versions))
for _, version := range g.groupVersions.Versions {
gv := clientgentypes.GroupVersion{Group: g.groupVersions.Group, Version: version.Version}
versionPackage := filepath.Join(g.outputPackage, strings.ToLower(gv.Version.NonEmpty()))
versionPackage := path.Join(g.outputPackage, strings.ToLower(gv.Version.NonEmpty()))
iface := c.Universe.Type(types.Name{Package: versionPackage, Name: "Interface"})
versions = append(versions, versionData{
Name: namer.IC(version.Version.NonEmpty()),

View File

@ -84,12 +84,7 @@ func isInternal(m types.Member) bool {
return !strings.Contains(m.Tags, "json")
}
// subdirForInternalInterfaces returns a string which is a subdir of the
// provided base, which can be a Go import-path or a directory path, depending
// on what the caller needs.
func subdirForInternalInterfaces(base string) string {
return filepath.Join(base, "internalinterfaces")
}
const subdirForInternalInterfaces = "internalinterfaces"
// GetTargets makes the client target definition.
func GetTargets(context *generator.Context, args *args.Args) []generator.Target {
@ -104,9 +99,9 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
externalVersionOutputPkg := args.OutputPkg
if !args.SingleDirectory {
internalVersionOutputDir = filepath.Join(internalVersionOutputDir, "internalversion")
internalVersionOutputPkg = filepath.Join(internalVersionOutputPkg, "internalversion")
internalVersionOutputPkg = path.Join(internalVersionOutputPkg, "internalversion")
externalVersionOutputDir = filepath.Join(externalVersionOutputDir, "externalversions")
externalVersionOutputPkg = filepath.Join(externalVersionOutputPkg, "externalversions")
externalVersionOutputPkg = path.Join(externalVersionOutputPkg, "externalversions")
}
var targetList []generator.Target
@ -244,7 +239,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
func factoryTarget(outputDirBase, outputPkgBase string, boilerplate []byte, groupGoNames, pluralExceptions map[string]string, groupVersions map[string]clientgentypes.GroupVersions, clientSetPackage string,
typesForGroupVersion map[clientgentypes.GroupVersion][]*types.Type) generator.Target {
return &generator.SimpleTarget{
PkgName: filepath.Base(outputDirBase),
PkgName: path.Base(outputDirBase),
PkgPath: outputPkgBase,
PkgDir: outputDirBase,
HeaderComment: boilerplate,
@ -257,7 +252,7 @@ func factoryTarget(outputDirBase, outputPkgBase string, boilerplate []byte, grou
imports: generator.NewImportTracker(),
groupVersions: groupVersions,
clientSetPackage: clientSetPackage,
internalInterfacesPackage: subdirForInternalInterfaces(outputPkgBase),
internalInterfacesPackage: path.Join(outputPkgBase, subdirForInternalInterfaces),
gvGoNames: groupGoNames,
})
@ -279,11 +274,11 @@ func factoryTarget(outputDirBase, outputPkgBase string, boilerplate []byte, grou
}
func factoryInterfaceTarget(outputDirBase, outputPkgBase string, boilerplate []byte, clientSetPackage string) generator.Target {
outputDir := subdirForInternalInterfaces(outputDirBase)
outputPkg := subdirForInternalInterfaces(outputPkgBase)
outputDir := filepath.Join(outputDirBase, subdirForInternalInterfaces)
outputPkg := path.Join(outputPkgBase, subdirForInternalInterfaces)
return &generator.SimpleTarget{
PkgName: filepath.Base(outputDir),
PkgName: path.Base(outputDir),
PkgPath: outputPkg,
PkgDir: outputDir,
HeaderComment: boilerplate,
@ -304,7 +299,7 @@ func factoryInterfaceTarget(outputDirBase, outputPkgBase string, boilerplate []b
func groupTarget(outputDirBase, outputPackageBase string, groupVersions clientgentypes.GroupVersions, boilerplate []byte) generator.Target {
outputDir := filepath.Join(outputDirBase, groupVersions.PackageName)
outputPkg := filepath.Join(outputPackageBase, groupVersions.PackageName)
outputPkg := path.Join(outputPackageBase, groupVersions.PackageName)
groupPkgName := strings.Split(string(groupVersions.PackageName), ".")[0]
return &generator.SimpleTarget{
@ -320,7 +315,7 @@ func groupTarget(outputDirBase, outputPackageBase string, groupVersions clientge
outputPackage: outputPkg,
groupVersions: groupVersions,
imports: generator.NewImportTracker(),
internalInterfacesPackage: subdirForInternalInterfaces(outputPackageBase),
internalInterfacesPackage: path.Join(outputPackageBase, subdirForInternalInterfaces),
})
return generators
},
@ -332,9 +327,9 @@ func groupTarget(outputDirBase, outputPackageBase string, groupVersions clientge
}
func versionTarget(outputDirBase, outputPkgBase string, groupPkgName string, gv clientgentypes.GroupVersion, groupGoName string, boilerplate []byte, typesToGenerate []*types.Type, clientSetPackage, listersPackage string) generator.Target {
subdir := filepath.Join(groupPkgName, strings.ToLower(gv.Version.NonEmpty()))
outputDir := filepath.Join(outputDirBase, subdir)
outputPkg := filepath.Join(outputPkgBase, subdir)
subdir := []string{groupPkgName, strings.ToLower(gv.Version.NonEmpty())}
outputDir := filepath.Join(outputDirBase, filepath.Join(subdir...))
outputPkg := path.Join(outputPkgBase, path.Join(subdir...))
return &generator.SimpleTarget{
PkgName: strings.ToLower(gv.Version.NonEmpty()),
@ -349,7 +344,7 @@ func versionTarget(outputDirBase, outputPkgBase string, groupPkgName string, gv
outputPackage: outputPkg,
imports: generator.NewImportTracker(),
types: typesToGenerate,
internalInterfacesPackage: subdirForInternalInterfaces(outputPkgBase),
internalInterfacesPackage: path.Join(outputPkgBase, subdirForInternalInterfaces),
})
for _, t := range typesToGenerate {
@ -365,7 +360,7 @@ func versionTarget(outputDirBase, outputPkgBase string, groupPkgName string, gv
imports: generator.NewImportTracker(),
clientSetPackage: clientSetPackage,
listersPackage: listersPackage,
internalInterfacesPackage: subdirForInternalInterfaces(outputPkgBase),
internalInterfacesPackage: path.Join(outputPkgBase, subdirForInternalInterfaces),
})
}
return generators

View File

@ -19,6 +19,7 @@ package generators
import (
"fmt"
"io"
"path"
"path/filepath"
"strings"
@ -118,9 +119,9 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
orderer := namer.Orderer{Namer: namer.NewPrivateNamer(0)}
typesToGenerate = orderer.OrderTypes(typesToGenerate)
subdir := filepath.Join(groupPackageName, strings.ToLower(gv.Version.NonEmpty()))
outputDir := filepath.Join(args.OutputDir, subdir)
outputPkg := filepath.Join(args.OutputPkg, subdir)
subdir := []string{groupPackageName, strings.ToLower(gv.Version.NonEmpty())}
outputDir := filepath.Join(args.OutputDir, filepath.Join(subdir...))
outputPkg := path.Join(args.OutputPkg, path.Join(subdir...))
targetList = append(targetList, &generator.SimpleTarget{
PkgName: strings.ToLower(gv.Version.NonEmpty()),
PkgPath: outputPkg,

View File

@ -19,7 +19,7 @@ package prereleaselifecyclegenerators
import (
"fmt"
"io"
"path/filepath"
"path"
"strconv"
"strings"
@ -225,7 +225,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
if pkgNeedsGeneration {
targets = append(targets,
&generator.SimpleTarget{
PkgName: strings.Split(filepath.Base(pkg.Path), ".")[0],
PkgName: strings.Split(path.Base(pkg.Path), ".")[0],
PkgPath: pkg.Path,
PkgDir: pkg.Dir, // output pkg is the same as the input
HeaderComment: boilerplate,