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

Add timezone database copy for go run image #212

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions langs/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (h *GoLangHelper) DockerfileBuildCmds() []string {

func (h *GoLangHelper) DockerfileCopyCmds() []string {
return []string{
"COPY --from=build-stage /usr/local/go/lib/time/zoneinfo.zip " +
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only a Go issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

So, i'm not sure, but faced with this while was developing a function with go

Copy link
Contributor

Choose a reason for hiding this comment

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

we should just have it in base image we build from? string of issues over this, made some suggestions fnproject/dockers#13 - we probably need to add for all langs (like certs)

"/usr/local/go/lib/time/zoneinfo.zip",
"COPY --from=build-stage /go/src/func/func /function/",
}
}
Expand Down
2 changes: 1 addition & 1 deletion langs/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (h *PythonLangHelper) Runtime() string {
}

func (h *PythonLangHelper) LangStrings() []string {
return []string{"python","python3.6"}
return []string{"python", "python3.6"}
}

func (h *PythonLangHelper) Extensions() []string {
Expand Down
9 changes: 8 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $fn --version

export FN_API_URL="http://localhost:8080"

go test $(go list ./... | grep -v /vendor/ | grep -v /tests)
go test $(go list ./... | grep -v /vendor/ | grep -v /test)

# Our test directory
OS=$(uname -s)
Expand Down Expand Up @@ -107,3 +107,10 @@ $fn -v build
$fn -v build
$fn run
$fn test

# Test Golang time.LoadLocation
cd $WORK_DIR
cp -r ${CUR_DIR}/test/go_location_loader $WORK_DIR/go_location_loader
cd $WORK_DIR/go_location_loader
$fn -v run
$fn -v test
18 changes: 18 additions & 0 deletions test/go_location_loader/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/go_location_loader/Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

[[constraint]]
branch = "master"
name = "github.com/fnproject/fdk-go"

[prune]
go-tests = true
unused-packages = true
25 changes: 25 additions & 0 deletions test/go_location_loader/func.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"context"
"io"
"time"

"encoding/json"
"github.com/fnproject/fdk-go"
)

func main() {
fdk.Handle(fdk.HandlerFunc(myHandler))
}

func myHandler(_ context.Context, _ io.Reader, out io.Writer) {
tz, err := time.LoadLocation("America/New_York")
if err != nil {
fdk.WriteStatus(out, 500)
out.Write([]byte(err.Error()))
return
}
fdk.WriteStatus(out, 200)
json.NewEncoder(out).Encode(tz.String())
}
5 changes: 5 additions & 0 deletions test/go_location_loader/func.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: load_timezone
version: 0.0.1
runtime: go
entrypoint: ./func
format: json
12 changes: 12 additions & 0 deletions test/go_location_loader/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"tests": [
{
"input": {
"body": {}
},
"output": {
"body": "America/New_York"
}
}
]
}