-
Notifications
You must be signed in to change notification settings - Fork 225
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
Remove master.zip file after building function with faas-cli build #66
Remove master.zip file after building function with faas-cli build #66
Conversation
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.
It looks like the CI build is broken.. @ems5311 please can you take a look?
Would be great if you can squash these commits into one (also)
commands/fetch_templates.go
Outdated
return err | ||
} | ||
|
||
func fetchMasterZip() error { | ||
var err error | ||
if _, err = os.Stat("master.zip"); err != nil { | ||
err = nil |
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.
What's happening there? If there is an error you're ignoring 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.
That err
variable is being set to nil
because after we find that there is an error, we load the master.zip file location from the templateUrl
environment variable, or if that env variable does not exist, we grab it from github. The error variable is not needed here, in fact it is a bug if it is not reset to nil, because if you have templateURL
env variable set because you intend to load the master.zip from an alternative location, as this test does, then the test will normally fail on "master.zip os.Stat method failed", because that method and set the err
at line 67. Let me know if there is a better way. Thanks
6642b37
to
5d00f5f
Compare
The magic bytes used in |
I thought that's what they were - so let's make the code self-documenting and use that variable name. I still need to look at the os.Stat line as I'm still not clear why we're clearing the error. Otherwise very excited to see these tests emerging. |
I was wrong about the os.Stat line. The test works without that change, so I'll revert it. Also I should be calling Edit: Just updated the code with a new commit. Let me know if it looks good, and I'll squash them (wanted to leave unsquashed for now so it's easy to see what was updated) |
5d00f5f
to
296f478
Compare
build.sh
Outdated
@@ -5,3 +5,5 @@ docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_p | |||
docker cp faas-cli:/root/faas-cli . && \ | |||
docker rm -f faas-cli | |||
|
|||
go test | |||
go test ./commands |
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.
You can replace both commands with a single invocation:
go test ./...
38b1f1d
to
a963f3c
Compare
Httptest mock server used in this changelist is a solution for issue #45 |
Once you've had a chance to read feedback and apply if necessary can you squash he commits please? Thanks for this change. It will mean smaller git ignore files |
a963f3c
to
5e84bf5
Compare
Just squashed into a single commit. The feedback has been addressed. |
5e84bf5
to
fd5018f
Compare
commands/fetch_templates_test.go
Outdated
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
|
||
// Write out the minimum number of bytes to make the response a valid .zip file | ||
w.Write([]byte{80, 75, 05, 06, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00}) |
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 a magic variable. Please extract it and give it a name like smallest zip etc
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.
@ems5311 where are we with this?
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.
Sure, will make this change this evening.
commands/fetch_templates_test.go
Outdated
})) | ||
defer ts.Close() | ||
|
||
os.Setenv("templateUrl", ts.URL) |
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.
Can we avoid using the environmental variable? Since this is now using httptest?
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.
Similar to the 3rd party template issue, I can pass a variable to the PullTemplates()
function
log.Printf("Writing %dKb to master.zip\n", len(bytesOut)/1024) | ||
err = ioutil.WriteFile("./master.zip", bytesOut, 0700) | ||
log.Printf("Writing %dKb to %s\n", len(bytesOut)/1024, ZipFileName) | ||
err = ioutil.WriteFile(ZipFileName, bytesOut, 0700) | ||
if err != nil { | ||
log.Println(err.Error()) | ||
} |
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.
Please can you do one final new line print at the end of this function? It will separate the output when someone does new or build for the first time.
Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. |
Just pushed this update. I'm gonna need to rebase this if it looks good, but wanted it to be more clear for now. |
267e747
to
26b3452
Compare
"testing" | ||
) | ||
|
||
var SmallestZipFile = []byte{80, 75, 05, 06, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00} |
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.
Perfect, this is 10x better. It could start with small s
so it's not exported too.
Hi Eric, With the mantra of "Less is more": I'm not sure we need keep-archive.. overwrite seems like a good idea. Let's get this finished and then I can merge? |
I'll change the |
Closing this PR as #87 (with changes pending in my local branch) will supercede this PR. It will provide the same functionality along with the |
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.
I thought we were ready to merge this?
It's superceded by the add-template changes that Minh and I are working on.
It would be too much confusion to merge this, then deal with the merge
conflicts with add-template, when the functionality will just be replaced
anyway
…On Sep 17, 2017 2:04 AM, "Alex Ellis" ***@***.***> wrote:
***@***.**** commented on this pull request.
I thought we were ready to merge this?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#66 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABah_V7t6A-G2tKvjQ8fWqKzrPsFFXGMks5sjOCAgaJpZM4PLQOM>
.
|
3d6c6de
to
ea738f9
Compare
1. Remove master.zip after pulling template directory 2. Tests template fetch with mock HTTP server Signed-off-by: Eric Stoekl <ems5311@gmail.com>
ea738f9
to
cf4777a
Compare
Thank you for re-opening. |
This change will remove the master.zip file after the
fetchTemplates()
function is done creating the templates from the downloaded zip file.Description
Use the
os.Remove()
function to remove the zip file, whose name is now stored in a const variable, after making sure that the zip file is still present withos.Stat()
Motivation and Context
Noticed the zip file hanging around, was confused as to its necessity to remain the directory. However, as long as the
templates
directory is present in your YAML build file location, themaster.zip
file will not be used. Therefore, it is not necessary to keep it around.How Has This Been Tested?
Tried building the node, python, csharp, ruby, and Dockerfile templates, and checked that the master.zip file was removed, but the function worked when deployed.
Types of changes
Checklist:
git commit -s