Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config.Resource.Path to support configuring plural names of generated resources #184

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/config/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,9 @@ type Resource struct {
// MetaResource is the metadata associated with the resource scraped from
// the Terraform registry.
MetaResource *registry.Resource

// Path is the resource path for the API server endpoint. It defaults to
// the plural name of the generated CRD. Overriding this sets both the
// path and the plural name for the generated CRD.
Path string
}
1 change: 1 addition & 0 deletions pkg/pipeline/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (cg *CRDGenerator) Generate(cfg *config.Resource) (string, error) {
"Kind": cfg.Kind,
"ForProviderType": gen.ForProviderType.Obj().Name(),
"AtProviderType": gen.AtProviderType.Obj().Name(),
"Path": cfg.Path,
},
"Provider": map[string]string{
"ShortName": cg.ProviderShortName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/templates/crd_types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type {{ .CRD.Kind }}Status struct {
// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,{{ .Provider.ShortName }}}
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,{{ .Provider.ShortName }}}{{ if .CRD.Path }},path={{ .CRD.Path }}{{ end }}
type {{ .CRD.Kind }} struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down