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

Refactor command line arguments and the executor #306

Merged
merged 2 commits into from
Aug 23, 2018

Conversation

priyawadhwa
Copy link
Collaborator

@priyawadhwa priyawadhwa commented Aug 23, 2018

In this refactor I:

  1. Created KanikoOptions to make it easier to pass around arguments
    passed in through the command line
  2. Reorganized executor.go by putting the logic for pushing the image in
    a new file push.go
  3. Made some error messages clearer
  4. Fixed a mistake in the README for pushing to AWS
  5. Marked the --bucket flag as hidden since we want people to use
    --context instead, and marked an aws flag as hidden which is set in a
    vendored directory (not totally sure why but it shows up in the help text for the command)

Should fix documentation issue in #290

In this refactor I:

1. Created KanikoOptions to make it easier to pass around arguments
passed in through the command line
2. Reorganized executor.go by putting the logic for pushing the image in
a new file push.go
3. Made some error messages clearer
4. Fixed a mistake in the README for pushing to AWS
5. Marked the --bucket flag as hidden since we want people to use
--context instead, and marked an aws flag as hidden which is set in a
vendored directorya
@dlorenc
Copy link
Collaborator

dlorenc commented Aug 23, 2018

/help

@container-tools-bot
Copy link
Collaborator

@dlorenc:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@container-tools-bot container-tools-bot added the help wanted Looking for a volunteer! label Aug 23, 2018
@dlorenc dlorenc removed the help wanted Looking for a volunteer! label Aug 23, 2018
@dlorenc
Copy link
Collaborator

dlorenc commented Aug 23, 2018

/assign @tstromberg

@@ -240,7 +240,7 @@ To configure credentials, you will need to do the following:
- name: aws-secret
mountPath: /root/.aws/
- name: docker-config
mountPath: /root/.docker/
mountPath: /kaniko/.docker/
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional? It's not mentioned in the PR description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yah, this is the error in the README I mentioned in the 4th point :)

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I missed that. I thought this was just a YAML file based on the diff context but didn't read the filename =)

RootCmd.PersistentFlags().BoolVarP(&reproducible, "reproducible", "", false, "Strip timestamps out of the image to make it reproducible")
RootCmd.PersistentFlags().StringVarP(&target, "target", "", "", " Set the target build stage to build")
RootCmd.PersistentFlags().BoolVarP(&noPush, "no-push", "", false, "Do not push the image to the registry")
addSetupFlags(RootCmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a level of indirection for flag setup is unusual, but clearly you have something in mind. Do you mind clarifying the intent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The flags in that function were meant to be ones that are used in the prerun (things like setting loglevel), but I might move them back to init() for clarity

rt := &withUserAgent{t: tr}

if err := remote.Write(destRef, image, pushAuth, rt, remote.WriteOptions{}); err != nil {
logrus.Error(fmt.Errorf("Failed to push to destination %s", destination))
Copy link
Contributor

Choose a reason for hiding this comment

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

Logging and error and propagating it upwards usually results in duplicate errors being logged. I generally suggest one or the other unless there is a good reason.

// Push the image
destRef, err := name.NewTag(destination, name.WeakValidation)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

DoPush() has many code paths that can return an error. Do you mind adding some context to the errors returned by it to assist future debuggers? For instance:

"nametag failed: %v", err

I noticed other parts of the kaniko codebase use errors.Wrap for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yah I actually just added in errors.Wrap in this refactor to improve our error messages -- I'll definitely add it here but it will probably require another PR to fix all of our error messages.

@priyawadhwa priyawadhwa merged commit 3603900 into GoogleContainerTools:master Aug 23, 2018
@priyawadhwa priyawadhwa deleted the refactor branch August 23, 2018 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants