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

Fixed issue #1200 (buildctl: add --tlsdir) #1284

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

nvpandeti
Copy link

@nvpandeti nvpandeti commented Dec 10, 2019

Added a command-line flag (tlsdir) to buildctl that allowed for specifying a directory that contains a ca.pem, cert.pem, and key.pem. This command-line flag acts an alias of --tlscacert, --tlscert, and --tlskey. --tlsdir cannot be used at the same time as those flags, and will cause an error if done. The pkg/errors package has been added to cmd/buildctl/common/common.go to allow for the creation of this error message.

fix #1200

Signed-off-by: Jeffrey Huang [email protected]

@AkihiroSuda AkihiroSuda changed the title Fixed issue #1200 Fixed issue #1200 (buildctl: add --tlsdir) Dec 10, 2019
AkihiroSuda
AkihiroSuda previously approved these changes Dec 10, 2019
@AkihiroSuda
Copy link
Member

@nvpandeti (Nikhil Varma Pandeti )

the signer (Jeffrey Huang) seems another person

@AkihiroSuda AkihiroSuda self-requested a review December 10, 2019 08:49
@AkihiroSuda AkihiroSuda dismissed their stale review December 10, 2019 08:50

the signer seems not you

@AkihiroSuda AkihiroSuda removed their request for review December 10, 2019 08:50
@nvpandeti
Copy link
Author

@AkihiroSuda I should have mentioned this earlier, @jeffreyhuang23 and I are members of the same Virtualization course at UT Austin. We collaborated on fixes for issues #1200 #1230 and #1240 . I can have him confirm this ASAP.

// Look for cert.pem and, if it exists, set key to that
// Look for key.pem and, if it exists, set tlsDir to that
for _, v := range [3]string{"/ca.pem", "/cert.pem", "/key.pem"} {
matches, _ := filepath.Glob(tlsDir + v)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a weird construction to me.

if _, err := os.Stat(filepath.Join(tlsDir, v)); err != nil {
  switch v {

seems more readable to me. Also, I think we need to error if one of the files can't be found under tlsdir

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, applying your changes and adding an error if one of the files are not found in the specified TLS directory

// Look for ca.pem and, if it exists, set caCert to that
// Look for cert.pem and, if it exists, set key to that
// Look for key.pem and, if it exists, set tlsDir to that
for _, v := range [3]string{"/ca.pem", "/cert.pem", "/key.pem"} {
Copy link
Member

Choose a reason for hiding this comment

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

slashes not needed here

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, removing those slashes

key = file
}
} else {
return nil, errors.New(v + " not found in specified TLS directory")
Copy link
Member

Choose a reason for hiding this comment

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

if error is not os.IsNotExist() we should not try to hide the original error. You may just wrap the error with the specific filename as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Returning the error given by os.Stat(file) then. Not wrapping the error with the specific filename though because the error already returns the absolute path of the file with issues.

Added a command-line flag (tlsdir) to buildctl that allowed for specifying a directory that contains a ca.pem, cert.pem, and key.pem. This command-line flag acts an alias of --tlscacert, --tlscert, and --tlskey. --tlsdir cannot be used at the same time as those flags, and will cause an error if done. The pkg/errors package has been added to cmd/buildctl/common/common.go to allow for the creation of this error message.

Signed-off-by: Jeffrey Huang <[email protected]>
@AkihiroSuda AkihiroSuda merged commit 1dfd864 into moby:master Dec 13, 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.

buildctl: add flag for specifying a directory that contains ca.pem, cert.pem, key.pem
4 participants