Skip to content

Upjet shouldn't generate types with float fields #442

Description

@negz

What happened?

In crossplane-contrib/provider-upjet-gcp#623 various fields that appear to really be integers (e.g. port) are generated with type *float64. This led to a request to add paved.GetFloat() - some context and discussion in crossplane/crossplane-runtime#778.

You're not supposed to use floats in Kubernetes APIs. From https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#primitive-types:

Avoid floating-point values as much as possible, and never use them in spec. Floating-point values cannot be reliably round-tripped (encoded and re-decoded) without changing, and have varying precision and representations across languages and architectures.

See for example https://github.com/kubernetes-sigs/json, which deserializes JSON numbers into int64 where possible.

How can we reproduce it?

Take a look at the generated types in crossplane-contrib/provider-upjet-gcp#623.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv2

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions