Skip to content

Commit

Permalink
Merge pull request #236 from xiaoyu74/test_backplane_api_warning_header
Browse files Browse the repository at this point in the history
[OSD-19019] Enable bp-cli to consume warning header from bp API's response
  • Loading branch information
openshift-merge-bot[bot] committed Nov 14, 2023
2 parents 5585194 + fd9f6cc commit 5a3e6e8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/ocm-backplane/managedJob/createManagedJob.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

BackplaneApi "github.com/openshift/backplane-api/pkg/client"
logger "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/util/wait"

Expand Down Expand Up @@ -175,7 +176,7 @@ func createJob(client BackplaneApi.ClientInterface) (*BackplaneApi.Job, error) {
// create job request
createJob := BackplaneApi.CreateJobJSONRequestBody{
CanonicalName: &options.canonicalName,
Parameters: &jobParams,
Parameters: &jobParams,
}

// call create end point
Expand All @@ -185,6 +186,11 @@ func createJob(client BackplaneApi.ClientInterface) (*BackplaneApi.Job, error) {
return nil, err
}

// Check for the warning header and display it if found.
if warningMsg := resp.Header.Get("Backplane-Warning"); warningMsg != "" {
logger.Warnf("warning: %s", warningMsg)
}

if resp.StatusCode != http.StatusOK {
return nil, utils.TryPrintAPIError(resp, options.raw)
}
Expand Down

0 comments on commit 5a3e6e8

Please sign in to comment.