Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Consistent contructor #91

Open
fabioy opened this issue Nov 30, 2017 · 3 comments
Open

Consistent contructor #91

fabioy opened this issue Nov 30, 2017 · 3 comments

Comments

@fabioy
Copy link

fabioy commented Nov 30, 2017

Rather than have multiple parameters in the constructors, prefer to have a single (or no param) constructor.

Currently the constructors take a variable number of parameters, and it's hard to know what's required. For example:

Deployment - new(name, replicas, containers, podLabels={app: name})
Service - new(name, selector, ports)

Some of these params are text, some are other objects. It's unclear from the definition. To make it more confusing, there's also builder methods like "withContainers", which presumably provide same functionality.

Suggestion:

Have a consistent constructor (single name param for named objects, else no param constructor):

local mydep = deployment.new("frontend")
.withReplicas(2)
.withContainers(...);

@nikolay
Copy link

nikolay commented Jan 10, 2018

If there's no desire to do more, at least all parameters need to be optional! Also, documentation should recommend the usage of named parameters instead of unreadable positional ones!

There's a related PR by @bryanl: ksonnet/ksonnet#267

@adamdecaf
Copy link

Adding init() works for me.

@bryanl
Copy link
Member

bryanl commented Jan 10, 2018

@nikolay we're currently working through the proposal right now. We should have a course by the EOD tomorrow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants