Skip to content

Commit

Permalink
fix bug importing orb version
Browse files Browse the repository at this point in the history
The bug hid errors occuring during an import of an orb version.
  • Loading branch information
johnswanson committed Jan 12, 2021
1 parent 1667a8d commit 5c0aefc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ type OrbPublishResponse struct {
}
}

// The OrbImportVersionResponse type matches the data shape of the GQL response for
// importing an orb version.
type OrbImportVersionResponse struct {
ImportOrbVersion struct {
Orb Orb

Errors GQLErrorsCollection
}
}

// The OrbPromoteResponse type matches the data shape of the GQL response for
// promoting an orb.
type OrbPromoteResponse struct {
Expand Down Expand Up @@ -579,7 +589,7 @@ func OrbQuery(cl *graphql.Client, configPath string) (*ConfigResponse, error) {

// OrbImportVersion publishes a new version of an orb using the provided source and id.
func OrbImportVersion(cl *graphql.Client, orbSrc string, orbID string, orbVersion string) (*Orb, error) {
var response OrbPublishResponse
var response OrbImportVersionResponse

query := `
mutation($config: String!, $orbId: UUID!, $version: String!) {
Expand Down Expand Up @@ -608,11 +618,11 @@ func OrbImportVersion(cl *graphql.Client, orbSrc string, orbID string, orbVersio
return nil, errors.Wrap(err, "unable to import orb version")
}

if len(response.PublishOrb.Errors) > 0 {
return nil, response.PublishOrb.Errors
if len(response.ImportOrbVersion.Errors) > 0 {
return nil, response.ImportOrbVersion.Errors
}

return &response.PublishOrb.Orb, nil
return &response.ImportOrbVersion.Orb, nil
}

// OrbPublishByID publishes a new version of an orb by id
Expand Down
2 changes: 1 addition & 1 deletion cmd/orb_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ The following orb versions already exist:
}`

orbPublishResp := `{
"publishOrb": {
"importOrbVersion": {
"errors": [{"message": "ERROR IN CONFIG FILE:\ntesterror"}]
}
}`
Expand Down

0 comments on commit 5c0aefc

Please sign in to comment.