gojenkins icon indicating copy to clipboard operation
gojenkins copied to clipboard

Create types for APIs

Open supereagle opened this issue 7 years ago • 3 comments

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:

  1. 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.
  2. 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.

supereagle avatar Jul 18 '17 06:07 supereagle

This is a good enhancement, I agree the signature of the methods is getting out of control and is not developer-friendly.

bndr avatar Jul 19 '17 15:07 bndr

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?

supereagle avatar Jul 20 '17 04:07 supereagle

Could you do something with a ...interface{} signature and have the code decide if it's an api.Node or collection of details?

ArcticSnowman avatar Sep 20 '17 18:09 ArcticSnowman