code-generator icon indicating copy to clipboard operation
code-generator copied to clipboard

applyconfiguration-gen fails on a map to a structure

Open tnozicka opened this issue 3 years ago • 2 comments

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"`
}

tnozicka avatar Aug 30 '22 17:08 tnozicka

/kind bug /sig apimachinery

tnozicka avatar Aug 30 '22 17:08 tnozicka

@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.

k8s-ci-robot avatar Aug 30 '22 17:08 k8s-ci-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Nov 28 '22 17:11 k8s-triage-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Dec 28 '22 18:12 k8s-triage-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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 avatar Jan 27 '23 19:01 k8s-triage-robot

@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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

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.

k8s-ci-robot avatar Jan 27 '23 19:01 k8s-ci-robot