Skip to content

CustomColumnsPrinter prints address for fields with pointer types instead of the value #1176

@evanmcclure

Description

@evanmcclure

What happened:
I was using the kubectl module in my project and noticed that if server-side flattening and printing isn't used, the CustomColumnsPrinter printer prints the address for object fields that are pointer types instead of the actual value. For example, .spec.terminationGracePeriodSeconds in v1.Pod has the type *int64, and it's value gets printed as 0x140009abc30 instead of an integer such as42.

What you expected to happen:
I expect the CustomColumnsPrinter to handle pointer types correctly. If the value is nil, then <none> should be printed. Otherwise, the value of the dereferenced type should be printed.

How to reproduce it (as minimally and precisely as possible):

Write a program or test to generate fake Pod objects and print those objects with the CustomColumnsPrinter using the JSONPath for the .spec.terminationGracePeriodSeconds field.

Anything else we need to know?:
Bug is here:

valueStrings = append(valueStrings, fmt.Sprintf("%v", values[arrIx][valIx].Interface()))

Environment:

  • Kubernetes client and server versions (use kubectl version): I'm using these modules: k8s.io/api, k8s.io/apimachinery, k8s.io/cli-runtime, k8s.io/client-go, and k8s.io/kubectl, all at version 0.23.3.

  • Cloud provider or hardware configuration:

  • OS (e.g: cat /etc/os-release):

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.priority/backlogHigher priority than priority/awaiting-more-evidence.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions