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

Exporter defaults to stack.toml run image #127

Merged
merged 3 commits into from
Apr 25, 2019

Conversation

joaopapereira
Copy link
Member

Remove the required --image command line argument and default
to stack.toml configuration.
When the argument is passed it overrides the stack.toml value

Fixes #119

@djoyahoy djoyahoy requested a review from sclevine April 24, 2019 14:59
if flag.NArg() > 1 || flag.Arg(0) == "" || runImageRef == "" {
args := map[string]interface{}{"narg": flag.NArg(), "runImage": runImageRef, "layersDir": layersDir}
if flag.NArg() > 1 || flag.Arg(0) == "" {
args := map[string]interface{}{"narg": flag.NArg(), "layersDir": layersDir}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fair this error was already weird before this PR. It feels like we should print all of the optional args in this error message or none of them. Just including the layersDir is strange. Providing none of them would be consistent with the builder and detector

var stack metadata.StackMetadata
_, err = toml.DecodeFile(stackPath, &stack)
if err != nil {
outLog.Printf("no stack.toml found at path '%s', stack metadata will not be exported\n", stackPath)
}

if runImageRef == "" {
if stack.RunImage.Image == "" {
return cmd.FailCode(cmd.CodeInvalidArgs, "--run-image is required when stack.toml is not present in builder")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lifecycle flag is flag is -image rather than --run-image. Given that the stack.toml can have an arbitrary name if the path is supplied with a flag or an environment variable, perhaps we should say something more generic like "-image is required when there is no stack metadata available". Also, I'm not sure we should mention builders here, that feels like a platform specific concept.

if stack.RunImage.Image == "" {
return cmd.FailCode(cmd.CodeInvalidArgs, "--run-image is required when stack.toml is not present in builder")
}
runImageRef = stack.RunImage.Image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to select the best mirror (the one whose registry matches repoName) instead of always using stack.RunImage.Image. stack.RunImage.Image can be the default if none of the mirrors have a matching registry.

Remove the required `--image` command line argument and default
to `stack.toml` configuration.
When the argument is passed it overrides the `stack.toml` value

Signed-off-by: Joao Pereira <[email protected]>
Remove unnecessary information

Signed-off-by: Joao Pereira <[email protected]>
@joaopapereira
Copy link
Member Author

@ekcasey I added the functionality of choosing the Run Image by registry inside the image package. But only after doing so I realize that it was split to a separated repo.

This feels like a functionality that should be in imageUtil, do you think I should create it in there and when it is merge have update this PR?

@ekcasey
Copy link
Member

ekcasey commented Apr 25, 2019

@joaopapereira given that the only thing in imgutil right now is our image abstraction, I think this functionality fits better in the lifecycle repo

Copy link
Member

@ekcasey ekcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved pending minor fixes

image/image.go Outdated
continue
}
if registry == reg {
return i, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor thing but I was confused the first time I glanced over this code b/c the variable name i led me to assume it was referring to the array index.

"io/ioutil"
"log"
"os"
"path/filepath"

"github.com/BurntSushi/toml"
"github.com/buildpack/imgutil"
"github.com/buildpack/lifecycle/image"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should group this with the other imports from lifecycle

Enhance the selection of run image by using the mirror that is
in the same registry or the canonic version if no mirror is colocated

Signed-off-by: Joao Pereira <[email protected]>
@joaopapereira
Copy link
Member Author

@ekcasey done 😺

@ekcasey ekcasey merged commit d5ef411 into buildpacks:master Apr 25, 2019
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.

exporter chooses run-image from stack.toml when -runImage not provided
2 participants