code-generator
code-generator copied to clipboard
applyconfiguration-gen fails on a map to a structure
Running k8s.io/code-generator/cmd/applyconfiguration-gen on types that contains a map to a structure fail with a templating error. (Maps to native type work fine.) Best shown on a simple reproducer:
type Foo struct {
Bar string `json:"bar"`
}
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type MyType struct {
Foo Foo `json:"foo,omitempty"`
FooMap map[string]Foo `json:"fooMap,omitempty"`
}
$ GOPATH=/home/tnozicka/go go run "./vendor/k8s.io/code-generator/cmd/applyconfiguration-gen" --go-header-file='/dev/null' --input-dirs='github.com/scylladb/scylla-operator/pkg/api/test/v1' --output-package='github.com/scylladb/scylla-operator/pkg/client/scylla/applyconfigurations'
F0830 19:24:58.455689 843949 main.go:53] Error: Failed executing generator: some packages had errors:
template: /home/tnozicka/go/src/github.com/scylladb/scylla-operator/vendor/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/applyconfiguration.go:220:1:28: executing "/home/tnozicka/go/src/github.com/scylladb/scylla-operator/vendor/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/applyconfiguration.go:220" at <raw>: error calling raw: runtime error: invalid memory address or nil pointer dereference
when I remove the map it all works fine
type Foo struct {
Bar string `json:"bar"`
}
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type MyType struct {
Foo Foo `json:"foo,omitempty"`
// FooMap map[string]Foo `json:"fooMap,omitempty"`
}
/kind bug /sig apimachinery
@tnozicka: The label(s) sig/apimachinery cannot be applied, because the repository doesn't have them.
In response to this:
/kind bug /sig apimachinery
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Reopen this issue with
/reopen - Mark this issue as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closedYou can:
- Reopen this issue with
/reopen- Mark this issue as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.