fkorotkov / k8s-kotlin-dsl

Kotlin DSL for Kubernetes configs
MIT License
339 stars 19 forks source link

'new' prefix added to class builders #5

Closed ichaki5748 closed 6 years ago

ichaki5748 commented 6 years ago

new prefix prevents confusion between choosing real extension functions that mutate fields and class builders that just create new objects and don't mutate 'outer scope'

fkorotkov commented 6 years ago

@ichaki5748 just published 1.0 with your change 👌

ichaki5748 commented 6 years ago

@fkorotkov thanks, awesome project 👍 :)

fkorotkov commented 6 years ago

For future researchers: this change helps to prevent a very annoying type of mistakes when one could think that a field modifier is used but in reality it was a builder which value wasn't use. For example:

deployment {
  spec {
    metadata {
      name = "foo"
    }
  }
}

Could be valid before, but DeploymentSpec actually doesn't have any metadata field and this ObjectMeta object is actually unused. After this change there is no way to make such a mistake.