Im looking to build a crossplane provider for my organization however im running to issues with the code generation.
Is there a way to manipulate how the resource names get generated? The Upjet code generations tools do not seem to respect the naming format for certain resources.
for example:
We have a terraform resource with this format.
provider_load_balancer after adding the resource and running make generate
the resource gets generated. However, the following gets generated.
├── apis
│ ├── generate.go
│ ├── load
│ │ └── v1alpha1
│ │ ├── zz_balancer_types.go
│ │ ├── zz_generated.deepcopy.go
│ │ ├── zz_generated.managed.go
│ │ ├── zz_generated.managedlist.go
│ │ ├── zz_generated_terraformed.go
│ │ └── zz_groupversion_info.go
├── examples-generated
│ ├── load
│ │ └── balancer.yaml
The CRDS, yamls and file structure get generated incorrectly. Ideally, the directories and CRDS should not split the resource name but rather have them as one string loadbalancer
Below we see even the deepcopy methods get generated with the wrong name. These Should be loadbalancer not balancer
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Balancer) DeepCopyInto(out *Balancer) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Balancer.
func (in *Balancer) DeepCopy() *Balancer {
if in == nil {
return nil
}
out := new(Balancer)
in.DeepCopyInto(out)
return out
}
Any ideas about what I can do here?
You can customize the group for an individual generated resource by adding a
ResourceConfiguratorfor it. This is mentioned briefly in the GitHub provider example in the upjet docs.For a more significant example of customization, have a look at provider-aws, which uses a custom mapping and trimming function to map from certain terraform resource names into specific Groups and Kinds.
This is then added into config/provider.go to customize the behavior of the generator.