From 84320032e02d3581ab29d07b892bc859017ecc61 Mon Sep 17 00:00:00 2001 From: Suhrud kumar <13905545+suhrud-kumar@users.noreply.github.com> Date: Sun, 19 Jul 2020 13:54:38 +0530 Subject: [PATCH 1/2] feat(pipelineController): manual fix to return pipeline execution id --- gateapi/pipeline_controller_api.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gateapi/pipeline_controller_api.go b/gateapi/pipeline_controller_api.go index 76ab37c3..60b3f592 100644 --- a/gateapi/pipeline_controller_api.go +++ b/gateapi/pipeline_controller_api.go @@ -578,12 +578,13 @@ func (a *PipelineControllerApiService) GetPipelineUsingGET(ctx context.Context, @param optional (nil or map[string]interface{}) with one or more of: @param "trigger" (interface{}) trigger @return */ -func (a *PipelineControllerApiService) InvokePipelineConfigUsingPOST1(ctx context.Context, application string, pipelineNameOrId string, localVarOptionals map[string]interface{}) ( *http.Response, error) { +func (a *PipelineControllerApiService) InvokePipelineConfigUsingPOST1(ctx context.Context, application string, pipelineNameOrId string, localVarOptionals map[string]interface{}) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload interface{} ) // create path and map variables @@ -595,9 +596,8 @@ func (a *PipelineControllerApiService) InvokePipelineConfigUsingPOST1(ctx contex localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -608,7 +608,7 @@ func (a *PipelineControllerApiService) InvokePipelineConfigUsingPOST1(ctx contex // to determine the Accept header localVarHttpHeaderAccepts := []string{ "*/*", - } + } // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -621,20 +621,24 @@ func (a *PipelineControllerApiService) InvokePipelineConfigUsingPOST1(ctx contex } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return successPayload, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return localVarHttpResponse, err + return successPayload, localVarHttpResponse, err } defer localVarHttpResponse.Body.Close() if localVarHttpResponse.StatusCode >= 300 { bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err + if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { + return successPayload, localVarHttpResponse, err + } + + return successPayload, localVarHttpResponse, err } /* PipelineControllerApiService Trigger a pipeline execution From 339ec0e9c6fbe4101abd965b1d0e840ec590be82 Mon Sep 17 00:00:00 2001 From: Suhrud kumar <13905545+suhrud-kumar@users.noreply.github.com> Date: Sun, 19 Jul 2020 14:02:44 +0530 Subject: [PATCH 2/2] feat(pipelineExecute): return execution id on pipeline execute command --- cmd/pipeline/execute.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/pipeline/execute.go b/cmd/pipeline/execute.go index 9b7dd1cc..09cdb3cc 100644 --- a/cmd/pipeline/execute.go +++ b/cmd/pipeline/execute.go @@ -87,7 +87,7 @@ func executePipeline(cmd *cobra.Command, options *executeOptions) error { } } - resp, err := options.GateClient.PipelineControllerApi.InvokePipelineConfigUsingPOST1(options.GateClient.Context, + successPayload, resp, err := options.GateClient.PipelineControllerApi.InvokePipelineConfigUsingPOST1(options.GateClient.Context, options.application, options.name, map[string]interface{}{"trigger": trigger}) @@ -100,7 +100,7 @@ func executePipeline(cmd *cobra.Command, options *executeOptions) error { return fmt.Errorf("Encountered an error executing pipeline, status code: %d\n", resp.StatusCode) } - options.Ui.Success("Pipeline execution started") + options.Ui.JsonOutput(successPayload) return nil }