-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circle-11123 publish orb #27
Conversation
…ci-cli into 11123-publish-orb
Feature-complete, but currently refactoring a lot of copy-pasted code. Ideally 3 things I'd like to DRY up:
Two feature behaviors to change: |
api/api.go
Outdated
@@ -35,6 +48,18 @@ func (response ConfigResponse) ToError() error { | |||
return errors.New(strings.Join(messages, ": ")) | |||
} | |||
|
|||
// ToError (PublishOrbResponse) returns all errors that the GraphQL API returns | |||
// as part of a publish orb request. | |||
func (response PublishOrbResponse) ToError() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have 2 copies of this function - we can extract out a struct that has:
Errors []struct {
Message string
}
and use this a mix-in for any responses that have this shape of data. Then we can have a single ToError function.
api/api.go
Outdated
err = graphQLclient.Run(ctx, request, response) | ||
|
||
if err != nil { | ||
return errors.Wrap(err, "Unable to validate config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Unable to validate config"
- copy paste error?
api/api.go
Outdated
} | ||
} | ||
|
||
return &response.PublishOrb.PublishOrbResponse, publishOrbQuery(ctx, logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would delete the publishOrbQuery
function and just put the body of it here in OrbPublish
. The reason for the split in the config validation code-path is because I wanted to re-use a large chunk of code that was copy+pasted between orb validate
and config validate
.
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
==========================================
+ Coverage 41.6% 43.49% +1.89%
==========================================
Files 11 10 -1
Lines 661 646 -15
==========================================
+ Hits 275 281 +6
+ Misses 363 343 -20
+ Partials 23 22 -1
Continue to review full report at Codecov.
|
Pushed changes Marc suggested. Didn't have time to get around to these two tasks:
Created a card to capture this task: https://circleci.atlassian.net/browse/CIRCLE-12582 |
nice one |
User can publish an orb from the CLI