Skip to content

Set default values for boolean properties #615

@kim-tsao

Description

@kim-tsao

Which area this feature is related to?

/area api

Which functionality do you think we should add?

Why is this needed? Is your feature request related to a problem?

The spec mentions default values for a number of boolean properties, with the majority of them being false if unset (exception is MountSources which is true by default). Neither the API or Library packages enforce the setting of default values since this was handled natively by the JSON marshalling package. In order to fix the parent override bug, we will need to switch to using boolean pointers which will cause the default value to be nil. The unfortunate outcome is, our clients will have to bear the responsibility of enforcing the correct default values.

Detailed description:

Describe the solution you'd like

Clients should be able to access boolean properties and get the default values without having to perform nil checks and setting the defaults themselves.

Describe alternatives you've considered

Discussion in parent override bug describes using getters and setters but it's imperfect since clients can still access the fields which need to remain public.

Other areas to investigate:

  • writing our own custom deserializer and setting the defaults there. We need to make sure parent override fields are exempt since we don't want implicitly set values to override
  • Look at setting defaults in the library parser. This may be an easier approach but will only benefit clients who depend on the library.

Additional context

Metadata

Metadata

Assignees

Labels

area/apiEnhancement or issue related to the api/devfile specificationbreakingidentifies changes that would break clients

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions