Exemplo n.º 1
0
func main() {
	customArgs := &generators.CustomArgs{
		VersionedClientSetPackage: "k8s.io/kubernetes/pkg/client/clientset_generated/clientset",
		InternalClientSetPackage:  "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset",
		ListersPackage:            "k8s.io/kubernetes/pkg/client/listers",
	}
	arguments := &args.GeneratorArgs{
		OutputBase:        args.DefaultSourceTree(),
		GoHeaderFilePath:  filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt"),
		GeneratedBuildTag: "ignore_autogenerated",
		OutputPackagePath: "k8s.io/kubernetes/pkg/client/informers/informers_generated",
		CustomArgs:        customArgs,
	}
	arguments.AddFlags(pflag.CommandLine)
	customArgs.AddFlags(pflag.CommandLine)

	// Run it.
	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
	glog.V(2).Info("Completed successfully.")
}
Exemplo n.º 2
0
func New() *Generator {
	sourceTree := args.DefaultSourceTree()
	common := args.GeneratorArgs{
		OutputBase:       sourceTree,
		GoHeaderFilePath: filepath.Join(sourceTree, "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt"),
	}
	defaultProtoImport := filepath.Join(sourceTree, "k8s.io", "kubernetes", "vendor", "github.com", "gogo", "protobuf", "protobuf")
	return &Generator{
		Common:      common,
		OutputBase:  sourceTree,
		ProtoImport: []string{defaultProtoImport},
		Packages: strings.Join([]string{
			`+k8s.io/kubernetes/pkg/util/intstr`,
			`+k8s.io/kubernetes/pkg/api/resource`,
			`+k8s.io/kubernetes/pkg/runtime`,
			`+k8s.io/kubernetes/pkg/watch/versioned`,
			`k8s.io/kubernetes/pkg/api/unversioned`,
			`k8s.io/kubernetes/pkg/api/v1`,
			`k8s.io/kubernetes/pkg/apis/policy/v1beta1`,
			`k8s.io/kubernetes/pkg/apis/extensions/v1beta1`,
			`k8s.io/kubernetes/pkg/apis/autoscaling/v1`,
			`k8s.io/kubernetes/pkg/apis/authorization/v1beta1`,
			`k8s.io/kubernetes/pkg/apis/batch/v1`,
			`k8s.io/kubernetes/pkg/apis/batch/v2alpha1`,
			`k8s.io/kubernetes/pkg/apis/apps/v1beta1`,
			`k8s.io/kubernetes/pkg/apis/authentication/v1beta1`,
			`k8s.io/kubernetes/pkg/apis/rbac/v1alpha1`,
			`k8s.io/kubernetes/federation/apis/federation/v1beta1`,
			`k8s.io/kubernetes/pkg/apis/certificates/v1alpha1`,
			`k8s.io/kubernetes/pkg/apis/imagepolicy/v1alpha1`,
			`k8s.io/kubernetes/pkg/apis/storage/v1beta1`,
		}, ","),
		DropEmbeddedFields: "k8s.io/kubernetes/pkg/api/unversioned.TypeMeta",
	}
}
Exemplo n.º 3
0
func main() {
	arguments := args.Default()

	// Override defaults.
	arguments.OutputFileBaseName = "conversion_generated"
	arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt")

	// Custom args.
	customArgs := &generators.CustomArgs{
		ExtraPeerDirs: []string{
			"k8s.io/kubernetes/pkg/api",
			"k8s.io/kubernetes/pkg/api/v1",
			"k8s.io/kubernetes/pkg/api/unversioned",
			"k8s.io/kubernetes/pkg/conversion",
			"k8s.io/kubernetes/pkg/runtime",
		},
		SkipUnsafe: false,
	}
	pflag.CommandLine.StringSliceVar(&customArgs.ExtraPeerDirs, "extra-peer-dirs", customArgs.ExtraPeerDirs,
		"Comma-separated list of import paths which are considered, after tag-specified peers, for conversions.")
	arguments.CustomArgs = customArgs

	// Run it.
	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
	glog.V(2).Info("Completed successfully.")
}
Exemplo n.º 4
0
func main() {
	arguments := args.Default()

	// Override defaults.
	arguments.OutputFileBaseName = "openapi_generated"
	arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt")

	// Run it.
	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
	glog.V(2).Info("Completed successfully.")
}
Exemplo n.º 5
0
func init() {
	sourceTree := args.DefaultSourceTree()
	g.Common.GoHeaderFilePath = filepath.Join("hack", "boilerplate.txt")
	g.ProtoImport = []string{
		filepath.Join("vendor"),
		filepath.Join("vendor", "k8s.io", "kubernetes", "third_party", "protobuf"),
	}
	g.OutputBase = sourceTree

	var fullPackageList []string

	if len(g.Packages) > 0 {
		// start with the predefined package list from kube's command
		kubePackages := strings.Split(g.Packages, ",")
		fullPackageList = make([]string, 0, len(kubePackages))
		for _, kubePackage := range kubePackages {
			// strip off the leading + if it exists because we want all kube packages to be prefixed with -
			// so they're not generated
			if strings.HasPrefix(kubePackage, "+") {
				kubePackage = kubePackage[1:]
			}
			fullPackageList = append(fullPackageList, "-"+kubePackage)
		}
	}

	// add the origin packages
	fullPackageList = append(fullPackageList,
		`github.com/openshift/origin/pkg/authorization/api/v1`,
		`github.com/openshift/origin/pkg/build/api/v1`,
		`github.com/openshift/origin/pkg/deploy/api/v1`,
		`github.com/openshift/origin/pkg/image/api/v1`,
		`github.com/openshift/origin/pkg/oauth/api/v1`,
		`github.com/openshift/origin/pkg/project/api/v1`,
		`github.com/openshift/origin/pkg/quota/api/v1`,
		`github.com/openshift/origin/pkg/route/api/v1`,
		`github.com/openshift/origin/pkg/sdn/api/v1`,
		`github.com/openshift/origin/pkg/security/api/v1`,
		`github.com/openshift/origin/pkg/template/api/v1`,
		`github.com/openshift/origin/pkg/user/api/v1`,
	)
	g.Packages = strings.Join(fullPackageList, ",")

	g.BindFlags(flag.CommandLine)
}
Exemplo n.º 6
0
func main() {
	arguments := &args.GeneratorArgs{
		OutputBase:        args.DefaultSourceTree(),
		GoHeaderFilePath:  "hack/boilerplate.txt",
		GeneratedBuildTag: "ignore_autogenerated_openshift",
		OutputPackagePath: "github.com/openshift/origin/pkg/client/listers",
	}
	arguments.AddFlags(pflag.CommandLine)

	// Run it.
	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
	glog.V(2).Info("Completed successfully.")
}
Exemplo n.º 7
0
func main() {
	arguments := args.Default()

	// Override defaults. These are Kubernetes specific input and output
	// locations.
	arguments.InputDirs = []string{"k8s.io/kubernetes/pkg/util/sets/types"}
	arguments.OutputPackagePath = "k8s.io/kubernetes/pkg/util/sets"
	arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt")

	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Errorf("Error: %v", err)
		os.Exit(1)
	}
	glog.V(2).Info("Completed successfully.")
}
Exemplo n.º 8
0
func main() {
	arguments := args.Default()

	// Override defaults.
	arguments.OutputFileBaseName = "deepcopy_generated"
	arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt")

	// Custom args.
	customArgs := &generators.CustomArgs{}
	pflag.CommandLine.StringSliceVar(&customArgs.BoundingDirs, "bounding-dirs", customArgs.BoundingDirs,
		"Comma-separated list of import paths which bound the types for which deep-copies will be generated.")
	arguments.CustomArgs = customArgs

	// Run it.
	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
	glog.V(2).Info("Completed successfully.")
}
Exemplo n.º 9
0
func main() {
	arguments := args.Default()
	arguments.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt")
	flag.Parse()
	var cmdArgs string
	flag.VisitAll(func(f *flag.Flag) {
		if !f.Changed || f.Name == "verify-only" {
			return
		}
		cmdArgs = cmdArgs + fmt.Sprintf("--%s=%s ", f.Name, f.Value)
	})

	dependencies := []string{
		"k8s.io/kubernetes/pkg/fields",
		"k8s.io/kubernetes/pkg/labels",
		"k8s.io/kubernetes/pkg/watch",
		"k8s.io/kubernetes/pkg/client/unversioned",
		"k8s.io/kubernetes/pkg/apimachinery/registered",
	}

	if *test {
		arguments.InputDirs = append(dependencies, []string{
			"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/test_apis/testgroup.k8s.io",
		}...)
		arguments.CustomArgs = clientgenargs.Args{
			GroupVersions: []unversioned.GroupVersion{{Group: "testgroup.k8s.io", Version: ""}},
			GroupVersionToInputPath: map[unversioned.GroupVersion]string{
				unversioned.GroupVersion{Group: "testgroup.k8s.io", Version: ""}: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/test_apis/testgroup.k8s.io",
			},
			ClientsetName:       "test_internalclientset",
			ClientsetOutputPath: "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
			ClientsetOnly:       false,
			FakeClient:          true,
			CmdArgs:             cmdArgs,
		}
	} else {
		inputPath, groupVersions, gvToPath, err := parseInputVersions()
		if err != nil {
			glog.Fatalf("Error: %v", err)
		}
		includedTypesOverrides, err := parseIncludedTypesOverrides()
		if err != nil {
			glog.Fatalf("Unexpected error: %v", err)
		}
		glog.Infof("going to generate clientset from these input paths: %v", inputPath)
		arguments.InputDirs = append(inputPath, dependencies...)

		arguments.CustomArgs = clientgenargs.Args{
			GroupVersions:           groupVersions,
			GroupVersionToInputPath: gvToPath,
			ClientsetName:           *clientsetName,
			ClientsetOutputPath:     *clientsetPath,
			ClientsetOnly:           *clientsetOnly,
			FakeClient:              *fakeClient,
			CmdArgs:                 cmdArgs,
			IncludedTypesOverrides:  includedTypesOverrides,
		}

		glog.Infof("==arguments: %v\n", arguments)
	}

	if err := arguments.Execute(
		generators.NameSystems(),
		generators.DefaultNameSystem(),
		generators.Packages,
	); err != nil {
		glog.Fatalf("Error: %v", err)
	}
}