Compare commits
16 Commits
perl
...
0.9.2-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2560dc23fc | ||
|
|
3d6c3d10bf | ||
|
|
5f811693f1 | ||
|
|
0068fb92eb | ||
|
|
71174ead45 | ||
|
|
43c18caceb | ||
|
|
7b4c9c3154 | ||
|
|
9d2649433d | ||
|
|
6353fa7dd3 | ||
|
|
bfa837c88d | ||
|
|
bdc454e7e5 | ||
|
|
9b3e85754c | ||
|
|
af3dcc5f31 | ||
|
|
c375fb9eaf | ||
|
|
70c314229f | ||
|
|
66e23ead00 |
10
.github/workflows/docker.yml
vendored
10
.github/workflows/docker.yml
vendored
@@ -57,11 +57,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
docker push metrue/fx-python-base:latest
|
docker push metrue/fx-python-base:latest
|
||||||
|
|
||||||
# - name: build and publish fx rust image
|
- name: build and publish fx perl image
|
||||||
# if: always()
|
if: always()
|
||||||
# run: |
|
run: |
|
||||||
# docker build -t metrue/fx-rust-base:latest -f ./assets/dockerfiles/base/rust/Dockerfile ./assets/dockerfiles/base/python
|
docker build -t metrue/fx-perl-base:latest -f ./assets/dockerfiles/base/perl/Dockerfile ./assets/dockerfiles/base/perl
|
||||||
# docker push metrue/fx-rust-base:latest
|
docker push metrue/fx-perl-base:latest
|
||||||
|
|
||||||
- name: build and publish fx julia image
|
- name: build and publish fx julia image
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
run:
|
run:
|
||||||
deadline: 10m
|
deadline: 20m
|
||||||
timeout: 10m
|
timeout: 20m
|
||||||
issues-exit-code: 1
|
issues-exit-code: 1
|
||||||
tests: true
|
tests: true
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
|
|||||||
15
assets/dockerfiles/base/node/package-lock.json
generated
vendored
15
assets/dockerfiles/base/node/package-lock.json
generated
vendored
@@ -1,13 +1,26 @@
|
|||||||
{
|
{
|
||||||
"name": "aok",
|
"name": "fx-node-base",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@koa/cors": {
|
||||||
|
"version": "2.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@koa/cors/-/cors-2.2.3.tgz",
|
||||||
|
"integrity": "sha512-tCVVXa39ETsit5kGBtEWWimjLn1sDaeu8+0phgb8kT3GmBDZOykkI3ZO8nMjV2p3MGkJI4K5P+bxR8Ztq0bwsA==",
|
||||||
|
"requires": {
|
||||||
|
"vary": "^1.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||||
|
},
|
||||||
|
"vary": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||||
|
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
assets/dockerfiles/base/node/package.json
vendored
1
assets/dockerfiles/base/node/package.json
vendored
@@ -10,6 +10,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@koa/cors": "^2.2.3",
|
||||||
"get-port": "^3.2.0",
|
"get-port": "^3.2.0",
|
||||||
"is-generator-function": "^1.0.6",
|
"is-generator-function": "^1.0.6",
|
||||||
"koa": "^2.3.0",
|
"koa": "^2.3.0",
|
||||||
|
|||||||
1
assets/dockerfiles/base/perl/cpanfile
vendored
1
assets/dockerfiles/base/perl/cpanfile
vendored
@@ -1,2 +1,3 @@
|
|||||||
requires "EV";
|
requires "EV";
|
||||||
|
requires "JSON";
|
||||||
requires "Mojolicious::Lite";
|
requires "Mojolicious::Lite";
|
||||||
|
|||||||
9
fx.go
9
fx.go
@@ -17,7 +17,7 @@ import (
|
|||||||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.8.87"
|
const version = "0.9.2"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go checkForUpdate()
|
go checkForUpdate()
|
||||||
@@ -179,6 +179,13 @@ func main() {
|
|||||||
Name: "list",
|
Name: "list",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Usage: "list deployed services",
|
Usage: "list deployed services",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "format, f",
|
||||||
|
Value: "table",
|
||||||
|
Usage: "output format, 'table' and 'JSON' supported",
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: handle(
|
Action: handle(
|
||||||
middlewares.Parse("list"),
|
middlewares.Parse("list"),
|
||||||
middlewares.LoadConfig,
|
middlewares.LoadConfig,
|
||||||
|
|||||||
12
go.mod
12
go.mod
@@ -5,8 +5,8 @@ go 1.12
|
|||||||
require (
|
require (
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
||||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||||
github.com/apex/log v1.1.1
|
github.com/apex/log v1.1.2
|
||||||
github.com/briandowns/spinner v1.7.0
|
github.com/briandowns/spinner v1.9.0
|
||||||
github.com/docker/distribution v2.7.1+incompatible // indirect
|
github.com/docker/distribution v2.7.1+incompatible // indirect
|
||||||
github.com/docker/docker v0.0.0-20190313072916-46036c230805
|
github.com/docker/docker v0.0.0-20190313072916-46036c230805
|
||||||
github.com/docker/go-connections v0.4.0
|
github.com/docker/go-connections v0.4.0
|
||||||
@@ -15,7 +15,7 @@ require (
|
|||||||
github.com/gin-gonic/gin v1.4.0
|
github.com/gin-gonic/gin v1.4.0
|
||||||
github.com/gobuffalo/envy v1.8.1 // indirect
|
github.com/gobuffalo/envy v1.8.1 // indirect
|
||||||
github.com/gobuffalo/packr v1.30.1
|
github.com/gobuffalo/packr v1.30.1
|
||||||
github.com/golang/mock v1.3.1
|
github.com/golang/mock v1.4.1
|
||||||
github.com/golang/snappy v0.0.1 // indirect
|
github.com/golang/snappy v0.0.1 // indirect
|
||||||
github.com/google/go-querystring v1.0.0
|
github.com/google/go-querystring v1.0.0
|
||||||
github.com/google/uuid v1.1.1
|
github.com/google/uuid v1.1.1
|
||||||
@@ -34,11 +34,11 @@ require (
|
|||||||
github.com/otiai10/copy v1.0.2
|
github.com/otiai10/copy v1.0.2
|
||||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
|
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
|
||||||
github.com/pierrec/lz4 v0.0.0-20190222153722-062282ea0dcf // indirect
|
github.com/pierrec/lz4 v0.0.0-20190222153722-062282ea0dcf // indirect
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/rogpeppe/go-internal v1.5.1 // indirect
|
github.com/rogpeppe/go-internal v1.5.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/spf13/viper v1.6.1
|
github.com/spf13/viper v1.6.2
|
||||||
github.com/stretchr/testify v1.4.0
|
github.com/stretchr/testify v1.5.1
|
||||||
github.com/ugorji/go v1.1.7 // indirect
|
github.com/ugorji/go v1.1.7 // indirect
|
||||||
github.com/urfave/cli v1.22.2
|
github.com/urfave/cli v1.22.2
|
||||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||||
|
|||||||
22
go.sum
22
go.sum
@@ -23,6 +23,9 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
|
|||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/apex/log v1.1.1 h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA=
|
github.com/apex/log v1.1.1 h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA=
|
||||||
github.com/apex/log v1.1.1/go.mod h1:Ls949n1HFtXfbDcjiTTFQqkVUrte0puoIBfO3SVgwOA=
|
github.com/apex/log v1.1.1/go.mod h1:Ls949n1HFtXfbDcjiTTFQqkVUrte0puoIBfO3SVgwOA=
|
||||||
|
github.com/apex/log v1.1.2 h1:bnDuVoi+o98wOdVqfEzNDlY0tcmBia7r4YkjS9EqGYk=
|
||||||
|
github.com/apex/log v1.1.2/go.mod h1:SyfRweFO+TlkIJ3DVizTSeI1xk7jOIIqOnUPZQTTsww=
|
||||||
|
github.com/apex/logs v0.0.3/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo=
|
||||||
github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE=
|
github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE=
|
||||||
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
|
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
|
||||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
@@ -32,6 +35,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
|||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
github.com/briandowns/spinner v1.7.0 h1:aan1hBBOoscry2TXAkgtxkJiq7Se0+9pt+TUWaPrB4g=
|
github.com/briandowns/spinner v1.7.0 h1:aan1hBBOoscry2TXAkgtxkJiq7Se0+9pt+TUWaPrB4g=
|
||||||
github.com/briandowns/spinner v1.7.0/go.mod h1://Zf9tMcxfRUA36V23M6YGEAv+kECGfvpnLTnb8n4XQ=
|
github.com/briandowns/spinner v1.7.0/go.mod h1://Zf9tMcxfRUA36V23M6YGEAv+kECGfvpnLTnb8n4XQ=
|
||||||
|
github.com/briandowns/spinner v1.9.0 h1:+OMAisemaHar1hjuJ3Z2hIvNhQl9Y7GLPWUwwz2Pxo8=
|
||||||
|
github.com/briandowns/spinner v1.9.0/go.mod h1://Zf9tMcxfRUA36V23M6YGEAv+kECGfvpnLTnb8n4XQ=
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
@@ -110,6 +115,10 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
|
|||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
|
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
|
||||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
|
github.com/golang/mock v1.4.0 h1:Rd1kQnQu0Hq3qvJppYSG0HtP+f5LPPUiDswTLiEegLg=
|
||||||
|
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
|
github.com/golang/mock v1.4.1 h1:ocYkMQY5RrXTYgXl7ICpV0IXwlEQGwKIsery4gyXa1U=
|
||||||
|
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@@ -253,6 +262,10 @@ 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.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 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
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/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
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 v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@@ -312,6 +325,8 @@ github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
|
|||||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk=
|
github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk=
|
||||||
github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
|
github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
|
||||||
|
github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E=
|
||||||
|
github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
@@ -321,6 +336,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
|||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
|
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
|
||||||
@@ -408,6 +425,7 @@ golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e h1:z2Flw7sLy7DxaQi3zDOvI9X+Kb06+G9iZJlkEyHvujE=
|
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e h1:z2Flw7sLy7DxaQi3zDOvI9X+Kb06+G9iZJlkEyHvujE=
|
||||||
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||||
@@ -486,6 +504,10 @@ k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKf
|
|||||||
k8s.io/utils v0.0.0-20190920012459-5008bf6f8cd6/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
k8s.io/utils v0.0.0-20190920012459-5008bf6f8cd6/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||||
k8s.io/utils v0.0.0-20190923111123-69764acb6e8e h1:BXSmdH6S3YGLlhC89DZp+sNdYSmwNeDU6Xu5ZpzGOlM=
|
k8s.io/utils v0.0.0-20190923111123-69764acb6e8e h1:BXSmdH6S3YGLlhC89DZp+sNdYSmwNeDU6Xu5ZpzGOlM=
|
||||||
k8s.io/utils v0.0.0-20190923111123-69764acb6e8e/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
k8s.io/utils v0.0.0-20190923111123-69764acb6e8e/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||||
|
rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=
|
||||||
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
|
rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
|
||||||
|
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/metrue/fx/constants"
|
"github.com/metrue/fx/constants"
|
||||||
containerruntimes "github.com/metrue/fx/container_runtimes"
|
containerruntimes "github.com/metrue/fx/container_runtimes"
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
|
"github.com/metrue/fx/hook"
|
||||||
"github.com/metrue/fx/packer"
|
"github.com/metrue/fx/packer"
|
||||||
"github.com/metrue/fx/pkg/spinner"
|
"github.com/metrue/fx/pkg/spinner"
|
||||||
"github.com/metrue/fx/utils"
|
"github.com/metrue/fx/utils"
|
||||||
@@ -39,6 +40,9 @@ func BuildImage(ctx context.Contexter) (err error) {
|
|||||||
if err := packer.Pack(workdir, sources...); err != nil {
|
if err := packer.Pack(workdir, sources...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := hook.RunBeforeBuildHook(workdir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
docker := ctx.Get("docker").(containerruntimes.ContainerRuntime)
|
docker := ctx.Get("docker").(containerruntimes.ContainerRuntime)
|
||||||
@@ -68,6 +72,9 @@ func ExportImage(ctx context.Contexter) (err error) {
|
|||||||
if err := packer.Pack(outputDir, sources...); err != nil {
|
if err := packer.Pack(outputDir, sources...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := hook.RunBeforeBuildHook(outputDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("exported to %v: %v", outputDir, constants.CheckedSymbol)
|
log.Infof("exported to %v: %v", outputDir, constants.CheckedSymbol)
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
"github.com/metrue/fx/infra"
|
"github.com/metrue/fx/infra"
|
||||||
"github.com/metrue/fx/pkg/render"
|
"github.com/metrue/fx/pkg/renderrer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// List command handle
|
// List command handle
|
||||||
func List(ctx context.Contexter) (err error) {
|
func List(ctx context.Contexter) (err error) {
|
||||||
cli := ctx.GetCliContext()
|
cli := ctx.GetCliContext()
|
||||||
deployer := ctx.Get("deployer").(infra.Deployer)
|
deployer := ctx.Get("deployer").(infra.Deployer)
|
||||||
|
format := ctx.Get("format").(string)
|
||||||
|
|
||||||
services, err := deployer.List(ctx.GetContext(), cli.Args().First())
|
services, err := deployer.List(ctx.GetContext(), cli.Args().First())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
render.Table(services)
|
return renderrer.Render(services, format)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
"github.com/metrue/fx/infra"
|
"github.com/metrue/fx/infra"
|
||||||
"github.com/metrue/fx/pkg/render"
|
"github.com/metrue/fx/pkg/renderrer"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,6 +42,5 @@ func Up(ctx context.Contexter) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
render.Table([]types.Service{service})
|
return renderrer.Render([]types.Service{service}, "table")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
hook/.hooks/before_build
Normal file
1
hook/.hooks/before_build
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npm install
|
||||||
15
hook/fixture/package.json
Normal file
15
hook/fixture/package.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "fixture",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"leftpad": "0.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
73
hook/hook.go
Normal file
73
hook/hook.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package hook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Hooker defines hook interface
|
||||||
|
type Hooker interface {
|
||||||
|
Run() error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook to run
|
||||||
|
type Hook struct {
|
||||||
|
name string
|
||||||
|
script string
|
||||||
|
}
|
||||||
|
|
||||||
|
// New a hook
|
||||||
|
func New(name string, script string, workdir string) *Hook {
|
||||||
|
return &Hook{
|
||||||
|
name: name,
|
||||||
|
script: script,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run execute a hook
|
||||||
|
func (h *Hook) Run(workdir string) error {
|
||||||
|
var script string
|
||||||
|
if !utils.IsRegularFile(h.script) {
|
||||||
|
hookScript, err := ioutil.TempFile(os.TempDir(), "fx-hook-script-")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer os.Remove(hookScript.Name())
|
||||||
|
|
||||||
|
content := []byte(h.script)
|
||||||
|
if _, err = hookScript.Write(content); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := hookScript.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
script = hookScript.Name()
|
||||||
|
} else {
|
||||||
|
absScript, err := filepath.Abs(h.script)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
script = absScript
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command("/bin/sh", script)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
if workdir != "" {
|
||||||
|
cmd.Dir = workdir
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name hook name
|
||||||
|
func (h *Hook) Name() string {
|
||||||
|
return h.name
|
||||||
|
}
|
||||||
54
hook/hook_manager.go
Normal file
54
hook/hook_manager.go
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package hook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HookNameBeforeBuild before build hook
|
||||||
|
const HookNameBeforeBuild = "before_build"
|
||||||
|
|
||||||
|
// RunBeforeBuildHook trigger before_build hook
|
||||||
|
func RunBeforeBuildHook(workdir string) error {
|
||||||
|
hooks, err := descovery("")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, h := range hooks {
|
||||||
|
if h.Name() == HookNameBeforeBuild {
|
||||||
|
if err := h.Run(workdir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func descovery(hookdir string) ([]*Hook, error) {
|
||||||
|
if hookdir == "" {
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
hookdir = filepath.Join(dir, ".hooks")
|
||||||
|
}
|
||||||
|
|
||||||
|
hooks := []*Hook{}
|
||||||
|
if !utils.IsDir(hookdir) {
|
||||||
|
return hooks, nil
|
||||||
|
}
|
||||||
|
if err := filepath.Walk(hookdir, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if info.Name() == HookNameBeforeBuild {
|
||||||
|
hooks = append(hooks, New("before_build", path, ""))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return hooks, nil
|
||||||
|
}
|
||||||
40
hook/hook_manager_test.go
Normal file
40
hook/hook_manager_test.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package hook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHookManager(t *testing.T) {
|
||||||
|
t.Run("descovery in default hookdir .hooks", func(t *testing.T) {
|
||||||
|
hooks, err := descovery("")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(hooks) != 1 {
|
||||||
|
t.Fatalf("should have one hook, but got %d", len(hooks))
|
||||||
|
}
|
||||||
|
|
||||||
|
if hooks[0].Name() != HookNameBeforeBuild {
|
||||||
|
t.Fatalf("should be before_build hook, but got %s", hooks[0].Name())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("descovery in empty hookdir", func(t *testing.T) {
|
||||||
|
hooks, err := descovery(filepath.Join(os.TempDir(), ".hooks"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(hooks) != 0 {
|
||||||
|
t.Fatalf("should get 0 hooks, but got %d", len(hooks))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("run before_build hook", func(t *testing.T) {
|
||||||
|
if err := RunBeforeBuildHook("fixture"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
21
hook/hook_test.go
Normal file
21
hook/hook_test.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package hook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHook(t *testing.T) {
|
||||||
|
t.Run("text", func(t *testing.T) {
|
||||||
|
h := New("before_build", "npm install leftpad", "fixture")
|
||||||
|
if err := h.Run("fixture"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("script", func(t *testing.T) {
|
||||||
|
h := New("before_build", ".hooks/before_build", "fixture")
|
||||||
|
if err := h.Run("fixture"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -86,12 +86,6 @@ func (d *Deployer) Ping(ctx context.Context) error {
|
|||||||
|
|
||||||
// List services
|
// List services
|
||||||
func (d *Deployer) List(ctx context.Context, name string) (svcs []types.Service, err error) {
|
func (d *Deployer) List(ctx context.Context, name string) (svcs []types.Service, err error) {
|
||||||
const task = "listing"
|
|
||||||
spinner.Start(task)
|
|
||||||
defer func() {
|
|
||||||
spinner.Stop(task, err)
|
|
||||||
}()
|
|
||||||
|
|
||||||
// FIXME support remote host
|
// FIXME support remote host
|
||||||
return d.cli.ListContainer(ctx, name)
|
return d.cli.ListContainer(ctx, name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
containerruntimes "github.com/metrue/fx/container_runtimes"
|
containerruntimes "github.com/metrue/fx/container_runtimes"
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
|
"github.com/metrue/fx/hook"
|
||||||
"github.com/metrue/fx/packer"
|
"github.com/metrue/fx/packer"
|
||||||
"github.com/metrue/fx/pkg/spinner"
|
"github.com/metrue/fx/pkg/spinner"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
@@ -54,6 +55,9 @@ func Build(ctx context.Contexter) (err error) {
|
|||||||
if err := packer.Pack(workdir, sources...); err != nil {
|
if err := packer.Pack(workdir, sources...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := hook.RunBeforeBuildHook(workdir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cloudType := ctx.Get("cloud_type").(string)
|
cloudType := ctx.Get("cloud_type").(string)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse parse input
|
// Parse parse input
|
||||||
@@ -15,7 +16,11 @@ func Parse(action string) func(ctx context.Contexter) (err error) {
|
|||||||
case "up":
|
case "up":
|
||||||
sources := []string{}
|
sources := []string{}
|
||||||
for _, s := range cli.Args() {
|
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)
|
ctx.Set("sources", sources)
|
||||||
name := cli.String("name")
|
name := cli.String("name")
|
||||||
@@ -37,6 +42,8 @@ func Parse(action string) func(ctx context.Contexter) (err error) {
|
|||||||
case "list":
|
case "list":
|
||||||
name := cli.Args().First()
|
name := cli.Args().First()
|
||||||
ctx.Set("filter", name)
|
ctx.Set("filter", name)
|
||||||
|
format := cli.String("format")
|
||||||
|
ctx.Set("format", format)
|
||||||
case "image_build":
|
case "image_build":
|
||||||
sources := []string{}
|
sources := []string{}
|
||||||
for _, s := range cli.Args() {
|
for _, s := range cli.Args() {
|
||||||
|
|||||||
49
middlewares/parse_test.go
Normal file
49
middlewares/parse_test.go
Normal 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")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ func init() {
|
|||||||
packr.PackJSONBytes("./images", "julia/deps.jl", "\"b3BlbigiL2FwcC9SRVFVSVJFIikgZG8gZgoJZGVwcyA9IHJlYWRsaW5lcyhmKQoJZm9yIGQgaW4gZGVwcwoJCVBrZy5hZGQoZCkKCWVuZAplbmQKUGtnLmJ1aWxkKCJIdHRwUGFyc2VyIikK\"")
|
packr.PackJSONBytes("./images", "julia/deps.jl", "\"b3BlbigiL2FwcC9SRVFVSVJFIikgZG8gZgoJZGVwcyA9IHJlYWRsaW5lcyhmKQoJZm9yIGQgaW4gZGVwcwoJCVBrZy5hZGQoZCkKCWVuZAplbmQKUGtnLmJ1aWxkKCJIdHRwUGFyc2VyIikK\"")
|
||||||
packr.PackJSONBytes("./images", "julia/fx.jl", "\"CnN0cnVjdCBJbnB1dAogICAgYTo6TnVtYmVyCiAgICBiOjpOdW1iZXIKZW5kCgpmeCA9IGZ1bmN0aW9uKGlucHV0OjpJbnB1dCkKICAgIHJldHVybiBpbnB1dC5hICsgaW5wdXQuYgplbmQK\"")
|
packr.PackJSONBytes("./images", "julia/fx.jl", "\"CnN0cnVjdCBJbnB1dAogICAgYTo6TnVtYmVyCiAgICBiOjpOdW1iZXIKZW5kCgpmeCA9IGZ1bmN0aW9uKGlucHV0OjpJbnB1dCkKICAgIHJldHVybiBpbnB1dC5hICsgaW5wdXQuYgplbmQK\"")
|
||||||
packr.PackJSONBytes("./images", "node/Dockerfile", "\"RlJPTSBtZXRydWUvZngtbm9kZS1iYXNlCgpDT1BZIC4gLgpFWFBPU0UgMzAwMApDTUQgWyJub2RlIiwgImFwcC5qcyJdCg==\"")
|
packr.PackJSONBytes("./images", "node/Dockerfile", "\"RlJPTSBtZXRydWUvZngtbm9kZS1iYXNlCgpDT1BZIC4gLgpFWFBPU0UgMzAwMApDTUQgWyJub2RlIiwgImFwcC5qcyJdCg==\"")
|
||||||
packr.PackJSONBytes("./images", "node/app.js", "\"Y29uc3QgS29hID0gcmVxdWlyZSgna29hJyk7CmNvbnN0IGJvZHlQYXJzZXIgPSByZXF1aXJlKCdrb2EtYm9keXBhcnNlcicpOwpjb25zdCBmeCA9IHJlcXVpcmUoJy4vZngnKTsKCmNvbnN0IGFwcCA9IG5ldyBLb2EoKTsKYXBwLnVzZShib2R5UGFyc2VyKCkpOwphcHAudXNlKGZ4KTsKCmFwcC5saXN0ZW4oMzAwMCk7Cg==\"")
|
packr.PackJSONBytes("./images", "node/app.js", "\"Y29uc3QgS29hID0gcmVxdWlyZSgna29hJyk7CmNvbnN0IGJvZHlQYXJzZXIgPSByZXF1aXJlKCdrb2EtYm9keXBhcnNlcicpOwpjb25zdCBjb3JzID0gcmVxdWlyZSgnQGtvYS9jb3JzJyk7CmNvbnN0IGZ4ID0gcmVxdWlyZSgnLi9meCcpOwoKY29uc3QgYXBwID0gbmV3IEtvYSgpOwphcHAudXNlKGNvcnMoewogIG9yaWdpbjogJyonLAp9KSk7CmFwcC51c2UoYm9keVBhcnNlcigpKTsKYXBwLnVzZShmeCk7CgphcHAubGlzdGVuKDMwMDApOwo=\"")
|
||||||
packr.PackJSONBytes("./images", "node/fx.js", "\"bW9kdWxlLmV4cG9ydHMgPSAoY3R4KSA9PiB7CiAgY3R4LmJvZHkgPSAnaGVsbG8gd29ybGQnCn0K\"")
|
packr.PackJSONBytes("./images", "node/fx.js", "\"bW9kdWxlLmV4cG9ydHMgPSAoY3R4KSA9PiB7CiAgY3R4LmJvZHkgPSAnaGVsbG8gd29ybGQnCn0K\"")
|
||||||
packr.PackJSONBytes("./images", "perl/Dockerfile", "\"RlJPTSBtZXRydWUvZngtcGVybC1iYXNlCgpBREQgLiAuCgpFWFBPU0UgMzAwMApDTUQgWyJwZXJsIiwgImFwcC5wbCIsICJkYWVtb24iXQo=\"")
|
packr.PackJSONBytes("./images", "perl/Dockerfile", "\"RlJPTSBtZXRydWUvZngtcGVybC1iYXNlCgpBREQgLiAuCgpFWFBPU0UgMzAwMApDTUQgWyJwZXJsIiwgImFwcC5wbCIsICJkYWVtb24iXQo=\"")
|
||||||
packr.PackJSONBytes("./images", "perl/app.pl", "\"dXNlIE1vam9saWNpb3VzOjpMaXRlOwoKcmVxdWlyZSAiLi9meC5wbCI7CgpnZXQgJy8nID0+IHN1YiB7CiAgbXkgJGN0eCA9IHNoaWZ0OwogIG15ICRyZXMgPSBmeCgkY3R4KTsKICAkY3R4LT5yZW5kZXIoanNvbiA9PiAkcmVzKTsKfTsKCnBvc3QgJy8nID0+IHN1YiB7CiAgbXkgJGN0eCA9IHNoaWZ0OwogIG15ICRyZXMgPSBmeCgkY3R4KTsKICAkY3R4LT5yZW5kZXIoanNvbiA9PiAkcmVzKTsKfTsKCmFwcC0+c3RhcnQ7Cg==\"")
|
packr.PackJSONBytes("./images", "perl/app.pl", "\"dXNlIE1vam9saWNpb3VzOjpMaXRlOwoKcmVxdWlyZSAiLi9meC5wbCI7CgpnZXQgJy8nID0+IHN1YiB7CiAgbXkgJGN0eCA9IHNoaWZ0OwogIG15ICRyZXMgPSBmeCgkY3R4KTsKICAkY3R4LT5yZW5kZXIoanNvbiA9PiAkcmVzKTsKfTsKCnBvc3QgJy8nID0+IHN1YiB7CiAgbXkgJGN0eCA9IHNoaWZ0OwogIG15ICRyZXMgPSBmeCgkY3R4KTsKICAkY3R4LT5yZW5kZXIoanNvbiA9PiAkcmVzKTsKfTsKCmFwcC0+c3RhcnQ7Cg==\"")
|
||||||
|
|||||||
4
packer/images/node/app.js
vendored
4
packer/images/node/app.js
vendored
@@ -1,8 +1,12 @@
|
|||||||
const Koa = require('koa');
|
const Koa = require('koa');
|
||||||
const bodyParser = require('koa-bodyparser');
|
const bodyParser = require('koa-bodyparser');
|
||||||
|
const cors = require('@koa/cors');
|
||||||
const fx = require('./fx');
|
const fx = require('./fx');
|
||||||
|
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
|
app.use(cors({
|
||||||
|
origin: '*',
|
||||||
|
}));
|
||||||
app.use(bodyParser());
|
app.use(bodyParser());
|
||||||
app.use(fx);
|
app.use(fx);
|
||||||
|
|
||||||
|
|||||||
@@ -149,9 +149,21 @@ func merge(dest string, input ...string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := copy.Copy(file, dest); err != nil {
|
stat, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if stat.Mode().IsRegular() {
|
||||||
|
destDir := filepath.Join(dest, filepath.Dir(path))
|
||||||
|
if err := utils.EnsureDir(destDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := copy.Copy(file, destDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package render
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/types"
|
|
||||||
"github.com/olekukonko/tablewriter"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Table output services as table format
|
|
||||||
func Table(services []types.Service) {
|
|
||||||
data := [][]string{}
|
|
||||||
for _, s := range services {
|
|
||||||
col := []string{
|
|
||||||
s.ID,
|
|
||||||
s.Name,
|
|
||||||
fmt.Sprintf("%s:%d", s.Host, +s.Port),
|
|
||||||
}
|
|
||||||
data = append(data, col)
|
|
||||||
}
|
|
||||||
|
|
||||||
table := tablewriter.NewWriter(os.Stdout)
|
|
||||||
table.SetHeader([]string{"ID", "Name", "Endpoint"})
|
|
||||||
table.AppendBulk(data)
|
|
||||||
table.Render()
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package render
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestTable(t *testing.T) {
|
|
||||||
services := []types.Service{
|
|
||||||
types.Service{
|
|
||||||
ID: "id-1",
|
|
||||||
Name: "name-1",
|
|
||||||
Host: "127.0.0.1",
|
|
||||||
Port: 1000,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Table(services)
|
|
||||||
}
|
|
||||||
53
pkg/renderrer/renderrer.go
Normal file
53
pkg/renderrer/renderrer.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package renderrer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/types"
|
||||||
|
"github.com/olekukonko/tablewriter"
|
||||||
|
)
|
||||||
|
|
||||||
|
const formatJSON = "json"
|
||||||
|
|
||||||
|
//nolint:unused,varcheck,deadcode
|
||||||
|
const formatTable = "table"
|
||||||
|
|
||||||
|
// Render render output with given format
|
||||||
|
func Render(services []types.Service, format string) error {
|
||||||
|
if strings.ToLower(format) == formatJSON {
|
||||||
|
return toJSON(services)
|
||||||
|
}
|
||||||
|
return toTable(services)
|
||||||
|
}
|
||||||
|
|
||||||
|
func toTable(services []types.Service) error {
|
||||||
|
data := [][]string{}
|
||||||
|
for _, s := range services {
|
||||||
|
col := []string{
|
||||||
|
s.ID,
|
||||||
|
s.Name,
|
||||||
|
fmt.Sprintf("%s:%d", s.Host, +s.Port),
|
||||||
|
}
|
||||||
|
data = append(data, col)
|
||||||
|
}
|
||||||
|
|
||||||
|
table := tablewriter.NewWriter(os.Stdout)
|
||||||
|
table.SetHeader([]string{"ID", "Name", "Endpoint"})
|
||||||
|
table.AppendBulk(data)
|
||||||
|
table.Render()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func toJSON(services []types.Service) error {
|
||||||
|
output, err := json.Marshal(services)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Print(string(output)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
24
pkg/renderrer/renderrer_test.go
Normal file
24
pkg/renderrer/renderrer_test.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package renderrer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRenderrer(t *testing.T) {
|
||||||
|
services := []types.Service{
|
||||||
|
types.Service{
|
||||||
|
ID: "id-1",
|
||||||
|
Name: "name-1",
|
||||||
|
Host: "127.0.0.1",
|
||||||
|
Port: 1000,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
t.Run("toTable", func(t *testing.T) {
|
||||||
|
Render(services, "table")
|
||||||
|
})
|
||||||
|
t.Run("toJSON", func(t *testing.T) {
|
||||||
|
Render(services, "json")
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user