gojenkins
gojenkins copied to clipboard
Create types for APIs
For some APIs like func (j *Jenkins) CreateNode(name string, numExecutors int, description string, remoteFS string, options ...interface{}) (*Node, error)
, it is not good enough:
- Core config of node are listed as params. If want to add another core config, the API has to be changed, which will cause the build failure for codes depend on gojenkins.
- Use
options
param as map for complex configs. This param is clear enough for users, as they do not know what key are supported, and there is no a clear struct.
I think we can create a api folder for types, the above API will be clear as func (j *Jenkins) CreateNode(node *api.Node) (*Node, error)
. All configs needed by a node will be stored in api.Node
. In order to add more config for node, just need to add them into the struct api.Node
, no need to change the API.
This is a good enhancement, I agree the signature of the methods is getting out of control and is not developer-friendly.
Ok, I will start this enhancement.
As there will be a huge change of the APIs, I think there is need to publish a new release before this change, and start the new version from v2.0.0 after this change.
@bndr Any thoughts?
Could you do something with a ...interface{}
signature and have the code decide if it's an api.Node
or collection of details?