Skip to content
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

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

simonjjones
Copy link
Member

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's InspectImage command will include an additional Processes element of ProcessDetails including a DefaultProcess if there is one, as well as a slice of OtherProcesses.

Signed-off-by: Emily Casey <ecasey@pivotal.io>
Signed-off-by: Simon Jones <sijones@pivotal.io>
@simonjjones
Copy link
Member Author

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 {
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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 {
Copy link
Contributor

@ameyer-pivotal ameyer-pivotal Dec 2, 2019

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).

Copy link
Contributor

@ameyer-pivotal ameyer-pivotal left a 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.

@simonjjones simonjjones merged commit f8b3674 into master Dec 4, 2019
@ameyer-pivotal ameyer-pivotal deleted the feature/370-inspect-image-processes branch December 4, 2019 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants