-
Notifications
You must be signed in to change notification settings - Fork 41
Conversation
b83346a
to
5594014
Compare
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.
have you tried to run you code?
pkg/build/build.go
Outdated
return errors.Wrap(err, "unable to build image") | ||
} | ||
|
||
log.Infof("Image '%s' from directory '%s' built successfully", image, path.Base(context)) | ||
log.Debugf("Image %s build output:\n%s", image, outputBuffer) | ||
|
||
log.Debugf("Deleted temporary file %v", os.Remove(tmpFile.Name())) |
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 will show Deleted temporary file <nil>
os.Remove
returns error. You should check it, not printing 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.
This is also nice case for using defer
to avoid having to call in two places in case of erro
5594014
to
726d213
Compare
@kadel , got it, updated the code :) |
pkg/build/build.go
Outdated
@@ -99,14 +99,15 @@ func (c *Build) BuildImage(dockerfile, image, context string) error { | |||
Dockerfile: dockerfile, | |||
} | |||
|
|||
// Delete tarball after creating image | |||
defer os.Remove(tmpFile.Name()) |
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.
defer should be placed right after tmpFile
is created. Otherwise, it won't be run before for any return between this and tmpFile, err := ioutil.TempFile("/tmp", "kedge-image-build-")
pkg/build/build.go
Outdated
// Build it! | ||
if err := c.Client.BuildImage(opts); err != nil { | ||
return errors.Wrap(err, "unable to build image") | ||
} | ||
|
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.
@surajnarwade : unrelated changes!
726d213
to
d507503
Compare
Resolves kedgeproject#488, This PR will delete temporary files created in `/tmp` for building images with `kedge build`
d507503
to
0993391
Compare
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 LGTM!
Resolves #488, This PR will delete temporary files created in
/tmp
for building images with
kedge build