-
Notifications
You must be signed in to change notification settings - Fork 51
Add pull to docker daemon image provider #35
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
Conversation
| return "", nil, newPayloadErr(e.Type, "Source", e.Source) | ||
| } | ||
|
|
||
| prog, ok := e.Value.(*docker.PullStatus) |
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.
Consider renaming prog, it's a bit unclear to me what's going on, since we're sourcing the value from a docker.PullStatus and returning it as a docker.PullStatus. Is this a status value?
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.
it is a reference to a object which the consumer can poll for status continually
| return nil | ||
| } | ||
|
|
||
| func ParsePullDockerImage(e partybus.Event) (string, *docker.PullStatus, 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.
If this is an exported lib function, it'd be good to write a short explanation of what the function does as a doc comment.
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'll follow up in general with better docs for all of these functions
| "github.com/wagoodman/go-progress" | ||
| ) | ||
|
|
||
| const ( |
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 see the case for int here, as opposed to string, since it looks like you use the values assigned via iota for marking progress later on. In this approach, you need the parsePhase function just to make sense of a given value. I think this is probably fine. At the same time, it's helping me to better think through my philosophy about this, and I might've approached it a bit differently. To me, the string values seem more directly associated with a phase's identity, whereas the progress values seem like a derivative use case. In that scenario, I think I'd define these values as strings, and then use a map or something similar to declare the associated progress values for a given phase (e.g. map[PullPhase]int64). Primary reason: this makes the identity of the value the first class citizen (i.e. doesn't require a specialized function like parsePhase) and the specific use within the progress/eventing system use one extra logic step. Secondary reason: this lets you decouple the scale of iota with how you want to scale progress. For example, maybe you want to make the WaitingPhase a lower value, since not much has been accomplished; maybe you want to me the PullingFsPhase take longer since it's I/O and represents more work; whatever, hopefully you get the idea 😄
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.
to summarize our conversation: I'll leave the type of PullPhase alone and I'll translate the existing parse function for a map
This PR adds:
Closes #33