Compare commits

..

4 Commits

Author SHA1 Message Date
dependabot-preview[bot]
af3dcc5f31 Bump github.com/pkg/errors from 0.8.1 to 0.9.0 (#449)
Bumps [github.com/pkg/errors](https://github.com/pkg/errors) from 0.8.1 to 0.9.0.
- [Release notes](https://github.com/pkg/errors/releases)
- [Commits](https://github.com/pkg/errors/compare/v0.8.1...v0.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-14 08:51:29 +08:00
Minghe
c375fb9eaf check if source file or directory is ready or not (#447) 2020-01-07 15:36:23 +08:00
Minghe
70c314229f add JSON to perl base image (#446) 2020-01-03 09:53:59 +08:00
Minghe
66e23ead00 update docs (#445) 2020-01-02 23:42:43 +08:00
7 changed files with 65 additions and 8 deletions

View File

@@ -57,11 +57,11 @@ jobs:
run: |
docker push metrue/fx-python-base:latest
# - name: build and publish fx rust image
# if: always()
# run: |
# docker build -t metrue/fx-rust-base:latest -f ./assets/dockerfiles/base/rust/Dockerfile ./assets/dockerfiles/base/python
# docker push metrue/fx-rust-base:latest
- name: build and publish fx perl image
if: always()
run: |
docker build -t metrue/fx-perl-base:latest -f ./assets/dockerfiles/base/perl/Dockerfile ./assets/dockerfiles/base/perl
docker push metrue/fx-perl-base:latest
- name: build and publish fx julia image
if: always()

View File

@@ -1,2 +1,3 @@
requires "EV";
requires "JSON";
requires "Mojolicious::Lite";

2
fx.go
View File

@@ -17,7 +17,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)
const version = "0.8.87"
const version = "0.8.88"
func init() {
go checkForUpdate()

2
go.mod
View File

@@ -34,7 +34,7 @@ require (
github.com/otiai10/copy v1.0.2
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pierrec/lz4 v0.0.0-20190222153722-062282ea0dcf // indirect
github.com/pkg/errors v0.8.1
github.com/pkg/errors v0.9.0
github.com/rogpeppe/go-internal v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.1

2
go.sum
View File

@@ -253,6 +253,8 @@ github.com/pierrec/lz4 v0.0.0-20190222153722-062282ea0dcf/go.mod h1:3/3N9NVKO0je
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.0 h1:J8lpUdobwIeCI7OiSxHqEwJUKvJwicL5+3v1oe2Yb4k=
github.com/pkg/errors v0.9.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

View File

@@ -5,6 +5,7 @@ import (
"github.com/google/uuid"
"github.com/metrue/fx/context"
"github.com/metrue/fx/utils"
)
// Parse parse input
@@ -15,7 +16,11 @@ func Parse(action string) func(ctx context.Contexter) (err error) {
case "up":
sources := []string{}
for _, s := range cli.Args() {
sources = append(sources, s)
if utils.IsDir(s) || utils.IsRegularFile(s) {
sources = append(sources, s)
} else {
return fmt.Errorf("no such file or directory: %s", s)
}
}
ctx.Set("sources", sources)
name := cli.String("name")

49
middlewares/parse_test.go Normal file
View File

@@ -0,0 +1,49 @@
package middlewares
import (
"os"
"testing"
"flag"
"github.com/golang/mock/gomock"
mockCtx "github.com/metrue/fx/context/mocks"
"github.com/urfave/cli"
)
func TestParse(t *testing.T) {
t.Run("source code not existed", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctx := mockCtx.NewMockContexter(ctrl)
argset := flag.NewFlagSet("test", 0)
cli := cli.NewContext(nil, argset, nil)
argset.Parse([]string{"this_file_should_not_existed"})
ctx.EXPECT().GetCliContext().Return(cli)
if err := Parse("up")(ctx); err == nil {
t.Fatal("should got file or directory not existed error")
}
})
t.Run("source code ready", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctx := mockCtx.NewMockContexter(ctrl)
argset := flag.NewFlagSet("test", 0)
cli := cli.NewContext(nil, argset, nil)
pwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
argset.Parse([]string{pwd})
ctx.EXPECT().GetCliContext().Return(cli)
ctx.EXPECT().Set("sources", []string{pwd})
ctx.EXPECT().Set("name", "")
ctx.EXPECT().Set("port", 0)
ctx.EXPECT().Set("force", false)
if err := Parse("up")(ctx); err != nil {
t.Fatal("should got file or directory not existed error")
}
})
}