Compare commits
5 Commits
debug
...
0.8.84-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33cb4ce63c | ||
|
|
aefb4497e2 | ||
|
|
0047e66f10 | ||
|
|
6bae4254af | ||
|
|
a9689993b0 |
22
README.md
22
README.md
@@ -206,8 +206,26 @@ But we would suggest you run `kubectl config current-context` to check if the cu
|
||||
* Amazon Elastic Kubernetes Service (EKS)
|
||||
TODO
|
||||
|
||||
* Google Kubernetes Engine (GKET)
|
||||
TODO
|
||||
* Google Kubernetes Engine (GKE)
|
||||
|
||||
First you should create a Kubernetes cluster in your GKE, then make sure your KUBECONFIG is ready in `~/.kube/config`, if not, you can run following commands,
|
||||
|
||||
``` shell
|
||||
$ gcloud auth login
|
||||
$ gcloud container clusters get-credentials <your cluster> --zone <zone> --project <project>
|
||||
```
|
||||
|
||||
Then make sure you current context is GKE cluster, you can check it with command,
|
||||
|
||||
``` shell
|
||||
$ kubectl config current-context
|
||||
```
|
||||
|
||||
Then you can deploy your function onto GKE cluster with,
|
||||
|
||||
```shell
|
||||
$ KUBECONFIG=~/.kube/config fx up examples/functions/JavaScript/func.js --name hellojs
|
||||
```
|
||||
|
||||
* Setup your own Kubernetes cluster
|
||||
|
||||
|
||||
3
fx.go
3
fx.go
@@ -14,9 +14,10 @@ import (
|
||||
"github.com/metrue/fx/handlers"
|
||||
"github.com/metrue/fx/middlewares"
|
||||
"github.com/urfave/cli"
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
)
|
||||
|
||||
const version = "0.8.82"
|
||||
const version = "0.8.84"
|
||||
|
||||
func init() {
|
||||
go checkForUpdate()
|
||||
|
||||
2
go.mod
2
go.mod
@@ -39,7 +39,7 @@ require (
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.6.1
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/ugorji/go/codec v1.1.7 // indirect
|
||||
github.com/ugorji/go v1.1.7 // indirect
|
||||
github.com/urfave/cli v1.22.2
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915 // indirect
|
||||
|
||||
1
go.sum
1
go.sum
@@ -1,5 +1,6 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
|
||||
|
||||
@@ -70,7 +70,7 @@ func Pack(output string, input ...string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if isHandler(path) {
|
||||
if isHandler(path, language) {
|
||||
if err := copy.Copy(input[0], path); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func Pack(output string, input ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !hasFxHandleFile(input...) {
|
||||
if !hasFxHandleFile(language, input...) {
|
||||
msg := `it requires a fx handle file when input is not a single file function, e.g.
|
||||
fx.go for Golang
|
||||
Fx.java for Java
|
||||
|
||||
@@ -23,12 +23,18 @@ var ExtLangMapping = map[string]string{
|
||||
".pl": "perl",
|
||||
}
|
||||
|
||||
func isHandler(name string) bool {
|
||||
func isHandler(name string, lang string) bool {
|
||||
basename := filepath.Base(name)
|
||||
nameWithoutExt := strings.TrimSuffix(basename, filepath.Ext(basename))
|
||||
return nameWithoutExt == "fx" ||
|
||||
nameWithoutExt == "Fx" || // Fx is for Java
|
||||
nameWithoutExt == "mod" // mod.rs is for Rust
|
||||
if ExtLangMapping[filepath.Ext(basename)] != lang {
|
||||
return false
|
||||
}
|
||||
|
||||
return (nameWithoutExt == "fx" ||
|
||||
// Fx is for Java
|
||||
nameWithoutExt == "Fx" ||
|
||||
// mod.rs is for Rust)
|
||||
nameWithoutExt == "mod")
|
||||
}
|
||||
|
||||
func langFromFileName(fileName string) (string, error) {
|
||||
@@ -44,10 +50,10 @@ func langFromFileName(fileName string) (string, error) {
|
||||
return lang, nil
|
||||
}
|
||||
|
||||
func hasFxHandleFile(input ...string) bool {
|
||||
func hasFxHandleFile(lang string, input ...string) bool {
|
||||
var handleFile string
|
||||
for _, file := range input {
|
||||
if utils.IsRegularFile(file) && isHandler(file) {
|
||||
if utils.IsRegularFile(file) && isHandler(file, lang) {
|
||||
handleFile = file
|
||||
break
|
||||
} else if utils.IsDir(file) {
|
||||
@@ -56,7 +62,7 @@ func hasFxHandleFile(input ...string) bool {
|
||||
return err
|
||||
}
|
||||
|
||||
if utils.IsRegularFile(path) && isHandler(info.Name()) {
|
||||
if utils.IsRegularFile(path) && isHandler(info.Name(), lang) {
|
||||
handleFile = path
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user