Experimental code generators for Crossplane controllers.
angryjet
is the only extant tool within crossplane-tools. It will detect Go
structs that appear to be capable of satisfying crossplane-runtime's interfaces
(such as resource.Managed
) and automatically generate the method set
required to satisfy that interface. A struct is considered capable of satisfying
crossplane-runtime's interfaces based on the heuristics described in the
Crossplane Services Developer Guide, for example a managed resource must:
- Embed a
ResourceStatus
struct in theirStatus
struct. - Embed a
ResourceSpec
struct in theirSpec
struct. - Embed a
Parameters
struct in theirSpec
struct.
Methods are not written if they are already defined outside of the file that
would be generated. Use the //+crossplane:generate:methods=false
comment
marker to explicitly disable generation of any methods for a type. Use go generate
to generate your Crossplane API types by adding a generate marker to
the top level of your api/
directory, for example:
// Generate crossplane-runtime methodsets (resource.Claim, etc)
//go:generate go run ../vendor/github.com/crossplane/crossplane-tools/cmd/angryjet/main.go generate-methodsets ./...
$ angryjet generate-methodsets --help
usage: angryjet generate-methodsets [<flags>] [<packages>]
Generate a Crossplane method sets.
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--header-file=HEADER-FILE The contents of this file will be added to the top of all generated files.
--filename-managed="zz_generated.managed.go"
The filename of generated managed resource files.
--filename-claim="zz_generated.claim.go"
The filename of generated resource claim files.
--filename-portable-class="zz_generated.portableclass.go"
The filename of generated portable class files.
--filename-portable-class-list="zz_generated.portableclasslist.go"
The filename of generated portable class list files.
--filename-non-portable-class="zz_generated.nonportableclass.go"
The filename of generated non-portable class files.
Args:
[<packages>] Package(s) for which to generate methods, for example github.com/crossplane/crossplane/apis/...