-
Notifications
You must be signed in to change notification settings - Fork 294
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
Include processes in inspect-image output when available #397
Conversation
Signed-off-by: Emily Casey <ecasey@pivotal.io> Signed-off-by: Simon Jones <sijones@pivotal.io>
Resolves #370 |
@@ -101,20 +113,56 @@ func inspectImageOutput( | |||
} | |||
var buf bytes.Buffer | |||
localMirrors := getLocalMirrors(info.Stack.RunImage.Image, cfg) | |||
processes := displayProcesses(info.Processes) | |||
tw := tabwriter.NewWriter(&buf, 0, 0, 8, ' ', 0) | |||
defer tw.Flush() | |||
if err := tpl.Execute(tw, &struct { |
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.
This anonymous struct could be a map and it might shorten this code a bit.
@@ -91,6 +96,13 @@ func logDetails(remote *pack.ImageInfo, local *pack.ImageInfo, cfg config.Config | |||
} | |||
} | |||
|
|||
type process struct { | |||
PType string |
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.
Why not just Type
here? lifecycle.Process
already does it.
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.
type is a reserved word in golang
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 had assumed that was the reason, but I saw that lifecycle.Process
has a Type
field.
}); err != nil { | ||
return "", err | ||
} | ||
return buf.String(), nil | ||
} | ||
|
||
func displayProcess(p lifecycle.Process, d bool) process { |
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.
This function name makes it sound like it should be printing (or generating a string). I guess it depends on whether you read "display" as a verb or an adjective. Maybe something like renderProcess
? Though you might be able to make the same argument with that name (it's the best I could come up with on the spot).
Also, I feel like primitive parameters should have more descriptive names (the lifecycle.Process
param is fine, but the meaning of the bool
is hard to infer without looking deeper).
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.
Approved, with some minor comments/suggestions.
When using lifecycle version 0.6.0 or greater to build an image, the output of
pack inspect-image
will now include a list of processes defined by a buildpack. The output will indicate which process, if any, is the default.Calls to
pack.Client
'sInspectImage
command will include an additionalProcesses
element ofProcessDetails
including aDefaultProcess
if there is one, as well as a slice ofOtherProcesses
.