rundeck / go-rundeck

Rundeck Golang SDK
11 stars 3 forks source link

Function JobExecutionRun is requiring an int32 instead of uuid/string as JobID #1

Open commarla opened 4 years ago

commarla commented 4 years ago

Hi @ProTip

I tried to use the JobExecutionRun function https://github.com/rundeck/go-rundeck/blob/master/rundeck/client.go#L1091 but I think the int32 format is an error.

JobID is a string everywhere else, JobGet https://github.com/rundeck/go-rundeck/blob/master/rundeck/client.go#L1165 for example.

I understand this SDK is autogenerated but how can we fix that ?

Thanks

alexthehurst commented 4 years ago

I'm also hitting this issue. It looks like the API is built from an old version of the OpenAPI spec doc which includes this bug for both jobExecutionRun and jobExecutionDelete. The jobExecutionRun endpoint has been fixed in recent updates, but not the jobExecutionDelete endpoint. Rebuilding this API would fix the execution run endpoint, but not the execution delete endpoint.

https://github.com/rundeck/rundeck-api-specs/issues/2

Rayer commented 4 years ago

Noticed that. However, pull request is pointless since it is a code generated project. As a workaround, here is some pro tips :

  1. Copy this project to your project folder, it most likely ~/go/pkg/mod/github.com/rundeck
  2. Modify go.mod, use replace directive to redirect this project. Take my go.mod as example
module MyAwesomeProject

go 1.14

replace github.com/rundeck/go-rundeck/rundeck v0.0.0-20190510195016-2cf9670bbcc4 => ./rundeck

require (
    github.com/aws/aws-sdk-go v1.33.14
    github.com/rundeck/go-rundeck/rundeck v0.0.0-20190510195016-2cf9670bbcc4
    github.com/stretchr/testify v1.6.1 // indirect
)
  1. Modify files. You need to modify the type in clients.go line 1091, change type of ID to String, as well as line 1124
    func (client BaseClient) JobExecutionRun(ctx context.Context, ID string, request *ExecuteJobRequest) (result ExecutionList, err error) {

    func (client BaseClient) JobExecutionRunPreparer(ctx context.Context, ID string, request *ExecuteJobRequest) (*http.Request, error) {

Just a workaround, and it have been proven works in my project. Again, pull request for this project is pointless, I don't think we should do that.