Skip to content

Generators for workspace-aware clientsets, informers, and listers

License

fgiloux/code-generator

 
 

Repository files navigation

Wrappers for clients generated using code-gen

Usage:

code-generator <command> [input-flags]

where <command> can be one of:

  • client
  • lister
  • informer

It is possible to run the code generation for multiple components at once code-generator client,lister,informer [input-flags]

Input flags:

  1. --input-dir - The directory path where APIs are defined. Make sure that the types are defined in <inputDir>/pkg/apis/{$GROUP}/{$VERSION}. For example, if your input apis are defined in types.go inside examples/pkg/apis/apps/v1/types.go, the input directory should be specified as examples/pkg. {$GROUP}/{$VERSION} is appended in the input path. Note: This is the relative path to the input directory where APIs live.

  2. --output-dir - The directory where output clients are to be generated. It defaults to the clientset folder under current working directory.

    • Clientset wrappers would be generated inside <outputDir>/<clientset-name>/clientset.go.
    • Individual typed client wrappers would be inside <outputDir>/<clientset-name>/${GROUP}/${VERSION}/${group_version}.go.
  3. --clientset-api-path - The path to where clientset generated by k8s.io/code-gen is present.

  4. --clientset-name - The name of the generated clientset package. It defaults to clientset.

  5. --group-versions - List of group versions in the format group:version. Define multiple groups by specifying the flag again. For example, the inputs can be:

    • --group-version="apps:v1"
    • --group-versions="rbac:v1" --group-versions="apps:v1"
    • --group-version="rbac:v1,v2"
  6. --go-header-file - Path to the header file.

Example: To run it locally and see how it works, use the following command:

mkdir -p testdata/pkg
go run main.go client,lister,informer --clientset-name clusterclient --go-header-file examples/header.txt \
                      --clientset-api-path=github.com/kcp-dev/code-generator/examples/pkg/generated/clientset/versioned \
                      --input-dir examples/pkg/apis \
                      --output-dir testdata/pkg --group-versions example:v1

will create output folders in testdata/pkg.

About

Generators for workspace-aware clientsets, informers, and listers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 94.7%
  • Makefile 3.7%
  • Shell 1.6%