Compare commits
1 Commits
0.9.42-alp
...
perl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b0ffda4a3 |
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@@ -19,7 +19,8 @@ jobs:
|
|||||||
|
|
||||||
- name: lint
|
- name: lint
|
||||||
run: |
|
run: |
|
||||||
make lint
|
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint \
|
||||||
|
golangci-lint run -v
|
||||||
|
|
||||||
- name: unit test
|
- name: unit test
|
||||||
env:
|
env:
|
||||||
@@ -42,6 +43,11 @@ jobs:
|
|||||||
make docker-build
|
make docker-build
|
||||||
make test
|
make test
|
||||||
# make docker-publish #TODO in release workflow
|
# make docker-publish #TODO in release workflow
|
||||||
|
- name: test fx docker cloud
|
||||||
|
run: |
|
||||||
|
make start_docker_infra
|
||||||
|
make test_docker_infra
|
||||||
|
make stop_docker_infra
|
||||||
|
|
||||||
- name: test fx cli
|
- name: test fx cli
|
||||||
env:
|
env:
|
||||||
|
|||||||
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 perl image
|
# - name: build and publish fx rust image
|
||||||
if: always()
|
# if: always()
|
||||||
run: |
|
# run: |
|
||||||
docker build -t metrue/fx-perl-base:latest -f ./assets/dockerfiles/base/perl/Dockerfile ./assets/dockerfiles/base/perl
|
# docker build -t metrue/fx-rust-base:latest -f ./assets/dockerfiles/base/rust/Dockerfile ./assets/dockerfiles/base/python
|
||||||
docker push metrue/fx-perl-base:latest
|
# docker push metrue/fx-rust-base:latest
|
||||||
|
|
||||||
- name: build and publish fx julia image
|
- name: build and publish fx julia image
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
run:
|
run:
|
||||||
deadline: 20m
|
deadline: 10m
|
||||||
timeout: 20m
|
timeout: 10m
|
||||||
issues-exit-code: 1
|
issues-exit-code: 1
|
||||||
tests: true
|
tests: true
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
- examples
|
- examples
|
||||||
- api/images
|
- api/images
|
||||||
- test/functions
|
- test/functions
|
||||||
- assets/
|
|
||||||
- bundler/go/assets
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- goimports
|
- goimports
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -4,8 +4,7 @@ DOCKER_REMOTE_HOST_ADDR ?= "127.0.0.1"
|
|||||||
DOCKER_REMOTE_HOST_USER ?= $(whoami)
|
DOCKER_REMOTE_HOST_USER ?= $(whoami)
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
docker pull golangci/golangci-lint
|
golangci-lint run
|
||||||
docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint golangci-lint run -v
|
|
||||||
|
|
||||||
generate:
|
generate:
|
||||||
packr
|
packr
|
||||||
@@ -27,13 +26,13 @@ clean:
|
|||||||
rm -rf ${DIST_DIR}
|
rm -rf ${DIST_DIR}
|
||||||
|
|
||||||
unit-test:
|
unit-test:
|
||||||
./scripts/coverage.sh
|
CI=true ./scripts/coverage.sh
|
||||||
|
|
||||||
cli-test-ci:
|
cli-test-ci:
|
||||||
./scripts/test_cli.sh 'js'
|
./scripts/test_cli.sh 'js'
|
||||||
|
|
||||||
cli-test:
|
cli-test:
|
||||||
./scripts/test_cli.sh 'js rb py go java d pl'
|
./scripts/test_cli.sh 'js rb py go php java d rs pl'
|
||||||
|
|
||||||
http-test:
|
http-test:
|
||||||
./scripts/http_test.sh
|
./scripts/http_test.sh
|
||||||
|
|||||||
95
README.md
95
README.md
@@ -15,6 +15,9 @@ Poor man's function as a service.
|
|||||||
- [Introduction](#introduction)
|
- [Introduction](#introduction)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
|
- [Manage Infrastructure](#manage-infrastructure)
|
||||||
|
- [Contribute](#contribute)
|
||||||
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
@@ -68,6 +71,8 @@ You can go the release page to [download](https://github.com/metrue/fx/releases)
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Make sure [Docker](https://docs.docker.com/engine/installation/) installed and running on your server first. then type `fx -h` on your terminal to check out basic help.
|
||||||
|
|
||||||
```
|
```
|
||||||
NAME:
|
NAME:
|
||||||
fx - makes function as a service
|
fx - makes function as a service
|
||||||
@@ -75,11 +80,17 @@ NAME:
|
|||||||
USAGE:
|
USAGE:
|
||||||
fx [global options] command [command options] [arguments...]
|
fx [global options] command [command options] [arguments...]
|
||||||
|
|
||||||
|
VERSION:
|
||||||
|
0.8.7
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
|
infra manage infrastructure
|
||||||
up deploy a function
|
up deploy a function
|
||||||
down destroy a service
|
down destroy a service
|
||||||
list, ls list deployed services
|
list, ls list deployed services
|
||||||
|
call run a function instantly
|
||||||
image manage image of service
|
image manage image of service
|
||||||
|
doctor health check for fx
|
||||||
help, h Shows a list of commands or help for one command
|
help, h Shows a list of commands or help for one command
|
||||||
|
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
@@ -87,40 +98,22 @@ GLOBAL OPTIONS:
|
|||||||
--version, -v print the version
|
--version, -v print the version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deploy function
|
### Deploy your function to Docker
|
||||||
|
|
||||||
#### Local Docker environment
|
|
||||||
|
|
||||||
By default, function will be deployed on localhost, make sure [Docker](https://docs.docker.com/engine/installation/) installed and running on your server first. then type `fx -h` on your terminal to check out basic help.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ fx up --name hello ./examples/functions/JavaScript/func.js
|
$ fx up --name hello-fx ./examples/functions/JavaScript/func.js
|
||||||
|
|
||||||
+------------------------------------------------------------------+-----------+---------------+
|
+------------------------------------------------------------------+-----------+---------------+
|
||||||
| ID | NAME | ENDPOINT |
|
| ID | NAME | ENDPOINT |
|
||||||
+------------------------------------------------------------------+-----------+---------------+
|
+------------------------------------------------------------------+-----------+---------------+
|
||||||
| 5b24d36608ee392c937a61a530805f74551ddec304aea3aca2ffa0fabcf98cf3 | /hello | 0.0.0.0:58328 |
|
| 5b24d36608ee392c937a61a530805f74551ddec304aea3aca2ffa0fabcf98cf3 | /hello-fx | 0.0.0.0:58328 |
|
||||||
+------------------------------------------------------------------+-----------+---------------+
|
+------------------------------------------------------------------+-----------+---------------+
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Remote host
|
### Deploy your function to Kubernetes
|
||||||
|
|
||||||
Use `--host` to specify the target host for your function, or you can just set it to `FX_HOST` environment variable.
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ fx up --host roo@<your host> --name hello ./examples/functions/JavaScript/func.js
|
|
||||||
|
|
||||||
+------------------------------------------------------------------+-----------+---------------+
|
|
||||||
| ID | NAME | ENDPOINT |
|
|
||||||
+------------------------------------------------------------------+-----------+---------------+
|
|
||||||
| 5b24d36608ee392c937a61a530805f74551ddec304aea3aca2ffa0fabcf98cf3 | /hello | 0.0.0.0:58345 |
|
|
||||||
+------------------------------------------------------------------+-----------+---------------+
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Kubernetes
|
|
||||||
|
|
||||||
```
|
```
|
||||||
$ FX_KUBECONF=~/.kube/config fx up examples/functions/JavaScript/func.js --name hello
|
$ KUBECONFIG=~/.kube/config ./build/fx up examples/functions/JavaScript/func.js --name hello-fx
|
||||||
|
|
||||||
+-------------------------------+------+----------------+
|
+-------------------------------+------+----------------+
|
||||||
| ID | NAME | ENDPOINT |
|
| ID | NAME | ENDPOINT |
|
||||||
@@ -129,7 +122,7 @@ $ FX_KUBECONF=~/.kube/config fx up examples/functions/JavaScript/func.js --name
|
|||||||
+------------------------+-------------+----------------+
|
+------------------------+-------------+----------------+
|
||||||
```
|
```
|
||||||
|
|
||||||
### Test service
|
### Test your service
|
||||||
|
|
||||||
then you can test your service:
|
then you can test your service:
|
||||||
|
|
||||||
@@ -156,6 +149,31 @@ hello world
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Manage Infrastructure
|
||||||
|
|
||||||
|
**fx** is originally designed to turn a function into a runnable Docker container in a easiest way, on a host with Docker running, you can just deploy your function with `fx up` command, and now **fx** supports deploy function to be a service onto Kubernetes cluster infrasture, and we encourage you to do that other than on bare Docker environment, there are lots of advantage to run your function on Kubernetes like self-healing, load balancing, easy horizontal scaling, etc. It's pretty simple to deploy your function onto Kubernetes with **fx**, you just set KUBECONFIG in your enviroment.
|
||||||
|
|
||||||
|
By default. **fx** use localhost as target infrastructure to run your service, and you can also setup your remote virtual machines as **fx**'s infrastructure and deploy your functions onto it.
|
||||||
|
|
||||||
|
### `fx infra create`
|
||||||
|
|
||||||
|
You can create types (docker and k8s) of infrastructures for **fx** to deploy functions
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ fx infra create --name infra_us --type docker --host <user>@<ip> ## create docker type infrasture on <ip>
|
||||||
|
$ fx infra create --name infra_bj --type k8s --master <user>@<ip> --agents '<user1>@<ip1>,<user2>@<ip2>' ## create k8s type infrasture use <ip> as master node, and <ip1> and <ip2> as agents nodes
|
||||||
|
```
|
||||||
|
|
||||||
|
### `fx infra use`
|
||||||
|
|
||||||
|
To use a infrastructure, you can use `fx infra use` command to activate it.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
fx infra use <infrastructure name>
|
||||||
|
```
|
||||||
|
|
||||||
|
and you can list your infrastructure with `fx infra list`
|
||||||
|
|
||||||
## Use Public Cloud Kubernetes Service as infrastructure to run your functions
|
## Use Public Cloud Kubernetes Service as infrastructure to run your functions
|
||||||
|
|
||||||
* Azure Kubernetes Service (AKS)
|
* Azure Kubernetes Service (AKS)
|
||||||
@@ -180,7 +198,7 @@ aks-nodepool1-31718369-0 Ready agent 6m44s v1.12.8
|
|||||||
Since AKS's config will be merged into `~/.kube/config` and set to be current context after you run `az aks get-credentials` command, so you can just set KUBECONFIG to default config also,
|
Since AKS's config will be merged into `~/.kube/config` and set to be current context after you run `az aks get-credentials` command, so you can just set KUBECONFIG to default config also,
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ export FX_KUBECONF=~/.kube/config # then fx will take the config to deloy function
|
$ export KUBECONFIG=~/.kube/config # then fx will take the config to deloy function
|
||||||
```
|
```
|
||||||
|
|
||||||
But we would suggest you run `kubectl config current-context` to check if the current context is what you want.
|
But we would suggest you run `kubectl config current-context` to check if the current context is what you want.
|
||||||
@@ -206,7 +224,7 @@ $ kubectl config current-context
|
|||||||
Then you can deploy your function onto GKE cluster with,
|
Then you can deploy your function onto GKE cluster with,
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ FX_KUBECONF=~/.kube/config fx up examples/functions/JavaScript/func.js --name hellojs
|
$ KUBECONFIG=~/.kube/config fx up examples/functions/JavaScript/func.js --name hellojs
|
||||||
```
|
```
|
||||||
|
|
||||||
* Setup your own Kubernetes cluster
|
* Setup your own Kubernetes cluster
|
||||||
@@ -215,6 +233,31 @@ $ FX_KUBECONF=~/.kube/config fx up examples/functions/JavaScript/func.js --name
|
|||||||
fx infra create --type k3s --name fx-cluster-1 --master root@123.11.2.3 --agents 'root@1.1.1.1,root@2.2.2.2'
|
fx infra create --type k3s --name fx-cluster-1 --master root@123.11.2.3 --agents 'root@1.1.1.1,root@2.2.2.2'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Contribute
|
||||||
|
|
||||||
|
fx uses [Project](https://github.com/metrue/fx/projects/4) to manage the development.
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
Docker: make sure [Docker](https://docs.docker.com/engine/installation/) installed and running on your server.
|
||||||
|
|
||||||
|
|
||||||
|
<a name="buildtest"></a>
|
||||||
|
#### Build & Test
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git clone https://github.com/metrue/fx
|
||||||
|
$ cd fx
|
||||||
|
$ make build
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can build and test:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ make build
|
||||||
|
$ ./build/fx -h
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
|
|||||||
2
assets/dockerfiles/base/node/Dockerfile
vendored
2
assets/dockerfiles/base/node/Dockerfile
vendored
@@ -1,4 +1,4 @@
|
|||||||
FROM node:alpine
|
FROM node:latest
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|||||||
15
assets/dockerfiles/base/node/package-lock.json
generated
vendored
15
assets/dockerfiles/base/node/package-lock.json
generated
vendored
@@ -1,26 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "fx-node-base",
|
"name": "aok",
|
||||||
"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,7 +10,6 @@
|
|||||||
"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,3 +1,2 @@
|
|||||||
requires "EV";
|
requires "EV";
|
||||||
requires "JSON";
|
|
||||||
requires "Mojolicious::Lite";
|
requires "Mojolicious::Lite";
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
package bundle
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
"github.com/metrue/fx/bundler/d"
|
|
||||||
golang "github.com/metrue/fx/bundler/go"
|
|
||||||
"github.com/metrue/fx/bundler/java"
|
|
||||||
"github.com/metrue/fx/bundler/julia"
|
|
||||||
"github.com/metrue/fx/bundler/node"
|
|
||||||
"github.com/metrue/fx/bundler/perl"
|
|
||||||
"github.com/metrue/fx/bundler/python"
|
|
||||||
"github.com/metrue/fx/bundler/ruby"
|
|
||||||
"github.com/metrue/fx/bundler/rust"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Bundle function to project
|
|
||||||
func Bundle(workdir string, language string, fn string, deps ...string) error {
|
|
||||||
var bundler bundler.Bundler
|
|
||||||
switch language {
|
|
||||||
case "d":
|
|
||||||
bundler = d.New()
|
|
||||||
case "node":
|
|
||||||
bundler = node.New()
|
|
||||||
case "go":
|
|
||||||
bundler = golang.New()
|
|
||||||
case "java":
|
|
||||||
bundler = java.New()
|
|
||||||
case "julia":
|
|
||||||
bundler = julia.New()
|
|
||||||
case "perl":
|
|
||||||
bundler = perl.New()
|
|
||||||
case "python":
|
|
||||||
bundler = python.New()
|
|
||||||
case "ruby":
|
|
||||||
bundler = ruby.New()
|
|
||||||
case "rust":
|
|
||||||
bundler = rust.New()
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("%s not suppported yet", language)
|
|
||||||
}
|
|
||||||
return bundler.Bundle(workdir, fn, deps...)
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
package bundle
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createFn(content string, t *testing.T) string {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd.Name()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBundle(t *testing.T) {
|
|
||||||
workdir, err := ioutil.TempDir("", "fx-test")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(workdir)
|
|
||||||
|
|
||||||
cases := []struct {
|
|
||||||
workdir string
|
|
||||||
language string
|
|
||||||
fn string
|
|
||||||
deps []string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "d",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "go",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "java",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "julia",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "perl",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "python",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "ruby",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
workdir: workdir,
|
|
||||||
language: "rust",
|
|
||||||
fn: `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range cases {
|
|
||||||
fn := createFn(c.fn, t)
|
|
||||||
defer os.Remove(fn)
|
|
||||||
|
|
||||||
if err := Bundle(c.workdir, c.language, fn, c.deps...); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
The only thing `fx` does is to make a single function to be an HTTP service, `fx` takes two steps to finish the process,
|
|
||||||
* Wraps the function into a web server project and make it be the handler function of the HTTP request.
|
|
||||||
* Builds the bundled web server to be Docker image, then run it as a Docker container and expose the service port.
|
|
||||||
|
|
||||||
`bundler` is the component responsible for step 1: wrap a single function (and its dependencies) into a web server. Take a Node web service as an example, the project looks like this,
|
|
||||||
```
|
|
||||||
helloworld
|
|
||||||
├── Dockerfile
|
|
||||||
├── app.js
|
|
||||||
└── fx.js
|
|
||||||
```
|
|
||||||
|
|
||||||
And the codes is pretty simple,
|
|
||||||
|
|
||||||
**app.js**
|
|
||||||
```javascript
|
|
||||||
const Koa = require('koa');
|
|
||||||
const bodyParser = require('koa-bodyparser');
|
|
||||||
const cors = require('@koa/cors');
|
|
||||||
const fx = require('./fx');
|
|
||||||
|
|
||||||
const app = new Koa();
|
|
||||||
app.use(cors({
|
|
||||||
origin: '*',
|
|
||||||
}));
|
|
||||||
app.use(bodyParser());
|
|
||||||
app.use(fx);
|
|
||||||
|
|
||||||
app.listen(3000);
|
|
||||||
```
|
|
||||||
|
|
||||||
**fx.js**
|
|
||||||
```javascript
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello world'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Dockerfile**
|
|
||||||
```dockerfile
|
|
||||||
FROM metrue/fx-node-base
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
EXPOSE 3000
|
|
||||||
CMD ["node", "app.js"]
|
|
||||||
```
|
|
||||||
|
|
||||||
You can see that it's a web service built with `Koa`, the request handler function defined in `fx.js` to response plain text `hello world`, so to make a general JavaScript/Node function to be a web service, we only have to put it into `fx.js` above, then build and run it with Docker and that's it.
|
|
||||||
|
|
||||||
To support different programming languages, `fx` needs to implement different `bundlers`, the reasons are,
|
|
||||||
* The way to set up a web service is different in different languages
|
|
||||||
* The way to manage dependency is different in different languages.
|
|
||||||
|
|
||||||
So there will be (are) different `bundlers` in `fx`.
|
|
||||||
```
|
|
||||||
go-bundler: based on Gin
|
|
||||||
ruby-bundler: based on Sinatra
|
|
||||||
node-bundler: based on Koa
|
|
||||||
python-bundler: based on flask
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
package bundler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gobuffalo/packd"
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/constants"
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Bundler defines interface
|
|
||||||
type Bundler interface {
|
|
||||||
Scaffold(output string) error
|
|
||||||
Bundle(output string, fn string, deps ...string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsHandler check if it's handle file
|
|
||||||
func IsHandler(name string, lang string) bool {
|
|
||||||
basename := filepath.Base(name)
|
|
||||||
nameWithoutExt := strings.TrimSuffix(basename, filepath.Ext(basename))
|
|
||||||
if constants.ExtLangMapping[filepath.Ext(basename)] != lang {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return (nameWithoutExt == "fx" ||
|
|
||||||
// Fx is for Java
|
|
||||||
nameWithoutExt == "Fx" ||
|
|
||||||
// mod.rs is for Rust)
|
|
||||||
nameWithoutExt == "mod")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore directory from packr box
|
|
||||||
func Restore(box *packr.Box, output string) error {
|
|
||||||
if err := box.Walk(func(name string, fd packd.File) error {
|
|
||||||
content, err := box.Find(name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dest := filepath.Join(output, name)
|
|
||||||
if err := utils.EnsureFile(dest); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ioutil.WriteFile(dest, content, 0600); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle bundle a function
|
|
||||||
func Bundle(box *packr.Box, output string, language string, fn string, deps ...string) error {
|
|
||||||
if err := Restore(box, output); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.Merge(output, deps...); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace the default handler source file with given function source file
|
|
||||||
if err := filepath.Walk(output, func(path string, info os.FileInfo, err error) error {
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if IsHandler(path, language) {
|
|
||||||
if err := utils.CopyFile(fn, path); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package bundler
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBundler(t *testing.T) {
|
|
||||||
t.Run("Restore", func(t *testing.T) {
|
|
||||||
box := packr.New("", "./node/assets")
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
if err := Restore(box, outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("Bundle", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}`
|
|
||||||
if err = ioutil.WriteFile(fd.Name(), []byte(content), 0666); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
box := packr.New("", "./node/assets")
|
|
||||||
if err := Bundle(box, outputDir, "node", fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package d
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package d
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// D defines d bundler
|
|
||||||
type D struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *D {
|
|
||||||
return &D{
|
|
||||||
assets: packr.New("d", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (d *D) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(d.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (d *D) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(d.assets, output, "d", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &D{}
|
|
||||||
)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package golang
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Gin defines javascript bundler
|
|
||||||
type Gin struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Gin {
|
|
||||||
return &Gin{
|
|
||||||
assets: packr.New("go", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (g *Gin) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(g.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (g *Gin) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(g.assets, output, "go", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Gin{}
|
|
||||||
)
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
package golang
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestKoaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
koa := New()
|
|
||||||
if err := koa.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
koa := New()
|
|
||||||
if err := koa.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/fx.go")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/fx.go")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
koa := New()
|
|
||||||
if err := koa.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package golang
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package java
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package java
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Java defines javascript bundler
|
|
||||||
type Java struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Java {
|
|
||||||
return &Java{
|
|
||||||
assets: packr.New("java", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Java) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Java) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, "java", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Java{}
|
|
||||||
)
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
package java
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJavaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_java")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
java := New()
|
|
||||||
if err := java.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.java")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `package fx;
|
|
||||||
|
|
||||||
import io.javalin.Javalin;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
public class app {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Javalin app = Javalin.start(3000);
|
|
||||||
Fx handler = new Fx();
|
|
||||||
app.post("/", ctx -> {
|
|
||||||
JSONObject obj = new JSONObject(ctx.body());
|
|
||||||
ctx.result(""+handler.handle(obj));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_java")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
java := New()
|
|
||||||
if err := java.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/src/main/java/fx/Fx.java")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/src/main/java/fx/Fx.java")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_java")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
java := New()
|
|
||||||
if err := java.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package julia
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package julia
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Julia defines javascript bundler
|
|
||||||
type Julia struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Julia {
|
|
||||||
return &Julia{
|
|
||||||
assets: packr.New("julia", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Julia) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Julia) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, "julia", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Julia{}
|
|
||||||
)
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package julia
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJuliaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.julia")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `struct Input
|
|
||||||
a::Number
|
|
||||||
b::Number
|
|
||||||
end
|
|
||||||
|
|
||||||
fx = function(input::Input)
|
|
||||||
return input.a + input.b
|
|
||||||
end
|
|
||||||
`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle function should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/fx.jl")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/fx.jl")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package node
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
const language = "node"
|
|
||||||
|
|
||||||
// Node defines node bundler
|
|
||||||
type Node struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Node {
|
|
||||||
return &Node{
|
|
||||||
assets: packr.New("node", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Node) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Node) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, language, fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Node{}
|
|
||||||
)
|
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestNodeBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
koa := New()
|
|
||||||
if err := koa.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `
|
|
||||||
module.exports = (ctx) => {
|
|
||||||
ctx.body = 'hello fx'
|
|
||||||
}`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
koa := New()
|
|
||||||
if err := koa.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/fx.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/fx.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_koa")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
koa := New()
|
|
||||||
if err := koa.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package perl
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package perl
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Julia defines javascript bundler
|
|
||||||
type Julia struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Julia {
|
|
||||||
return &Julia{
|
|
||||||
assets: packr.New("perl", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Julia) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Julia) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, "perl", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Julia{}
|
|
||||||
)
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package perl
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJuliaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.julia")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `struct Input
|
|
||||||
a::Number
|
|
||||||
b::Number
|
|
||||||
end
|
|
||||||
|
|
||||||
fx = function(input::Input)
|
|
||||||
return input.a + input.b
|
|
||||||
end
|
|
||||||
`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle function should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/fx.pl")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/fx.pl")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package python
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package python
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Julia defines javascript bundler
|
|
||||||
type Julia struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Julia {
|
|
||||||
return &Julia{
|
|
||||||
assets: packr.New("python", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Julia) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Julia) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, "python", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Julia{}
|
|
||||||
)
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package python
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJuliaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.julia")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `struct Input
|
|
||||||
a::Number
|
|
||||||
b::Number
|
|
||||||
end
|
|
||||||
|
|
||||||
fx = function(input::Input)
|
|
||||||
return input.a + input.b
|
|
||||||
end
|
|
||||||
`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle function should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/fx.py")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/fx.py")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package ruby
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package ruby
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Julia defines javascript bundler
|
|
||||||
type Julia struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Julia {
|
|
||||||
return &Julia{
|
|
||||||
assets: packr.New("ruby", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Julia) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Julia) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, "ruby", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Julia{}
|
|
||||||
)
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package ruby
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJuliaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.julia")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `struct Input
|
|
||||||
a::Number
|
|
||||||
b::Number
|
|
||||||
end
|
|
||||||
|
|
||||||
fx = function(input::Input)
|
|
||||||
return input.a + input.b
|
|
||||||
end
|
|
||||||
`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle function should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/fx.rb")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/fx.rb")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// +build !skippackr
|
|
||||||
// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT.
|
|
||||||
|
|
||||||
// You can use the "packr clean" command to clean up this,
|
|
||||||
// and any other packr generated files.
|
|
||||||
package rust
|
|
||||||
|
|
||||||
import _ "github.com/metrue/fx/packrd"
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package rust
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
|
||||||
"github.com/metrue/fx/bundler"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Julia defines javascript bundler
|
|
||||||
type Julia struct {
|
|
||||||
assets *packr.Box
|
|
||||||
}
|
|
||||||
|
|
||||||
// New a koa bundler
|
|
||||||
func New() *Julia {
|
|
||||||
return &Julia{
|
|
||||||
assets: packr.New("rust", "./assets"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scaffold a koa app
|
|
||||||
func (k *Julia) Scaffold(output string) error {
|
|
||||||
return bundler.Restore(k.assets, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bundle a function into a koa project
|
|
||||||
func (k *Julia) Bundle(output string, fn string, deps ...string) error {
|
|
||||||
return bundler.Bundle(k.assets, output, "rust", fn, deps...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ bundler.Bundler = &Julia{}
|
|
||||||
)
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package rust
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/metrue/fx/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJuliaBundler(t *testing.T) {
|
|
||||||
t.Run("Scaffold", func(t *testing.T) {
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Scaffold(outputDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, _, _, err := utils.Diff(outputDir, "./assets")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if diff {
|
|
||||||
t.Fatalf("%s is not equal with %s", outputDir, "./assets")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleSingleFunc", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.julia")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content := `struct Input
|
|
||||||
a::Number
|
|
||||||
b::Number
|
|
||||||
end
|
|
||||||
|
|
||||||
fx = function(input::Input)
|
|
||||||
return input.a + input.b
|
|
||||||
end
|
|
||||||
`
|
|
||||||
err = ioutil.WriteFile(fd.Name(), []byte(content), 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle function should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(content)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
|
|
||||||
preHandleFunc, err := ioutil.ReadFile("./assets/src/fns/mod.rs")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(pre, preHandleFunc) {
|
|
||||||
{
|
|
||||||
}
|
|
||||||
t.Fatalf("it should get %s but got %s", preHandleFunc, pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("BundleFuncAndDeps", func(t *testing.T) {
|
|
||||||
fd, err := ioutil.TempFile("", "fx_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.Remove(fd.Name())
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile("./assets/src/fns/mod.rs")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fd.Name(), content, 0666)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
addFunc := `
|
|
||||||
module.exports = (a, b) => a+b
|
|
||||||
`
|
|
||||||
addFd, err := ioutil.TempFile("", "fx_add_func_*.js")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(addFd.Name(), []byte(addFunc), 0644)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputDir, err := ioutil.TempDir("", "fx_julia")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(outputDir)
|
|
||||||
|
|
||||||
julia := New()
|
|
||||||
if err := julia.Bundle(outputDir, fd.Name(), addFd.Name()); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff, pre, cur, err := utils.Diff("./assets", outputDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !diff {
|
|
||||||
t.Fatalf("handle functino should be changed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(cur, []byte(addFunc)) {
|
|
||||||
t.Fatalf("it should be %s but got %s", content, cur)
|
|
||||||
}
|
|
||||||
if pre != nil {
|
|
||||||
t.Fatal(pre)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
207
config/config.go
Normal file
207
config/config.go
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
dockerInfra "github.com/metrue/fx/infra/docker"
|
||||||
|
"github.com/metrue/fx/types"
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Configer manage fx config
|
||||||
|
type Configer interface {
|
||||||
|
GetCurrentCloud() ([]byte, error)
|
||||||
|
GetCurrentCloudType() (string, error)
|
||||||
|
GetKubeConfig() (string, error)
|
||||||
|
UseCloud(name string) error
|
||||||
|
View() ([]byte, error)
|
||||||
|
AddCloud(name string, meta []byte) error
|
||||||
|
Dir() (string, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config config of fx
|
||||||
|
type Config struct {
|
||||||
|
configFile string
|
||||||
|
container *Container
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultFxConfig = "~/.fx/config.yml"
|
||||||
|
|
||||||
|
// LoadDefault load default config
|
||||||
|
func LoadDefault() (*Config, error) {
|
||||||
|
configFile, err := homedir.Expand(defaultFxConfig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if os.Getenv("FX_CONFIG") != "" {
|
||||||
|
configFile = os.Getenv("FX_CONFIG")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(configFile); os.IsNotExist(err) {
|
||||||
|
if err := utils.EnsureFile(configFile); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return load(configFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func load(configFile string) (*Config, error) {
|
||||||
|
container, err := CreateContainer(configFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config := &Config{
|
||||||
|
configFile: configFile,
|
||||||
|
container: container,
|
||||||
|
}
|
||||||
|
|
||||||
|
if container.get("clouds") == nil {
|
||||||
|
if err := config.writeDefaultConfig(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load config
|
||||||
|
func Load(configFile string) (*Config, error) {
|
||||||
|
if configFile == "" {
|
||||||
|
return nil, fmt.Errorf("invalid config file")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(configFile); os.IsNotExist(err) {
|
||||||
|
if err := utils.EnsureFile(configFile); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return load(configFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddCloud add k8s cloud
|
||||||
|
func (c *Config) AddCloud(name string, meta []byte) error {
|
||||||
|
var cloudMeta map[string]interface{}
|
||||||
|
if err := json.Unmarshal(meta, &cloudMeta); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cloudType, ok := cloudMeta["type"].(string)
|
||||||
|
if !ok || cloudType == "" {
|
||||||
|
return fmt.Errorf("unknown cloud type")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cloudType == types.CloudTypeK8S {
|
||||||
|
dir := path.Dir(c.configFile)
|
||||||
|
kubecfg := path.Join(dir, name+".kubeconfig")
|
||||||
|
if err := utils.EnsureFile(kubecfg); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
config, ok := cloudMeta["config"].(string)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("invalid k8s config")
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(kubecfg, []byte(config), 0666); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.container.set("clouds."+name, cloudMeta); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UseCloud set cloud instance with name as current context
|
||||||
|
func (c *Config) UseCloud(name string) error {
|
||||||
|
if name == "" {
|
||||||
|
return fmt.Errorf("could not use empty name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.container.get("clouds."+name) == nil {
|
||||||
|
return fmt.Errorf("no such cloud with name: %s", name)
|
||||||
|
}
|
||||||
|
return c.container.set("current_cloud", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// View view current config
|
||||||
|
func (c *Config) View() ([]byte, error) {
|
||||||
|
return ioutil.ReadFile(c.configFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentCloud get current using cloud's meta
|
||||||
|
func (c *Config) GetCurrentCloud() ([]byte, error) {
|
||||||
|
name, ok := c.container.get("current_cloud").(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("no active cloud")
|
||||||
|
}
|
||||||
|
meta := c.container.get("clouds." + name)
|
||||||
|
if meta == nil {
|
||||||
|
return nil, fmt.Errorf("invalid config")
|
||||||
|
}
|
||||||
|
return json.Marshal(meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentCloudType get current cloud type
|
||||||
|
func (c *Config) GetCurrentCloudType() (string, error) {
|
||||||
|
name, ok := c.container.get("current_cloud").(string)
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("no active cloud")
|
||||||
|
}
|
||||||
|
return c.container.get("clouds." + name + ".type").(string), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetKubeConfig get kubeconfig
|
||||||
|
func (c *Config) GetKubeConfig() (string, error) {
|
||||||
|
name, ok := c.container.get("current_cloud").(string)
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("no active cloud")
|
||||||
|
}
|
||||||
|
dir := path.Dir(c.configFile)
|
||||||
|
kubecfg := path.Join(dir, name+".kubeconfig")
|
||||||
|
return kubecfg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) writeDefaultConfig() error {
|
||||||
|
me, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultCloud := &dockerInfra.Cloud{
|
||||||
|
IP: "127.0.0.1",
|
||||||
|
User: me.Username,
|
||||||
|
Name: "default",
|
||||||
|
Type: types.CloudTypeDocker,
|
||||||
|
}
|
||||||
|
meta, err := defaultCloud.Dump()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := c.container.set("clouds", map[string]interface{}{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := c.AddCloud("default", meta); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return c.UseCloud("default")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dir get directory of config
|
||||||
|
func (c *Config) Dir() (string, error) {
|
||||||
|
p, err := filepath.Abs(c.configFile)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return path.Dir(p), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ Configer = &Config{}
|
||||||
|
)
|
||||||
131
config/config_test.go
Normal file
131
config/config_test.go
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
k8sInfra "github.com/metrue/fx/infra/k8s"
|
||||||
|
"github.com/metrue/fx/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConfig(t *testing.T) {
|
||||||
|
configPath := "./tmp/config.yml"
|
||||||
|
defer func() {
|
||||||
|
if err := os.RemoveAll("./tmp/config.yml"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// default cloud
|
||||||
|
c, err := Load(configPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultMeta, err := c.GetCurrentCloud()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var cloudMeta map[string]string
|
||||||
|
if err := json.Unmarshal(defaultMeta, &cloudMeta); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if cloudMeta["ip"] != "127.0.0.1" {
|
||||||
|
t.Fatalf("should get %s but got %s", "127.0.0.1", cloudMeta["ip"])
|
||||||
|
}
|
||||||
|
|
||||||
|
me, _ := user.Current()
|
||||||
|
if cloudMeta["user"] != me.Username {
|
||||||
|
t.Fatalf("should get %s but got %s", me.Username, cloudMeta["user"])
|
||||||
|
}
|
||||||
|
if cloudMeta["type"] != types.CloudTypeDocker {
|
||||||
|
t.Fatalf("should get %s but got %s", types.CloudTypeDocker, cloudMeta["type"])
|
||||||
|
}
|
||||||
|
if cloudMeta["name"] != "default" {
|
||||||
|
t.Fatalf("should get %s but got %s", "default", cloudMeta["name"])
|
||||||
|
}
|
||||||
|
|
||||||
|
n1, err := k8sInfra.CreateNode(
|
||||||
|
"1.1.1.1",
|
||||||
|
"user-1",
|
||||||
|
"k3s-master",
|
||||||
|
"master-node",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
n2, err := k8sInfra.CreateNode(
|
||||||
|
"1.1.1.1",
|
||||||
|
"user-1",
|
||||||
|
"k3s-agent",
|
||||||
|
"agent-node-1",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
kName := "k8s-1"
|
||||||
|
kubeconf := "./tmp/" + kName + "config.yml"
|
||||||
|
defer func() {
|
||||||
|
if err := os.RemoveAll(kubeconf); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// add k8s cloud
|
||||||
|
kCloud := k8sInfra.NewCloud(kubeconf, n1, n2)
|
||||||
|
kMeta, err := kCloud.Dump()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := c.AddCloud(kName, kMeta); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
curMeta, err := c.GetCurrentCloud()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(curMeta, defaultMeta) {
|
||||||
|
t.Fatalf("should get %v but got %v", defaultMeta, curMeta)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.UseCloud("cloud-not-existed"); err == nil {
|
||||||
|
t.Fatalf("should get error when there is not given cloud name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.UseCloud(kName); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
curMeta, err = c.GetCurrentCloud()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if reflect.DeepEqual(curMeta, kMeta) {
|
||||||
|
t.Fatalf("should get %v but got %v", kMeta, curMeta)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := c.View()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(body))
|
||||||
|
|
||||||
|
dir, err := c.Dir()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
here, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if dir != filepath.Join(here, "./tmp") {
|
||||||
|
t.Fatalf("should get %s but got %s", "./tmp", dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
73
config/container.go
Normal file
73
config/container.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Container config container, wrap viper as a key-value store with lock
|
||||||
|
type Container struct {
|
||||||
|
mux sync.Mutex
|
||||||
|
store string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateContainer new a container
|
||||||
|
func CreateContainer(storeFile string) (*Container, error) {
|
||||||
|
if err := utils.EnsureFile(storeFile); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := filepath.Dir(storeFile)
|
||||||
|
ext := filepath.Ext(storeFile)
|
||||||
|
name := filepath.Base(storeFile)
|
||||||
|
viper.AddConfigPath(dir)
|
||||||
|
viper.SetConfigName(strings.Replace(name, ext, "", 1))
|
||||||
|
viper.SetConfigType(strings.Replace(ext, ".", "", 1))
|
||||||
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &Container{
|
||||||
|
store: storeFile,
|
||||||
|
}, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Container) set(key string, value interface{}) error {
|
||||||
|
c.mux.Lock()
|
||||||
|
defer c.mux.Unlock()
|
||||||
|
|
||||||
|
if key == "" {
|
||||||
|
return fmt.Errorf("empty key not allowed")
|
||||||
|
}
|
||||||
|
|
||||||
|
keys := strings.Split(key, ".")
|
||||||
|
if len(keys) == 1 {
|
||||||
|
viper.Set(key, value)
|
||||||
|
} else {
|
||||||
|
prePath := keys[0]
|
||||||
|
for i := 1; i < len(keys)-2; i++ {
|
||||||
|
prePath += "." + keys[i]
|
||||||
|
}
|
||||||
|
if viper.Get(prePath) == nil {
|
||||||
|
return fmt.Errorf("%s not existed", prePath)
|
||||||
|
}
|
||||||
|
viper.Set(key, value)
|
||||||
|
}
|
||||||
|
// viper.Set(key, value)
|
||||||
|
if err := viper.WriteConfig(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Container) get(key string) interface{} {
|
||||||
|
c.mux.Lock()
|
||||||
|
defer c.mux.Unlock()
|
||||||
|
|
||||||
|
return viper.Get(key)
|
||||||
|
}
|
||||||
84
config/container_test.go
Normal file
84
config/container_test.go
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestContainer(t *testing.T) {
|
||||||
|
configPath := "./tmp/container.yml"
|
||||||
|
defer func() {
|
||||||
|
if err := os.RemoveAll("./tmp/container.yml"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
c, err := CreateContainer(configPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.set("", ""); err == nil {
|
||||||
|
t.Fatalf("should get error when key is empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.get("1") != nil {
|
||||||
|
t.Fatalf("should get %v but got %v", nil, c.get("key"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// create
|
||||||
|
if err := c.set("1", "1"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// read
|
||||||
|
if c.get("1").(string) != "1" {
|
||||||
|
t.Fatalf("should get %s but got %s", "val-1", c.get("key"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// invaliad set
|
||||||
|
if err := c.set("1.1", "1.1"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if c.get("1.1").(string) != "1.1" {
|
||||||
|
t.Fatalf("should get 1.1 but got %s", c.get("1.1"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// update
|
||||||
|
if err := c.set("1", "11"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if c.get("1").(string) != "11" {
|
||||||
|
t.Fatalf("should get 11 but got %s", c.get("1").(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
// nested set
|
||||||
|
if err := c.set("2.2.2.2", "2222"); err == nil {
|
||||||
|
t.Fatalf("should throw error since 2.2.2 not ready yet")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.set("2", map[string]interface{}{
|
||||||
|
"2": map[string]interface{}{
|
||||||
|
"2": "2",
|
||||||
|
},
|
||||||
|
}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.get("2.2.2").(string) != "2" {
|
||||||
|
t.Fatalf("should get 2 but got %s", c.get("2.2.2"))
|
||||||
|
}
|
||||||
|
if err := c.set("2.2.2.2", "2222"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if c.get("2.2.2.2").(string) != "2222" {
|
||||||
|
t.Fatalf("should get 2222 but got %s", c.get("2.2.2.2"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.set("2.2.2.1", "1111"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.get("2.2.2.1").(string) != "1111" {
|
||||||
|
t.Fatalf("should get 1111 but got %s", c.get("2.2.2.1"))
|
||||||
|
}
|
||||||
|
}
|
||||||
14
config/env.go
Normal file
14
config/env.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DisableContainerAutoremove to tell if to run container with --rm
|
||||||
|
var DisableContainerAutoremove = false
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if os.Getenv("DISABLE_CONTAINER_AUTOREMOVE") == "true" {
|
||||||
|
DisableContainerAutoremove = true
|
||||||
|
}
|
||||||
|
}
|
||||||
17
config/env_test.go
Normal file
17
config/env_test.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = func() (_ struct{}) {
|
||||||
|
os.Setenv("DISABLE_CONTAINER_AUTOREMOVE", "true")
|
||||||
|
return
|
||||||
|
}()
|
||||||
|
|
||||||
|
func TestEnvLoad(t *testing.T) {
|
||||||
|
if !DisableContainerAutoremove {
|
||||||
|
t.Fatalf("should be true after set")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package constants
|
|
||||||
|
|
||||||
// ExtLangMapping file extension mapping with programming language
|
|
||||||
var ExtLangMapping = map[string]string{
|
|
||||||
".js": "node",
|
|
||||||
".go": "go",
|
|
||||||
".rb": "ruby",
|
|
||||||
".py": "python",
|
|
||||||
".php": "php",
|
|
||||||
".jl": "julia",
|
|
||||||
".java": "java",
|
|
||||||
".d": "d",
|
|
||||||
".rs": "rust",
|
|
||||||
".pl": "perl",
|
|
||||||
}
|
|
||||||
@@ -18,10 +18,12 @@ import (
|
|||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
dockerTypes "github.com/docker/docker/api/types"
|
dockerTypes "github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
dockerTypesContainer "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
fxConfig "github.com/metrue/fx/config"
|
||||||
containerruntimes "github.com/metrue/fx/container_runtimes"
|
containerruntimes "github.com/metrue/fx/container_runtimes"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
"github.com/metrue/fx/utils"
|
"github.com/metrue/fx/utils"
|
||||||
@@ -30,32 +32,10 @@ import (
|
|||||||
|
|
||||||
// API interact with dockerd http api
|
// API interact with dockerd http api
|
||||||
type API struct {
|
type API struct {
|
||||||
host string
|
|
||||||
port string
|
|
||||||
endpoint string
|
endpoint string
|
||||||
version string
|
version string
|
||||||
}
|
}
|
||||||
|
|
||||||
// New a API
|
|
||||||
func New(host string, port string) *API {
|
|
||||||
return &API{
|
|
||||||
host: host,
|
|
||||||
port: port,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize an API
|
|
||||||
func (api *API) Initialize() error {
|
|
||||||
addr := api.host + ":" + api.port
|
|
||||||
v, err := version(addr)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
endpoint := fmt.Sprintf("http://%s:%s/v%s", api.host, api.port, v)
|
|
||||||
api.endpoint = endpoint
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a API
|
// Create a API
|
||||||
func Create(host string, port string) (*API, error) {
|
func Create(host string, port string) (*API, error) {
|
||||||
addr := host + ":" + port
|
addr := host + ":" + port
|
||||||
@@ -154,8 +134,7 @@ func (api *API) post(path string, body []byte, expectStatus int, v interface{})
|
|||||||
|
|
||||||
// Version get version of docker engine
|
// Version get version of docker engine
|
||||||
func (api *API) Version(ctx context.Context) (string, error) {
|
func (api *API) Version(ctx context.Context) (string, error) {
|
||||||
addr := api.host + ":" + api.port
|
return version(api.endpoint)
|
||||||
return version(addr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func version(endpoint string) (string, error) {
|
func version(endpoint string) (string, error) {
|
||||||
@@ -418,13 +397,13 @@ func (api *API) StartContainer(ctx context.Context, name string, image string, b
|
|||||||
portSet[port] = struct{}{}
|
portSet[port] = struct{}{}
|
||||||
portMap[port] = bindings
|
portMap[port] = bindings
|
||||||
}
|
}
|
||||||
config := &container.Config{
|
config := &dockerTypesContainer.Config{
|
||||||
Image: image,
|
Image: image,
|
||||||
ExposedPorts: portSet,
|
ExposedPorts: portSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
hostConfig := &container.HostConfig{
|
hostConfig := &dockerTypesContainer.HostConfig{
|
||||||
AutoRemove: false,
|
AutoRemove: !fxConfig.DisableContainerAutoremove,
|
||||||
PortBindings: portMap,
|
PortBindings: portMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,82 +453,11 @@ func (api *API) StartContainer(ctx context.Context, name string, image string, b
|
|||||||
return errors.New(msg)
|
return errors.New(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait seconds for container starting
|
if _, err = api.inspect(createRes.ID); err != nil {
|
||||||
time.Sleep(3 * time.Second)
|
msg := fmt.Sprintf("inspect container %s error", name)
|
||||||
|
return errors.Wrap(err, msg)
|
||||||
info, err := api.inspect(createRes.ID)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "failed to inspect container "+createRes.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !info.State.Running {
|
|
||||||
logs, err := api.logs(createRes.ID)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "could not get logs of container "+createRes.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := api.RemoveContainer(ctx, createRes.ID); err != nil {
|
|
||||||
msg := fmt.Sprintf("remove container %s failed, and container started with logs: %s", createRes.ID, string(logs))
|
|
||||||
return errors.Wrap(err, msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Errorf("container start failure: %s", logs)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (api *API) logs(id string) ([]byte, error) {
|
|
||||||
query := url.Values{}
|
|
||||||
query.Set("stdout", "true")
|
|
||||||
query.Set("stderr", "true")
|
|
||||||
path := fmt.Sprintf("/containers/%s/logs?%s", id, query.Encode())
|
|
||||||
url := fmt.Sprintf("%s%s", api.endpoint, path)
|
|
||||||
request, err := http.NewRequest("GET", url, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
client := &http.Client{Timeout: 20 * time.Second}
|
|
||||||
resp, err := client.Do(request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode == 200 {
|
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return b, nil
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("get logs of container %s failed: %d", id, resp.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveContainer remove a container
|
|
||||||
func (api *API) RemoveContainer(ctx context.Context, id string) error {
|
|
||||||
query := url.Values{}
|
|
||||||
query.Set("v", "true")
|
|
||||||
path := fmt.Sprintf("/containers/%s?%s", id, query.Encode())
|
|
||||||
url := fmt.Sprintf("%s%s", api.endpoint, path)
|
|
||||||
request, err := http.NewRequest("DELETE", url, nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
client := &http.Client{Timeout: 20 * time.Second}
|
|
||||||
resp, err := client.Do(request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
output, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "read response body of remove container request failed")
|
|
||||||
}
|
|
||||||
if resp.StatusCode != 204 {
|
|
||||||
return fmt.Errorf("could not remove container %s: %s", id, string(output))
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM node:alpine
|
FROM node:latest
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
fxConfig "github.com/metrue/fx/config"
|
||||||
containerruntimes "github.com/metrue/fx/container_runtimes"
|
containerruntimes "github.com/metrue/fx/container_runtimes"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
"github.com/metrue/fx/utils"
|
"github.com/metrue/fx/utils"
|
||||||
@@ -161,7 +162,7 @@ func (d *Docker) StartContainer(ctx context.Context, name string, image string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hostConfig := &dockerTypesContainer.HostConfig{
|
hostConfig := &dockerTypesContainer.HostConfig{
|
||||||
AutoRemove: false,
|
AutoRemove: !fxConfig.DisableContainerAutoremove,
|
||||||
PortBindings: portMap,
|
PortBindings: portMap,
|
||||||
}
|
}
|
||||||
resp, err := d.ContainerCreate(ctx, config, hostConfig, nil, name)
|
resp, err := d.ContainerCreate(ctx, config, hostConfig, nil, name)
|
||||||
@@ -244,11 +245,6 @@ func (d *Docker) Version(ctx context.Context) (string, error) {
|
|||||||
return ping.APIVersion, nil
|
return ping.APIVersion, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveContainer remove container
|
|
||||||
func (d *Docker) RemoveContainer(ctx context.Context, id string) error {
|
|
||||||
panic("no implemented yet")
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ containerruntimes.ContainerRuntime = &Docker{}
|
_ containerruntimes.ContainerRuntime = &Docker{}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
// Code generated by MockGen. DO NOT EDIT.
|
|
||||||
// Source: runtimes.go
|
|
||||||
|
|
||||||
// Package mock_containerruntimes is a generated GoMock package.
|
|
||||||
package mock_containerruntimes
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
types "github.com/metrue/fx/types"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MockContainerRuntime is a mock of ContainerRuntime interface
|
|
||||||
type MockContainerRuntime struct {
|
|
||||||
ctrl *gomock.Controller
|
|
||||||
recorder *MockContainerRuntimeMockRecorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockContainerRuntimeMockRecorder is the mock recorder for MockContainerRuntime
|
|
||||||
type MockContainerRuntimeMockRecorder struct {
|
|
||||||
mock *MockContainerRuntime
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMockContainerRuntime creates a new mock instance
|
|
||||||
func NewMockContainerRuntime(ctrl *gomock.Controller) *MockContainerRuntime {
|
|
||||||
mock := &MockContainerRuntime{ctrl: ctrl}
|
|
||||||
mock.recorder = &MockContainerRuntimeMockRecorder{mock}
|
|
||||||
return mock
|
|
||||||
}
|
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
|
||||||
func (m *MockContainerRuntime) EXPECT() *MockContainerRuntimeMockRecorder {
|
|
||||||
return m.recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildImage mocks base method
|
|
||||||
func (m *MockContainerRuntime) BuildImage(ctx context.Context, workdir, name string) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "BuildImage", ctx, workdir, name)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildImage indicates an expected call of BuildImage
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) BuildImage(ctx, workdir, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuildImage", reflect.TypeOf((*MockContainerRuntime)(nil).BuildImage), ctx, workdir, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushImage mocks base method
|
|
||||||
func (m *MockContainerRuntime) PushImage(ctx context.Context, name string) (string, error) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "PushImage", ctx, name)
|
|
||||||
ret0, _ := ret[0].(string)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushImage indicates an expected call of PushImage
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) PushImage(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PushImage", reflect.TypeOf((*MockContainerRuntime)(nil).PushImage), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InspectImage mocks base method
|
|
||||||
func (m *MockContainerRuntime) InspectImage(ctx context.Context, name string, img interface{}) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "InspectImage", ctx, name, img)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// InspectImage indicates an expected call of InspectImage
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) InspectImage(ctx, name, img interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InspectImage", reflect.TypeOf((*MockContainerRuntime)(nil).InspectImage), ctx, name, img)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TagImage mocks base method
|
|
||||||
func (m *MockContainerRuntime) TagImage(ctx context.Context, name, tag string) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "TagImage", ctx, name, tag)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// TagImage indicates an expected call of TagImage
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) TagImage(ctx, name, tag interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TagImage", reflect.TypeOf((*MockContainerRuntime)(nil).TagImage), ctx, name, tag)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StartContainer mocks base method
|
|
||||||
func (m *MockContainerRuntime) StartContainer(ctx context.Context, name, image string, bindings []types.PortBinding) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "StartContainer", ctx, name, image, bindings)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// StartContainer indicates an expected call of StartContainer
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) StartContainer(ctx, name, image, bindings interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartContainer", reflect.TypeOf((*MockContainerRuntime)(nil).StartContainer), ctx, name, image, bindings)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StopContainer mocks base method
|
|
||||||
func (m *MockContainerRuntime) StopContainer(ctx context.Context, name string) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "StopContainer", ctx, name)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// StopContainer indicates an expected call of StopContainer
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) StopContainer(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopContainer", reflect.TypeOf((*MockContainerRuntime)(nil).StopContainer), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveContainer mocks base method
|
|
||||||
func (m *MockContainerRuntime) RemoveContainer(ctx context.Context, name string) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "RemoveContainer", ctx, name)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoveContainer indicates an expected call of RemoveContainer
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) RemoveContainer(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveContainer", reflect.TypeOf((*MockContainerRuntime)(nil).RemoveContainer), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InspectContainer mocks base method
|
|
||||||
func (m *MockContainerRuntime) InspectContainer(ctx context.Context, name string, container interface{}) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "InspectContainer", ctx, name, container)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// InspectContainer indicates an expected call of InspectContainer
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) InspectContainer(ctx, name, container interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InspectContainer", reflect.TypeOf((*MockContainerRuntime)(nil).InspectContainer), ctx, name, container)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListContainer mocks base method
|
|
||||||
func (m *MockContainerRuntime) ListContainer(ctx context.Context, filter string) ([]types.Service, error) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "ListContainer", ctx, filter)
|
|
||||||
ret0, _ := ret[0].([]types.Service)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListContainer indicates an expected call of ListContainer
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) ListContainer(ctx, filter interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListContainer", reflect.TypeOf((*MockContainerRuntime)(nil).ListContainer), ctx, filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version mocks base method
|
|
||||||
func (m *MockContainerRuntime) Version(ctx context.Context) (string, error) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Version", ctx)
|
|
||||||
ret0, _ := ret[0].(string)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version indicates an expected call of Version
|
|
||||||
func (mr *MockContainerRuntimeMockRecorder) Version(ctx interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Version", reflect.TypeOf((*MockContainerRuntime)(nil).Version), ctx)
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,6 @@ type ContainerRuntime interface {
|
|||||||
TagImage(ctx context.Context, name string, tag string) error
|
TagImage(ctx context.Context, name string, tag string) error
|
||||||
StartContainer(ctx context.Context, name string, image string, bindings []types.PortBinding) error
|
StartContainer(ctx context.Context, name string, image string, bindings []types.PortBinding) error
|
||||||
StopContainer(ctx context.Context, name string) error
|
StopContainer(ctx context.Context, name string) error
|
||||||
RemoveContainer(ctx context.Context, name string) error
|
|
||||||
InspectContainer(ctx context.Context, name string, container interface{}) error
|
InspectContainer(ctx context.Context, name string, container interface{}) error
|
||||||
ListContainer(ctx context.Context, filter string) ([]types.Service, error)
|
ListContainer(ctx context.Context, filter string) ([]types.Service, error)
|
||||||
Version(ctx context.Context) (string, error)
|
Version(ctx context.Context) (string, error)
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ func (ctx *Context) GetCliContext() *cli.Context {
|
|||||||
|
|
||||||
// Set a value with name
|
// Set a value with name
|
||||||
func (ctx *Context) Set(name string, value interface{}) {
|
func (ctx *Context) Set(name string, value interface{}) {
|
||||||
// nolint
|
|
||||||
newCtx := context.WithValue(ctx.Context, name, value)
|
newCtx := context.WithValue(ctx.Context, name, value)
|
||||||
ctx.Context = newCtx
|
ctx.Context = newCtx
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,26 +36,11 @@ $ curl 127.0.0.1:2000
|
|||||||
|
|
||||||
## Deploy a function onto remote host
|
## Deploy a function onto remote host
|
||||||
|
|
||||||
* make sure you can ssh login to target host with root
|
* make sure your instance can be ssh login
|
||||||
|
|
||||||
Update `/etc/ssh/sshd_config` to allow login with root.
|
|
||||||
|
|
||||||
```
|
|
||||||
PermitRootLogin yes
|
|
||||||
```
|
|
||||||
|
|
||||||
Then restart sshd with,
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ sudo service sshd restart
|
|
||||||
```
|
|
||||||
|
|
||||||
* make sure your instance accept port 8866
|
* make sure your instance accept port 8866
|
||||||
|
|
||||||
[FYI](https://lightsail.aws.amazon.com/ls/docs/en_us/articles/understanding-firewall-and-port-mappings-in-amazon-lightsail)
|
|
||||||
|
|
||||||
then you can deploy function to remote host
|
then you can deploy function to remote host
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
fx up --host root@<your host> test/functions/func.js
|
DOCKER_REMOTE_HOST_ADDR=<your host> DOCKER_REMOTE_HOST_USER=<your user> DOCKER_REMOTE_HOST_PASSWORD=<your password> fx up -p 2000 test/functions/func.js
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
package docker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
|
||||||
dockerMock "github.com/metrue/fx/container_runtimes/mocks"
|
|
||||||
"github.com/metrue/fx/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDriverPing(t *testing.T) {
|
|
||||||
ctrl := gomock.NewController(t)
|
|
||||||
defer ctrl.Finish()
|
|
||||||
|
|
||||||
dockerClient := dockerMock.NewMockContainerRuntime(ctrl)
|
|
||||||
n := New(Options{
|
|
||||||
DockerClient: dockerClient,
|
|
||||||
})
|
|
||||||
ctx := context.Background()
|
|
||||||
dockerClient.EXPECT().Version(ctx).Return("", nil)
|
|
||||||
if err := n.Ping(ctx); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDriverDeploy(t *testing.T) {
|
|
||||||
ctrl := gomock.NewController(t)
|
|
||||||
defer ctrl.Finish()
|
|
||||||
|
|
||||||
dockerClient := dockerMock.NewMockContainerRuntime(ctrl)
|
|
||||||
n := New(Options{
|
|
||||||
DockerClient: dockerClient,
|
|
||||||
})
|
|
||||||
ctx := context.Background()
|
|
||||||
fn := "fn"
|
|
||||||
name := "name"
|
|
||||||
image := "image"
|
|
||||||
ports := []types.PortBinding{}
|
|
||||||
dockerClient.EXPECT().StartContainer(ctx, name, image, ports).Return(nil)
|
|
||||||
if err := n.Deploy(ctx, fn, name, image, ports); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDriverDestroy(t *testing.T) {
|
|
||||||
ctrl := gomock.NewController(t)
|
|
||||||
defer ctrl.Finish()
|
|
||||||
|
|
||||||
dockerClient := dockerMock.NewMockContainerRuntime(ctrl)
|
|
||||||
n := New(Options{
|
|
||||||
DockerClient: dockerClient,
|
|
||||||
})
|
|
||||||
ctx := context.Background()
|
|
||||||
name := "name"
|
|
||||||
dockerClient.EXPECT().StopContainer(ctx, name).Return(nil)
|
|
||||||
dockerClient.EXPECT().RemoveContainer(ctx, name).Return(nil)
|
|
||||||
if err := n.Destroy(ctx, name); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDriverGetStatus(t *testing.T) {
|
|
||||||
ctrl := gomock.NewController(t)
|
|
||||||
defer ctrl.Finish()
|
|
||||||
|
|
||||||
dockerClient := dockerMock.NewMockContainerRuntime(ctrl)
|
|
||||||
n := New(Options{
|
|
||||||
DockerClient: dockerClient,
|
|
||||||
})
|
|
||||||
ctx := context.Background()
|
|
||||||
name := "name"
|
|
||||||
err := errors.New("no such container")
|
|
||||||
dockerClient.EXPECT().InspectContainer(ctx, name, gomock.Any()).Return(err)
|
|
||||||
if _, err := n.GetStatus(ctx, name); err == nil {
|
|
||||||
t.Fatalf("should get error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestList(t *testing.T) {
|
|
||||||
ctrl := gomock.NewController(t)
|
|
||||||
defer ctrl.Finish()
|
|
||||||
|
|
||||||
dockerClient := dockerMock.NewMockContainerRuntime(ctrl)
|
|
||||||
n := New(Options{
|
|
||||||
DockerClient: dockerClient,
|
|
||||||
})
|
|
||||||
ctx := context.Background()
|
|
||||||
name := "name"
|
|
||||||
dockerClient.EXPECT().ListContainer(ctx, name).Return(nil, nil)
|
|
||||||
if _, err := n.List(ctx, name); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
// Code generated by MockGen. DO NOT EDIT.
|
|
||||||
// Source: driver.go
|
|
||||||
|
|
||||||
// Package mock_driver is a generated GoMock package.
|
|
||||||
package mock_driver
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
types "github.com/metrue/fx/types"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MockDriver is a mock of Driver interface
|
|
||||||
type MockDriver struct {
|
|
||||||
ctrl *gomock.Controller
|
|
||||||
recorder *MockDriverMockRecorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockDriverMockRecorder is the mock recorder for MockDriver
|
|
||||||
type MockDriverMockRecorder struct {
|
|
||||||
mock *MockDriver
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMockDriver creates a new mock instance
|
|
||||||
func NewMockDriver(ctrl *gomock.Controller) *MockDriver {
|
|
||||||
mock := &MockDriver{ctrl: ctrl}
|
|
||||||
mock.recorder = &MockDriverMockRecorder{mock}
|
|
||||||
return mock
|
|
||||||
}
|
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
|
||||||
func (m *MockDriver) EXPECT() *MockDriverMockRecorder {
|
|
||||||
return m.recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deploy mocks base method
|
|
||||||
func (m *MockDriver) Deploy(ctx context.Context, fn, name, image string, bindings []types.PortBinding) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Deploy", ctx, fn, name, image, bindings)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deploy indicates an expected call of Deploy
|
|
||||||
func (mr *MockDriverMockRecorder) Deploy(ctx, fn, name, image, bindings interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockDriver)(nil).Deploy), ctx, fn, name, image, bindings)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provision mocks base method
|
|
||||||
func (m *MockDriver) Provision(ctx context.Context) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Provision", ctx)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provision indicates an expected call of Provision
|
|
||||||
func (mr *MockDriverMockRecorder) Provision(ctx interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Provision", reflect.TypeOf((*MockDriver)(nil).Provision), ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy mocks base method
|
|
||||||
func (m *MockDriver) Destroy(ctx context.Context, name string) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Destroy", ctx, name)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy indicates an expected call of Destroy
|
|
||||||
func (mr *MockDriverMockRecorder) Destroy(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Destroy", reflect.TypeOf((*MockDriver)(nil).Destroy), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update mocks base method
|
|
||||||
func (m *MockDriver) Update(ctx context.Context, name string) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Update", ctx, name)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update indicates an expected call of Update
|
|
||||||
func (mr *MockDriverMockRecorder) Update(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockDriver)(nil).Update), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStatus mocks base method
|
|
||||||
func (m *MockDriver) GetStatus(ctx context.Context, name string) (types.Service, error) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "GetStatus", ctx, name)
|
|
||||||
ret0, _ := ret[0].(types.Service)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStatus indicates an expected call of GetStatus
|
|
||||||
func (mr *MockDriverMockRecorder) GetStatus(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatus", reflect.TypeOf((*MockDriver)(nil).GetStatus), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// List mocks base method
|
|
||||||
func (m *MockDriver) List(ctx context.Context, name string) ([]types.Service, error) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "List", ctx, name)
|
|
||||||
ret0, _ := ret[0].([]types.Service)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// List indicates an expected call of List
|
|
||||||
func (mr *MockDriverMockRecorder) List(ctx, name interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockDriver)(nil).List), ctx, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ping mocks base method
|
|
||||||
func (m *MockDriver) Ping(ctx context.Context) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "Ping", ctx)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ping indicates an expected call of Ping
|
|
||||||
func (mr *MockDriverMockRecorder) Ping(ctx interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ping", reflect.TypeOf((*MockDriver)(nil).Ping), ctx)
|
|
||||||
}
|
|
||||||
196
fx.go
196
fx.go
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
@@ -14,12 +13,11 @@ import (
|
|||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
"github.com/metrue/fx/handlers"
|
"github.com/metrue/fx/handlers"
|
||||||
"github.com/metrue/fx/middlewares"
|
"github.com/metrue/fx/middlewares"
|
||||||
"github.com/mitchellh/go-homedir"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.9.42"
|
const version = "0.8.87"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
go checkForUpdate()
|
go checkForUpdate()
|
||||||
@@ -77,21 +75,63 @@ func main() {
|
|||||||
fmt.Println(aurora.Red("*****************"))
|
fmt.Println(aurora.Red("*****************"))
|
||||||
fmt.Println(r)
|
fmt.Println(r)
|
||||||
fmt.Println(aurora.Red("*****************"))
|
fmt.Println(aurora.Red("*****************"))
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
user, err := user.Current()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defaultHost := user.Username + "@localhost"
|
|
||||||
|
|
||||||
defaultSSHKeyFile, err := homedir.Expand("~/.ssh/id_rsa")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
|
{
|
||||||
|
Name: "infra",
|
||||||
|
Usage: "manage infrastructure",
|
||||||
|
Subcommands: []cli.Command{
|
||||||
|
{
|
||||||
|
Name: "create",
|
||||||
|
Usage: "create a infra for fx service",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "type, t",
|
||||||
|
Usage: "infracture type, 'docker', 'k8s' and 'k3s' support",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "name, n",
|
||||||
|
Usage: "name to identify the infrastructure",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "host",
|
||||||
|
Usage: "user and ip of your host, eg. 'root@182.12.1.12'",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "master",
|
||||||
|
Usage: "serve as master node in K3S cluster, eg. 'root@182.12.1.12'",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "agents",
|
||||||
|
Usage: "serve as agent node in K3S cluster, eg. 'root@187.1. 2. 3,root@123.3.2.1'",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Action: handle(
|
||||||
|
middlewares.LoadConfig,
|
||||||
|
handlers.Setup,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "list",
|
||||||
|
Usage: "list all infrastructures",
|
||||||
|
Action: handle(
|
||||||
|
middlewares.LoadConfig,
|
||||||
|
handlers.ListInfra,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "use",
|
||||||
|
Usage: "set current context to target cloud with given name",
|
||||||
|
Action: handle(
|
||||||
|
middlewares.LoadConfig,
|
||||||
|
handlers.UseInfra,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "up",
|
Name: "up",
|
||||||
Usage: "deploy a function",
|
Usage: "deploy a function",
|
||||||
@@ -106,25 +146,6 @@ func main() {
|
|||||||
Name: "port, p",
|
Name: "port, p",
|
||||||
Usage: "port number",
|
Usage: "port number",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "host, H",
|
|
||||||
Usage: "target host, <user>@<host>",
|
|
||||||
Value: defaultHost,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_port, P",
|
|
||||||
Usage: "SSH port for target host",
|
|
||||||
Value: "22",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_key, K",
|
|
||||||
Usage: "SSH key file for login target host",
|
|
||||||
Value: defaultSSHKeyFile,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "kubeconf, C",
|
|
||||||
Usage: "kubeconf of kubernetes cluster",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "healthcheck, hc",
|
Name: "healthcheck, hc",
|
||||||
Usage: "do a health check after service up",
|
Usage: "do a health check after service up",
|
||||||
@@ -135,11 +156,10 @@ func main() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: handle(
|
Action: handle(
|
||||||
|
middlewares.LoadConfig,
|
||||||
|
middlewares.Provision,
|
||||||
middlewares.Parse("up"),
|
middlewares.Parse("up"),
|
||||||
middlewares.Language(),
|
|
||||||
middlewares.Binding,
|
middlewares.Binding,
|
||||||
middlewares.SSH,
|
|
||||||
middlewares.Driver,
|
|
||||||
middlewares.Build,
|
middlewares.Build,
|
||||||
handlers.Up,
|
handlers.Up,
|
||||||
),
|
),
|
||||||
@@ -148,31 +168,10 @@ func main() {
|
|||||||
Name: "down",
|
Name: "down",
|
||||||
Usage: "destroy a service",
|
Usage: "destroy a service",
|
||||||
ArgsUsage: "[service 1, service 2, ....]",
|
ArgsUsage: "[service 1, service 2, ....]",
|
||||||
Flags: []cli.Flag{
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_port, P",
|
|
||||||
Usage: "SSH port for target host",
|
|
||||||
Value: "22",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_key, K",
|
|
||||||
Usage: "SSH key file for login target host",
|
|
||||||
Value: defaultSSHKeyFile,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "host, H",
|
|
||||||
Usage: "target host, <user>@<host>",
|
|
||||||
Value: defaultHost,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "kubeconf, C",
|
|
||||||
Usage: "kubeconf of kubernetes cluster",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Action: handle(
|
Action: handle(
|
||||||
middlewares.Parse("down"),
|
middlewares.Parse("down"),
|
||||||
middlewares.SSH,
|
middlewares.LoadConfig,
|
||||||
middlewares.Driver,
|
middlewares.Provision,
|
||||||
handlers.Down,
|
handlers.Down,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -180,39 +179,24 @@ 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",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_port, P",
|
|
||||||
Usage: "SSH port for target host",
|
|
||||||
Value: "22",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_key, K",
|
|
||||||
Usage: "SSH key file for login target host",
|
|
||||||
Value: defaultSSHKeyFile,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "host, H",
|
|
||||||
Usage: "target host, <user>@<host>",
|
|
||||||
Value: defaultHost,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "kubeconf, C",
|
|
||||||
Usage: "kubeconf of kubernetes cluster",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Action: handle(
|
Action: handle(
|
||||||
middlewares.Parse("list"),
|
middlewares.Parse("list"),
|
||||||
middlewares.SSH,
|
middlewares.LoadConfig,
|
||||||
middlewares.Driver,
|
middlewares.Provision,
|
||||||
handlers.List,
|
handlers.List,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "call",
|
||||||
|
Usage: "run a function instantly",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "host, H",
|
||||||
|
Usage: "fx server host, default is localhost",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: handle(handlers.Call),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "image",
|
Name: "image",
|
||||||
Usage: "manage image of service",
|
Usage: "manage image of service",
|
||||||
@@ -222,36 +206,14 @@ func main() {
|
|||||||
Usage: "build a image",
|
Usage: "build a image",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "ssh_port, P",
|
Name: "tag, t",
|
||||||
Usage: "SSH port for target host",
|
Usage: "image tag",
|
||||||
Value: "22",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh_key, K",
|
|
||||||
Usage: "SSH key file for login target host",
|
|
||||||
Value: defaultSSHKeyFile,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "host, H",
|
|
||||||
Usage: "target host, <user>@<host>",
|
|
||||||
Value: defaultHost,
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "kubeconf, C",
|
|
||||||
Usage: "kubeconf of kubernetes cluster",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "name, n",
|
|
||||||
Usage: "image name",
|
|
||||||
Value: uuid.New().String(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: handle(
|
Action: handle(
|
||||||
|
middlewares.LoadConfig,
|
||||||
|
middlewares.Provision,
|
||||||
middlewares.Parse("image_build"),
|
middlewares.Parse("image_build"),
|
||||||
middlewares.Language(),
|
|
||||||
middlewares.SSH,
|
|
||||||
middlewares.Driver,
|
|
||||||
middlewares.Build,
|
|
||||||
handlers.BuildImage,
|
handlers.BuildImage,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -265,13 +227,19 @@ func main() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: handle(
|
Action: handle(
|
||||||
|
middlewares.LoadConfig,
|
||||||
|
middlewares.Provision,
|
||||||
middlewares.Parse("image_export"),
|
middlewares.Parse("image_export"),
|
||||||
middlewares.Language(),
|
|
||||||
handlers.ExportImage,
|
handlers.ExportImage,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "doctor",
|
||||||
|
Usage: "health check for fx",
|
||||||
|
Action: handle(handlers.Doctor),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
|||||||
27
go.mod
27
go.mod
@@ -5,17 +5,17 @@ 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.4
|
github.com/apex/log v1.1.1
|
||||||
github.com/cheggaaa/pb/v3 v3.0.4
|
github.com/briandowns/spinner v1.7.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
|
||||||
github.com/docker/go-units v0.3.3 // indirect
|
github.com/docker/go-units v0.3.3 // indirect
|
||||||
github.com/dsnet/compress v0.0.1 // indirect
|
github.com/dsnet/compress v0.0.1 // indirect
|
||||||
github.com/gin-gonic/gin v1.6.3
|
github.com/gin-gonic/gin v1.4.0
|
||||||
github.com/gobuffalo/packd v1.0.0
|
github.com/gobuffalo/envy v1.8.1 // indirect
|
||||||
github.com/gobuffalo/packr/v2 v2.8.0
|
github.com/gobuffalo/packr v1.30.1
|
||||||
github.com/golang/mock v1.4.3
|
github.com/golang/mock v1.3.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
|
||||||
@@ -23,7 +23,7 @@ require (
|
|||||||
github.com/gorilla/mux v1.7.3 // indirect
|
github.com/gorilla/mux v1.7.3 // indirect
|
||||||
github.com/imdario/mergo v0.3.7 // indirect
|
github.com/imdario/mergo v0.3.7 // indirect
|
||||||
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434
|
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434
|
||||||
github.com/metrue/go-ssh-client v0.0.0-20200317072149-19d54050aefd
|
github.com/metrue/go-ssh-client v0.0.0-20191219103445-1f07b67e2b29
|
||||||
github.com/mholt/archiver v3.1.1+incompatible
|
github.com/mholt/archiver v3.1.1+incompatible
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/morikuni/aec v1.0.0 // indirect
|
github.com/morikuni/aec v1.0.0 // indirect
|
||||||
@@ -31,16 +31,21 @@ require (
|
|||||||
github.com/olekukonko/tablewriter v0.0.4
|
github.com/olekukonko/tablewriter v0.0.4
|
||||||
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
|
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
|
||||||
github.com/opencontainers/image-spec v1.0.1 // indirect
|
github.com/opencontainers/image-spec v1.0.1 // indirect
|
||||||
github.com/otiai10/copy v1.1.1
|
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.9.1
|
github.com/pkg/errors v0.8.1
|
||||||
|
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/stretchr/testify v1.5.1
|
github.com/spf13/viper v1.6.1
|
||||||
github.com/urfave/cli v1.22.4
|
github.com/stretchr/testify v1.4.0
|
||||||
|
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
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915 // indirect
|
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.2.7 // indirect
|
||||||
gotest.tools v2.2.0+incompatible // indirect
|
gotest.tools v2.2.0+incompatible // indirect
|
||||||
k8s.io/api v0.0.0-20190925180651-d58b53da08f5
|
k8s.io/api v0.0.0-20190925180651-d58b53da08f5
|
||||||
k8s.io/apimachinery v0.0.0-20190925235427-62598f38f24e
|
k8s.io/apimachinery v0.0.0-20190925235427-62598f38f24e
|
||||||
|
|||||||
169
go.sum
169
go.sum
@@ -19,13 +19,10 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
|
|||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
|
|
||||||
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
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.4 h1:3Zk+boorIQAAGBrHn0JUtAau4ihMamT4WdnfdnXM1zQ=
|
github.com/apex/log v1.1.1 h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA=
|
||||||
github.com/apex/log v1.1.4/go.mod h1:AlpoD9aScyQfJDVHmLMEcx4oU6LqzkWp4Mg9GdAcEvQ=
|
github.com/apex/log v1.1.1/go.mod h1:Ls949n1HFtXfbDcjiTTFQqkVUrte0puoIBfO3SVgwOA=
|
||||||
github.com/apex/logs v0.0.4/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=
|
||||||
@@ -33,19 +30,20 @@ github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
|
|||||||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
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/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/cheggaaa/pb/v3 v3.0.4 h1:QZEPYOj2ix6d5oEg63fbHmpolrnNiwjUsk+h74Yt4bM=
|
|
||||||
github.com/cheggaaa/pb/v3 v3.0.4/go.mod h1:7rgWxLrAUcFMkvJuv09+DYi7mMUYi8nO9iOWcvGJPfw=
|
|
||||||
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=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
|
||||||
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
@@ -75,10 +73,10 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
|
|||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ=
|
||||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
@@ -87,21 +85,19 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+
|
|||||||
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||||
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||||
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
|
||||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
|
||||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
|
||||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
|
||||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
|
||||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
|
||||||
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
|
|
||||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/gobuffalo/logger v1.0.3 h1:YaXOTHNPCvkqqA7w05A4v0k2tCdpr+sgFlgINbQ6gqc=
|
github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=
|
||||||
github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM=
|
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||||
github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM=
|
github.com/gobuffalo/envy v1.8.1 h1:RUr68liRvs0TS1D5qdW3mQv2SjAsu1QWMCx1tG4kDjs=
|
||||||
github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fdec9hrhI=
|
github.com/gobuffalo/envy v1.8.1/go.mod h1:FurDp9+EDPE4aIUS3ZLyD+7/9fpx7YRt/ukY6jIHf0w=
|
||||||
github.com/gobuffalo/packr/v2 v2.8.0 h1:IULGd15bQL59ijXLxEvA5wlMxsmx/ZkQv9T282zNVIY=
|
github.com/gobuffalo/logger v1.0.0 h1:xw9Ko9EcC5iAFprrjJ6oZco9UpzS5MQ4jAwghsLHdy4=
|
||||||
github.com/gobuffalo/packr/v2 v2.8.0/go.mod h1:PDk2k3vGevNE3SwVyVRgQCCXETC9SaONCNSXT1Q8M1g=
|
github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
|
||||||
|
github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=
|
||||||
|
github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
|
||||||
|
github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=
|
||||||
|
github.com/gobuffalo/packr v1.30.1/go.mod h1:ljMyFO2EcrnzsHsN99cvbq055Y9OhRrIaviy289eRuk=
|
||||||
|
github.com/gobuffalo/packr/v2 v2.5.1 h1:TFOeY2VoGamPjQLiNDT3mn//ytzk236VMO2j7iHxJR4=
|
||||||
|
github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
|
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
|
||||||
@@ -114,15 +110,11 @@ 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.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
|
|
||||||
github.com/golang/mock v1.4.3/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=
|
||||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
|
|
||||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
|
||||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
@@ -144,6 +136,8 @@ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsC
|
|||||||
github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk=
|
github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk=
|
||||||
github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU=
|
github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU=
|
||||||
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
|
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
@@ -162,17 +156,20 @@ github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
|
|||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
|
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
|
||||||
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
|
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
|
||||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
|
||||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/karrick/godirwalk v1.15.3 h1:0a2pXOgtB16CqIqXTiT7+K9L73f74n/aNQUnH6Ortew=
|
github.com/karrick/godirwalk v1.10.12 h1:BqUm+LuJcXjGv1d2mj3gBiQyrQ57a0rYoAmhvJQ7RDU=
|
||||||
github.com/karrick/godirwalk v1.15.3/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
|
github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
@@ -187,33 +184,26 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
|
||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
|
||||||
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434 h1:im9kkmH0WWwxzegiv18gSUJbuXR9y028rXrWuPp6Jug=
|
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434 h1:im9kkmH0WWwxzegiv18gSUJbuXR9y028rXrWuPp6Jug=
|
||||||
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
|
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||||
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI=
|
|
||||||
github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc=
|
|
||||||
github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY=
|
|
||||||
github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI=
|
|
||||||
github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI=
|
|
||||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
|
||||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
|
||||||
|
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
|
||||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
|
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
|
||||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/metrue/go-ssh-client v0.0.0-20200317072149-19d54050aefd h1:HoDa3tI6njhpyhu7aIcIfib8QugB66ILgYRLc5IuP6s=
|
github.com/metrue/go-ssh-client v0.0.0-20191219103445-1f07b67e2b29 h1:ENoMPMVc24XbBuVZ7guZmTB/7MSd+vqOkImSu9UUiJw=
|
||||||
github.com/metrue/go-ssh-client v0.0.0-20200317072149-19d54050aefd/go.mod h1:mgU+XR/ItF6PaQGpx0MthaaMP2dgGuck0IiXcrF3zMw=
|
github.com/metrue/go-ssh-client v0.0.0-20191219103445-1f07b67e2b29/go.mod h1:aPG/JtXTyLliKDDlkv+nzHbSbz2p2CBMAjNJRK4uhzY=
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||||
github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
|
github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
|
||||||
github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
||||||
@@ -247,16 +237,12 @@ github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2i
|
|||||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
|
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
|
||||||
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||||
github.com/otiai10/copy v1.1.1 h1:PH7IFlRQ6Fv9vYmuXbDRLdgTHoP1w483kPNUP2bskpo=
|
github.com/otiai10/copy v1.0.2 h1:DDNipYy6RkIkjMwy+AWzgKiNTyj2RUI9yEMeETEpVyc=
|
||||||
github.com/otiai10/copy v1.1.1/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
|
github.com/otiai10/copy v1.0.2/go.mod h1:c7RpqBkwMom4bYTSkLSym4VSJz/XtncWRAj/J4PEIMY=
|
||||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95 h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs=
|
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95 h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs=
|
||||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
||||||
github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI=
|
|
||||||
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
|
|
||||||
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
|
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
|
||||||
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
|
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
|
||||||
github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc=
|
|
||||||
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
|
|
||||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||||
@@ -267,8 +253,6 @@ 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.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=
|
||||||
@@ -284,8 +268,14 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
|
|||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w=
|
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
|
github.com/rogpeppe/go-internal v1.5.1 h1:asQ0uD7BN9RU5Im41SEEZTwCi/zAXdMOLS3npYaos2g=
|
||||||
|
github.com/rogpeppe/go-internal v1.5.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
|
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
|
||||||
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||||
@@ -295,9 +285,12 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
|
|||||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8=
|
github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8=
|
||||||
github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
|
github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
|
||||||
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
|
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
|
||||||
|
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||||
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
|
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
|
||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
@@ -306,7 +299,8 @@ github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
|||||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
||||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
|
||||||
|
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
@@ -314,7 +308,10 @@ github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
|||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
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.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk=
|
||||||
|
github.com/spf13/viper v1.6.1/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=
|
||||||
@@ -324,8 +321,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/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
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=
|
||||||
github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0=
|
github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0=
|
||||||
github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao=
|
github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao=
|
||||||
@@ -334,12 +331,13 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
|
|||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||||
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||||
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
|
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
|
||||||
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||||
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
|
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
|
||||||
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
||||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
@@ -350,14 +348,14 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
|
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915 h1:aJ0ex187qoXrJHPo8ZasVTASQB7llQP6YeNzgDALPRk=
|
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915 h1:aJ0ex187qoXrJHPo8ZasVTASQB7llQP6YeNzgDALPRk=
|
||||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
@@ -365,7 +363,6 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk
|
|||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@@ -376,13 +373,12 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r
|
|||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68=
|
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68=
|
||||||
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
|
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@@ -394,27 +390,24 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e h1:z2Flw7sLy7DxaQi3zDOvI9X+Kb06+G9iZJlkEyHvujE=
|
||||||
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191223224216-5a3cf8467b4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/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=
|
||||||
@@ -430,12 +423,10 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
|
|||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c h1:KfpJVdWhuRqNk4XVXzjXf2KAV4TBEP77SYdFGjeGuIE=
|
||||||
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
@@ -454,18 +445,26 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
|
|||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
|
||||||
|
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||||
|
gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=
|
||||||
|
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||||
gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o=
|
gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o=
|
||||||
gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
|
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
|
||||||
|
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||||
|
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
@@ -487,10 +486,6 @@ 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=
|
||||||
|
|||||||
11
handlers/call.go
Normal file
11
handlers/call.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/metrue/fx/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Call command handle
|
||||||
|
func Call(ctx context.Contexter) error {
|
||||||
|
// TODO not supported
|
||||||
|
return nil
|
||||||
|
}
|
||||||
26
handlers/doctor.go
Normal file
26
handlers/doctor.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/apex/log"
|
||||||
|
"github.com/metrue/fx/constants"
|
||||||
|
"github.com/metrue/fx/context"
|
||||||
|
"github.com/metrue/fx/doctor"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Doctor command handle
|
||||||
|
func Doctor(ctx context.Contexter) error {
|
||||||
|
host := os.Getenv("DOCKER_REMOTE_HOST_ADDR")
|
||||||
|
user := os.Getenv("DOCKER_REMOTE_HOST_USER")
|
||||||
|
password := os.Getenv("DOCKER_REMOTE_HOST_PASSWORD")
|
||||||
|
if host == "" {
|
||||||
|
host = "localhost"
|
||||||
|
}
|
||||||
|
if err := doctor.New(host, user, password).Start(); err != nil {
|
||||||
|
log.Warnf("machine %s is in dirty state: %v", host, err)
|
||||||
|
} else {
|
||||||
|
log.Infof("machine %s is in healthy state: %s", host, constants.CheckedSymbol)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -2,23 +2,17 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
"github.com/metrue/fx/driver"
|
"github.com/metrue/fx/infra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Down command handle
|
// Down command handle
|
||||||
func Down(ctx context.Contexter) (err error) {
|
func Down(ctx context.Contexter) (err error) {
|
||||||
services := ctx.Get("services").([]string)
|
services := ctx.Get("services").([]string)
|
||||||
for _, targetdriver := range []string{"docker_driver", "k8s_driver"} {
|
runner := ctx.Get("deployer").(infra.Deployer)
|
||||||
driver, ok := ctx.Get(targetdriver).(driver.Driver)
|
for _, svc := range services {
|
||||||
if !ok {
|
if err := runner.Destroy(ctx.GetContext(), svc); err != nil {
|
||||||
continue
|
return err
|
||||||
}
|
|
||||||
for _, svc := range services {
|
|
||||||
if err := driver.Destroy(ctx.GetContext(), svc); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
mockCtx "github.com/metrue/fx/context/mocks"
|
mockCtx "github.com/metrue/fx/context/mocks"
|
||||||
mockDeployer "github.com/metrue/fx/driver/mocks"
|
mockDeployer "github.com/metrue/fx/infra/mocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDown(t *testing.T) {
|
func TestDown(t *testing.T) {
|
||||||
@@ -14,14 +14,13 @@ func TestDown(t *testing.T) {
|
|||||||
defer ctrl.Finish()
|
defer ctrl.Finish()
|
||||||
|
|
||||||
ctx := mockCtx.NewMockContexter(ctrl)
|
ctx := mockCtx.NewMockContexter(ctrl)
|
||||||
driver := mockDeployer.NewMockDriver(ctrl)
|
deployer := mockDeployer.NewMockDeployer(ctrl)
|
||||||
|
|
||||||
services := []string{"sample-name"}
|
services := []string{"sample-name"}
|
||||||
ctx.EXPECT().Get("services").Return(services)
|
ctx.EXPECT().Get("services").Return(services)
|
||||||
ctx.EXPECT().Get("docker_driver").Return(driver)
|
ctx.EXPECT().Get("deployer").Return(deployer)
|
||||||
ctx.EXPECT().Get("k8s_driver").Return(driver)
|
ctx.EXPECT().GetContext().Return(context.Background())
|
||||||
ctx.EXPECT().GetContext().Return(context.Background()).Times(2)
|
deployer.EXPECT().Destroy(gomock.Any(), services[0]).Return(nil)
|
||||||
driver.EXPECT().Destroy(gomock.Any(), services[0]).Return(nil).Times(2)
|
|
||||||
if err := Down(ctx); err != nil {
|
if err := Down(ctx); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,73 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/metrue/fx/bundle"
|
|
||||||
"github.com/metrue/fx/constants"
|
"github.com/metrue/fx/constants"
|
||||||
|
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/pkg/spinner"
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
|
"github.com/otiai10/copy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BuildImage build image
|
// BuildImage build image
|
||||||
func BuildImage(ctx context.Contexter) (err error) {
|
func BuildImage(ctx context.Contexter) (err error) {
|
||||||
image := ctx.Get("image").(string)
|
spinner.Start("building")
|
||||||
log.Infof("image built: %s %v", image, constants.CheckedSymbol)
|
defer func() {
|
||||||
|
spinner.Stop("building", err)
|
||||||
|
}()
|
||||||
|
workdir := fmt.Sprintf("/tmp/fx-%d", time.Now().Unix())
|
||||||
|
defer os.RemoveAll(workdir)
|
||||||
|
|
||||||
|
sources := ctx.Get("sources").([]string)
|
||||||
|
|
||||||
|
if len(sources) == 0 {
|
||||||
|
return fmt.Errorf("source file/directory of function required")
|
||||||
|
}
|
||||||
|
if len(sources) == 1 &&
|
||||||
|
utils.IsDir(sources[0]) &&
|
||||||
|
utils.HasDockerfile(sources[0]) {
|
||||||
|
if err := copy.Copy(sources[0], workdir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := packer.Pack(workdir, sources...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
docker := ctx.Get("docker").(containerruntimes.ContainerRuntime)
|
||||||
|
nameWithTag := ctx.Get("tag").(string) + ":latest"
|
||||||
|
if err := docker.BuildImage(ctx.GetContext(), workdir, nameWithTag); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Infof("image built: %s %v", nameWithTag, constants.CheckedSymbol)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportImage export service's code into a directory
|
// ExportImage export service's code into a directory
|
||||||
func ExportImage(ctx context.Contexter) (err error) {
|
func ExportImage(ctx context.Contexter) (err error) {
|
||||||
outputDir := ctx.Get("output").(string)
|
outputDir := ctx.Get("output").(string)
|
||||||
fn := ctx.Get("fn").(string)
|
sources := ctx.Get("sources").([]string)
|
||||||
deps := ctx.Get("deps").([]string)
|
|
||||||
|
|
||||||
language := ctx.Get("language").(string)
|
if len(sources) == 0 {
|
||||||
|
return fmt.Errorf("source file/directory of function required")
|
||||||
if err := bundle.Bundle(outputDir, language, fn, deps...); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
if len(sources) == 1 &&
|
||||||
if err := hook.RunBeforeBuildHook(outputDir); err != nil {
|
utils.IsDir(sources[0]) &&
|
||||||
return err
|
utils.HasDockerfile(sources[0]) {
|
||||||
|
if err := copy.Copy(sources[0], outputDir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := packer.Pack(outputDir, sources...); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("exported to %v: %v", outputDir, constants.CheckedSymbol)
|
log.Infof("exported to %v: %v", outputDir, constants.CheckedSymbol)
|
||||||
|
|||||||
113
handlers/infra.go
Normal file
113
handlers/infra.go
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/config"
|
||||||
|
"github.com/metrue/fx/context"
|
||||||
|
dockerInfra "github.com/metrue/fx/infra/docker"
|
||||||
|
k8sInfra "github.com/metrue/fx/infra/k8s"
|
||||||
|
"github.com/metrue/fx/pkg/spinner"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setupK8S(configDir string, name, masterInfo string, agentsInfo string) ([]byte, error) {
|
||||||
|
info := strings.Split(masterInfo, "@")
|
||||||
|
if len(info) != 2 {
|
||||||
|
return nil, fmt.Errorf("incorrect master info, should be <user>@<ip> format")
|
||||||
|
}
|
||||||
|
master, err := k8sInfra.CreateNode(info[1], info[0], "k3s_master", "master")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nodes := []k8sInfra.Noder{master}
|
||||||
|
if agentsInfo != "" {
|
||||||
|
agentsInfoList := strings.Split(agentsInfo, ",")
|
||||||
|
for idx, agent := range agentsInfoList {
|
||||||
|
info := strings.Split(agent, "@")
|
||||||
|
if len(info) != 2 {
|
||||||
|
return nil, fmt.Errorf("incorrect agent info, should be <user>@<ip> format")
|
||||||
|
}
|
||||||
|
node, err := k8sInfra.CreateNode(info[1], info[0], "k3s_agent", fmt.Sprintf("agent-%d", idx))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kubeconfigPath := filepath.Join(configDir, name+".kubeconfig")
|
||||||
|
cloud := k8sInfra.NewCloud(kubeconfigPath, nodes...)
|
||||||
|
if err := cloud.Provision(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cloud.Dump()
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupDocker(hostInfo string, name string) ([]byte, error) {
|
||||||
|
info := strings.Split(hostInfo, "@")
|
||||||
|
if len(info) != 2 {
|
||||||
|
return nil, fmt.Errorf("incorrect master info, should be <user>@<ip> format")
|
||||||
|
}
|
||||||
|
user := info[0]
|
||||||
|
host := info[1]
|
||||||
|
|
||||||
|
cloud, err := dockerInfra.Create(host, user, name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := cloud.Provision(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cloud.Dump()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup infra
|
||||||
|
func Setup(ctx context.Contexter) (err error) {
|
||||||
|
const task = "setup infra"
|
||||||
|
spinner.Start(task)
|
||||||
|
defer func() {
|
||||||
|
spinner.Stop(task, err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
cli := ctx.GetCliContext()
|
||||||
|
typ := cli.String("type")
|
||||||
|
name := cli.String("name")
|
||||||
|
if name == "" {
|
||||||
|
return fmt.Errorf("name required")
|
||||||
|
}
|
||||||
|
if typ == "docker" {
|
||||||
|
if cli.String("host") == "" {
|
||||||
|
return fmt.Errorf("host required, eg. 'root@123.1.2.12'")
|
||||||
|
}
|
||||||
|
} else if typ == "k8s" {
|
||||||
|
if cli.String("master") == "" {
|
||||||
|
return fmt.Errorf("master required, eg. 'root@123.1.2.12'")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("invalid type, 'docker' and 'k8s' support")
|
||||||
|
}
|
||||||
|
|
||||||
|
fxConfig := ctx.Get("config").(*config.Config)
|
||||||
|
|
||||||
|
switch strings.ToLower(typ) {
|
||||||
|
case "k8s":
|
||||||
|
dir, err := fxConfig.Dir()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
kubeconf, err := setupK8S(dir, name, cli.String("master"), cli.String("agents"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fxConfig.AddCloud(name, kubeconf)
|
||||||
|
case "docker":
|
||||||
|
config, err := setupDocker(cli.String("host"), name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return fxConfig.AddCloud(name, config)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -2,27 +2,20 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
"github.com/metrue/fx/driver"
|
"github.com/metrue/fx/infra"
|
||||||
"github.com/metrue/fx/pkg/renderrer"
|
"github.com/metrue/fx/pkg/render"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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()
|
||||||
format := ctx.Get("format").(string)
|
deployer := ctx.Get("deployer").(infra.Deployer)
|
||||||
|
|
||||||
for _, targetdriver := range []string{"docker_driver", "k8s_driver"} {
|
services, err := deployer.List(ctx.GetContext(), cli.Args().First())
|
||||||
driver, ok := ctx.Get(targetdriver).(driver.Driver)
|
if err != nil {
|
||||||
if !ok {
|
return err
|
||||||
continue
|
|
||||||
}
|
|
||||||
services, err := driver.List(ctx.GetContext(), cli.Args().First())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := renderrer.Render(services, format); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render.Table(services)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
19
handlers/list_infra.go
Normal file
19
handlers/list_infra.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/config"
|
||||||
|
"github.com/metrue/fx/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListInfra list infra
|
||||||
|
func ListInfra(ctx context.Contexter) (err error) {
|
||||||
|
fxConfig := ctx.Get("config").(*config.Config)
|
||||||
|
conf, err := fxConfig.View()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(string(conf))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/metrue/fx/context"
|
"github.com/metrue/fx/context"
|
||||||
"github.com/metrue/fx/driver"
|
"github.com/metrue/fx/infra"
|
||||||
"github.com/metrue/fx/pkg/renderrer"
|
"github.com/metrue/fx/pkg/render"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,37 +19,29 @@ func Up(ctx context.Contexter) (err error) {
|
|||||||
image = ""
|
image = ""
|
||||||
}
|
}
|
||||||
name := ctx.Get("name").(string)
|
name := ctx.Get("name").(string)
|
||||||
|
deployer := ctx.Get("deployer").(infra.Deployer)
|
||||||
bindings := ctx.Get("bindings").([]types.PortBinding)
|
bindings := ctx.Get("bindings").([]types.PortBinding)
|
||||||
force := ctx.Get("force").(bool)
|
force := ctx.Get("force").(bool)
|
||||||
|
if force && name != "" {
|
||||||
for _, targetdriver := range []string{"docker_driver", "k8s_driver"} {
|
if err := deployer.Destroy(ctx.GetContext(), name); err != nil {
|
||||||
driver, ok := ctx.Get(targetdriver).(driver.Driver)
|
log.Warnf("destroy service %s failed: %v", name, err)
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if force && name != "" {
|
|
||||||
if err := driver.Destroy(ctx.GetContext(), name); err != nil {
|
|
||||||
log.Warnf("destroy service %s failed: %v", name, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := driver.Deploy(
|
|
||||||
ctx.GetContext(),
|
|
||||||
fn,
|
|
||||||
name,
|
|
||||||
image,
|
|
||||||
bindings,
|
|
||||||
); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
service, err := driver.GetStatus(ctx.GetContext(), name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := renderrer.Render([]types.Service{service}, "table"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := deployer.Deploy(
|
||||||
|
ctx.GetContext(),
|
||||||
|
fn,
|
||||||
|
name,
|
||||||
|
image,
|
||||||
|
bindings,
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
service, err := deployer.GetStatus(ctx.GetContext(), name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
render.Table([]types.Service{service})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
mockCtx "github.com/metrue/fx/context/mocks"
|
mockCtx "github.com/metrue/fx/context/mocks"
|
||||||
mockDeployer "github.com/metrue/fx/driver/mocks"
|
mockDeployer "github.com/metrue/fx/infra/mocks"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ func TestUp(t *testing.T) {
|
|||||||
defer ctrl.Finish()
|
defer ctrl.Finish()
|
||||||
|
|
||||||
ctx := mockCtx.NewMockContexter(ctrl)
|
ctx := mockCtx.NewMockContexter(ctrl)
|
||||||
driver := mockDeployer.NewMockDriver(ctrl)
|
deployer := mockDeployer.NewMockDeployer(ctrl)
|
||||||
|
|
||||||
bindings := []types.PortBinding{}
|
bindings := []types.PortBinding{}
|
||||||
name := "sample-name"
|
name := "sample-name"
|
||||||
@@ -24,19 +24,18 @@ func TestUp(t *testing.T) {
|
|||||||
data := "sample-data"
|
data := "sample-data"
|
||||||
ctx.EXPECT().Get("name").Return(name)
|
ctx.EXPECT().Get("name").Return(name)
|
||||||
ctx.EXPECT().Get("image").Return(image)
|
ctx.EXPECT().Get("image").Return(image)
|
||||||
ctx.EXPECT().Get("docker_driver").Return(driver)
|
ctx.EXPECT().Get("deployer").Return(deployer)
|
||||||
ctx.EXPECT().Get("k8s_driver").Return(driver)
|
|
||||||
ctx.EXPECT().Get("bindings").Return(bindings)
|
ctx.EXPECT().Get("bindings").Return(bindings)
|
||||||
ctx.EXPECT().Get("data").Return(data)
|
ctx.EXPECT().Get("data").Return(data)
|
||||||
ctx.EXPECT().Get("force").Return(false)
|
ctx.EXPECT().Get("force").Return(false)
|
||||||
ctx.EXPECT().GetContext().Return(context.Background()).Times(4)
|
ctx.EXPECT().GetContext().Return(context.Background()).Times(2)
|
||||||
driver.EXPECT().Deploy(gomock.Any(), data, name, image, bindings).Return(nil).Times(2)
|
deployer.EXPECT().Deploy(gomock.Any(), data, name, image, bindings).Return(nil)
|
||||||
driver.EXPECT().GetStatus(gomock.Any(), name).Return(types.Service{
|
deployer.EXPECT().GetStatus(gomock.Any(), name).Return(types.Service{
|
||||||
ID: "id-1",
|
ID: "id-1",
|
||||||
Name: name,
|
Name: name,
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 2100,
|
Port: 2100,
|
||||||
}, nil).Times(2)
|
}, nil)
|
||||||
if err := Up(ctx); err != nil {
|
if err := Up(ctx); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -47,7 +46,7 @@ func TestUp(t *testing.T) {
|
|||||||
defer ctrl.Finish()
|
defer ctrl.Finish()
|
||||||
|
|
||||||
ctx := mockCtx.NewMockContexter(ctrl)
|
ctx := mockCtx.NewMockContexter(ctrl)
|
||||||
driver := mockDeployer.NewMockDriver(ctrl)
|
deployer := mockDeployer.NewMockDeployer(ctrl)
|
||||||
|
|
||||||
bindings := []types.PortBinding{}
|
bindings := []types.PortBinding{}
|
||||||
name := "sample-name"
|
name := "sample-name"
|
||||||
@@ -55,20 +54,19 @@ func TestUp(t *testing.T) {
|
|||||||
data := "sample-data"
|
data := "sample-data"
|
||||||
ctx.EXPECT().Get("name").Return(name)
|
ctx.EXPECT().Get("name").Return(name)
|
||||||
ctx.EXPECT().Get("image").Return(image)
|
ctx.EXPECT().Get("image").Return(image)
|
||||||
ctx.EXPECT().Get("docker_driver").Return(driver)
|
ctx.EXPECT().Get("deployer").Return(deployer)
|
||||||
ctx.EXPECT().Get("k8s_driver").Return(driver)
|
|
||||||
ctx.EXPECT().Get("bindings").Return(bindings)
|
ctx.EXPECT().Get("bindings").Return(bindings)
|
||||||
ctx.EXPECT().Get("data").Return(data)
|
ctx.EXPECT().Get("data").Return(data)
|
||||||
ctx.EXPECT().Get("force").Return(true)
|
ctx.EXPECT().Get("force").Return(true)
|
||||||
ctx.EXPECT().GetContext().Return(context.Background()).Times(6)
|
ctx.EXPECT().GetContext().Return(context.Background()).Times(3)
|
||||||
driver.EXPECT().Deploy(gomock.Any(), data, name, image, bindings).Return(nil).Times(2)
|
deployer.EXPECT().Deploy(gomock.Any(), data, name, image, bindings).Return(nil)
|
||||||
driver.EXPECT().Destroy(gomock.Any(), name).Return(nil).Times(2)
|
deployer.EXPECT().Destroy(gomock.Any(), name).Return(nil)
|
||||||
driver.EXPECT().GetStatus(gomock.Any(), name).Return(types.Service{
|
deployer.EXPECT().GetStatus(gomock.Any(), name).Return(types.Service{
|
||||||
ID: "id-1",
|
ID: "id-1",
|
||||||
Name: name,
|
Name: name,
|
||||||
Host: "127.0.0.1",
|
Host: "127.0.0.1",
|
||||||
Port: 2100,
|
Port: 2100,
|
||||||
}, nil).Times(2)
|
}, nil)
|
||||||
if err := Up(ctx); err != nil {
|
if err := Up(ctx); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
13
handlers/use_infra.go
Normal file
13
handlers/use_infra.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/metrue/fx/config"
|
||||||
|
"github.com/metrue/fx/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UseInfra use infra
|
||||||
|
func UseInfra(ctx context.Contexter) error {
|
||||||
|
fxConfig := ctx.Get("config").(*config.Config)
|
||||||
|
cli := ctx.GetCliContext()
|
||||||
|
return fxConfig.UseCloud(cli.Args().First())
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
npm install
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"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
73
hook/hook.go
@@ -1,73 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
180
infra/docker/cloud.go
Normal file
180
infra/docker/cloud.go
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/infra"
|
||||||
|
"github.com/metrue/fx/types"
|
||||||
|
"github.com/metrue/go-ssh-client"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Cloud define a docker host
|
||||||
|
type Cloud struct {
|
||||||
|
IP string `json:"ip"`
|
||||||
|
User string `json:"user"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
sshClient ssh.Clienter
|
||||||
|
}
|
||||||
|
|
||||||
|
// New new a docker cloud
|
||||||
|
func New(ip string, user string, name string) *Cloud {
|
||||||
|
return &Cloud{
|
||||||
|
IP: ip,
|
||||||
|
User: user,
|
||||||
|
Name: name,
|
||||||
|
Type: types.CloudTypeDocker,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a docker node
|
||||||
|
func Create(ip string, user string, name string) (*Cloud, error) {
|
||||||
|
key, err := sshkey()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
port := sshport()
|
||||||
|
sshClient := ssh.New(ip).WithUser(user).WithKey(key).WithPort(port)
|
||||||
|
return &Cloud{
|
||||||
|
IP: ip,
|
||||||
|
User: user,
|
||||||
|
Name: name,
|
||||||
|
Type: types.CloudTypeDocker,
|
||||||
|
|
||||||
|
sshClient: sshClient,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load a docker node from meta
|
||||||
|
func Load(meta []byte) (*Cloud, error) {
|
||||||
|
var cloud Cloud
|
||||||
|
if err := json.Unmarshal(meta, &cloud); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
key, err := sshkey()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
port := sshport()
|
||||||
|
sshClient := ssh.New(cloud.IP).WithUser(cloud.User).WithKey(key).WithPort(port)
|
||||||
|
cloud.sshClient = sshClient
|
||||||
|
|
||||||
|
return &cloud, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provision a host
|
||||||
|
func (c *Cloud) Provision() error {
|
||||||
|
if err := c.runCmd(infra.Scripts["docker_version"].(string)); err != nil {
|
||||||
|
if err := c.runCmd(infra.Scripts["install_docker"].(string)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.runCmd(infra.Scripts["start_dockerd"].(string)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.runCmd(infra.Scripts["check_fx_agent"].(string)); err != nil {
|
||||||
|
if err := c.runCmd(infra.Scripts["start_fx_agent"].(string)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetType cloud type
|
||||||
|
func (c *Cloud) GetType() string {
|
||||||
|
return c.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Cloud) GetConfig() (string, error) {
|
||||||
|
data, err := json.Marshal(c)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(data), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Cloud) Dump() ([]byte, error) {
|
||||||
|
return json.Marshal(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsHealth check if cloud is in health
|
||||||
|
func (c *Cloud) IsHealth() (bool, error) {
|
||||||
|
if err := c.runCmd(infra.Scripts["check_fx_agent"].(string)); err != nil {
|
||||||
|
if err := c.runCmd(infra.Scripts["start_fx_agent"].(string)); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE only using for unit testing
|
||||||
|
func (c *Cloud) setsshClient(client ssh.Clienter) {
|
||||||
|
c.sshClient = client
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:unparam
|
||||||
|
func (c *Cloud) runCmd(script string, options ...ssh.CommandOptions) error {
|
||||||
|
option := ssh.CommandOptions{}
|
||||||
|
if len(options) >= 1 {
|
||||||
|
option = options[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
local := c.IP == "127.0.0.1" || c.IP == "localhost"
|
||||||
|
if local && os.Getenv("CI") == "" {
|
||||||
|
params := strings.Split(script, " ")
|
||||||
|
if len(params) == 0 {
|
||||||
|
return fmt.Errorf("invalid script: %s", script)
|
||||||
|
}
|
||||||
|
// nolint
|
||||||
|
cmd := exec.Command(params[0], params[1:]...)
|
||||||
|
cmd.Stdout = option.Stdout
|
||||||
|
cmd.Stderr = option.Stderr
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.sshClient.RunCommand(script, option)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE the reason putting sshkey() and sshport here inside node.go is because
|
||||||
|
// ssh key and ssh port is related to node it self, we may extend this in future
|
||||||
|
func sshkey() (string, error) {
|
||||||
|
path := os.Getenv("SSH_KEY_FILE")
|
||||||
|
if path != "" {
|
||||||
|
absPath, err := filepath.Abs(path)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return absPath, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
key, err := homedir.Expand("~/.ssh/id_rsa")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return key, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func sshport() string {
|
||||||
|
port := os.Getenv("SSH_PORT")
|
||||||
|
if port != "" {
|
||||||
|
return port
|
||||||
|
}
|
||||||
|
return "22"
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ infra.Clouder = &Cloud{}
|
||||||
|
)
|
||||||
158
infra/docker/cloud_test.go
Normal file
158
infra/docker/cloud_test.go
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/golang/mock/gomock"
|
||||||
|
"github.com/metrue/fx/infra"
|
||||||
|
"github.com/metrue/go-ssh-client"
|
||||||
|
sshMocks "github.com/metrue/go-ssh-client/mocks"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCloudProvision(t *testing.T) {
|
||||||
|
t.Run("fx agent started", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
|
||||||
|
n := New("127.0.0.1", "fx", "master")
|
||||||
|
sshClient := sshMocks.NewMockClienter(ctrl)
|
||||||
|
n.setsshClient(sshClient)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["docker_version"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["check_fx_agent"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
if err := n.Provision(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("fx agent not started", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
|
||||||
|
n := New("127.0.0.1", "fx", "master")
|
||||||
|
sshClient := sshMocks.NewMockClienter(ctrl)
|
||||||
|
n.setsshClient(sshClient)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["docker_version"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["check_fx_agent"].(string), ssh.CommandOptions{}).Return(fmt.Errorf("no such container"))
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["start_fx_agent"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
if err := n.Provision(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("docker not installed and fx agent not started", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
|
||||||
|
n := New("127.0.0.1", "fx", "master")
|
||||||
|
sshClient := sshMocks.NewMockClienter(ctrl)
|
||||||
|
n.setsshClient(sshClient)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["docker_version"].(string), ssh.CommandOptions{}).Return(fmt.Errorf("no such command"))
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["install_docker"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["start_dockerd"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["check_fx_agent"].(string), ssh.CommandOptions{}).Return(fmt.Errorf("no such container"))
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["start_fx_agent"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
if err := n.Provision(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCloudIsHealth(t *testing.T) {
|
||||||
|
t.Run("agent started", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
cloud := New("127.0.0.1", "fx", "master")
|
||||||
|
sshClient := sshMocks.NewMockClienter(ctrl)
|
||||||
|
cloud.setsshClient(sshClient)
|
||||||
|
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["check_fx_agent"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
ok, err := cloud.IsHealth()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("cloud should be healthy")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("agent not started, and retart ok", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
cloud := New("127.0.0.1", "fx", "master")
|
||||||
|
sshClient := sshMocks.NewMockClienter(ctrl)
|
||||||
|
cloud.setsshClient(sshClient)
|
||||||
|
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["check_fx_agent"].(string), ssh.CommandOptions{}).Return(fmt.Errorf("fx agent not started"))
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["start_fx_agent"].(string), ssh.CommandOptions{}).Return(nil)
|
||||||
|
ok, err := cloud.IsHealth()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("cloud should be healthy")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("agent not started, but restart failed", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
cloud := New("127.0.0.1", "fx", "master")
|
||||||
|
sshClient := sshMocks.NewMockClienter(ctrl)
|
||||||
|
cloud.setsshClient(sshClient)
|
||||||
|
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["check_fx_agent"].(string), ssh.CommandOptions{}).Return(fmt.Errorf("fx agent not started"))
|
||||||
|
sshClient.EXPECT().RunCommand(infra.Scripts["start_fx_agent"].(string), ssh.CommandOptions{}).Return(fmt.Errorf("fx agent started failed"))
|
||||||
|
ok, err := cloud.IsHealth()
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("should got failed starting")
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
t.Fatalf("cloud should not be healthy")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetSSHKeyFile(t *testing.T) {
|
||||||
|
t.Run("defaut", func(t *testing.T) {
|
||||||
|
defau, err := sshkey()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultPath, _ := homedir.Expand("~/.ssh/id_rsa")
|
||||||
|
if defau != defaultPath {
|
||||||
|
t.Fatalf("should get %s but got %s", defaultPath, defau)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("override from env", func(t *testing.T) {
|
||||||
|
os.Setenv("SSH_KEY_FILE", "/tmp/id_rsa")
|
||||||
|
keyFile, err := sshkey()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if keyFile != "/tmp/id_rsa" {
|
||||||
|
t.Fatalf("should get %s but got %s", "/tmp/id_rsa", keyFile)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetSSHPort(t *testing.T) {
|
||||||
|
t.Run("defaut", func(t *testing.T) {
|
||||||
|
defau := sshport()
|
||||||
|
if defau != "22" {
|
||||||
|
t.Fatalf("should get %s but got %s", "22", defau)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("override from env", func(t *testing.T) {
|
||||||
|
os.Setenv("SSH_PORT", "2222")
|
||||||
|
defau := sshport()
|
||||||
|
if defau != "2222" {
|
||||||
|
t.Fatalf("should get %s but got %s", "2222", defau)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -6,66 +6,48 @@ import (
|
|||||||
|
|
||||||
dockerTypes "github.com/docker/docker/api/types"
|
dockerTypes "github.com/docker/docker/api/types"
|
||||||
containerruntimes "github.com/metrue/fx/container_runtimes"
|
containerruntimes "github.com/metrue/fx/container_runtimes"
|
||||||
"github.com/metrue/fx/driver"
|
"github.com/metrue/fx/infra"
|
||||||
"github.com/metrue/fx/pkg/spinner"
|
"github.com/metrue/fx/pkg/spinner"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Driver manage container
|
// Deployer manage container
|
||||||
type Driver struct {
|
type Deployer struct {
|
||||||
dockerClient containerruntimes.ContainerRuntime
|
cli containerruntimes.ContainerRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options to initialize a fx docker driver
|
// CreateClient create a docker instance
|
||||||
type Options struct {
|
func CreateClient(client containerruntimes.ContainerRuntime) (d *Deployer, err error) {
|
||||||
DockerClient containerruntimes.ContainerRuntime
|
return &Deployer{cli: client}, nil
|
||||||
}
|
|
||||||
|
|
||||||
// New a fx docker driver
|
|
||||||
func New(options Options) *Driver {
|
|
||||||
return &Driver{
|
|
||||||
dockerClient: options.DockerClient,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ping check healty status of driver
|
|
||||||
func (d *Driver) Ping(ctx context.Context) error {
|
|
||||||
if _, err := d.dockerClient.Version(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deploy create a Docker container from given image, and bind the constants.FxContainerExposePort to given port
|
// Deploy create a Docker container from given image, and bind the constants.FxContainerExposePort to given port
|
||||||
func (d *Driver) Deploy(ctx context.Context, fn string, name string, image string, ports []types.PortBinding) (err error) {
|
func (d *Deployer) Deploy(ctx context.Context, fn string, name string, image string, ports []types.PortBinding) (err error) {
|
||||||
spinner.Start("deploying " + name)
|
spinner.Start("deploying " + name)
|
||||||
defer func() {
|
defer func() {
|
||||||
spinner.Stop("deploying "+name, err)
|
spinner.Stop("deploying "+name, err)
|
||||||
}()
|
}()
|
||||||
return d.dockerClient.StartContainer(ctx, name, image, ports)
|
return d.cli.StartContainer(ctx, name, image, ports)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update a container
|
// Update a container
|
||||||
func (d *Driver) Update(ctx context.Context, name string) error {
|
func (d *Deployer) Update(ctx context.Context, name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy stop and remove container
|
// Destroy stop and remove container
|
||||||
func (d *Driver) Destroy(ctx context.Context, name string) (err error) {
|
func (d *Deployer) Destroy(ctx context.Context, name string) (err error) {
|
||||||
spinner.Start("destroying " + name)
|
spinner.Start("destroying " + name)
|
||||||
defer func() {
|
defer func() {
|
||||||
spinner.Stop("destroying "+name, err)
|
spinner.Stop("destroying "+name, err)
|
||||||
}()
|
}()
|
||||||
if err := d.dockerClient.StopContainer(ctx, name); err != nil {
|
return d.cli.StopContainer(ctx, name)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return d.dockerClient.RemoveContainer(ctx, name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatus get a service status
|
// GetStatus get a service status
|
||||||
func (d *Driver) GetStatus(ctx context.Context, name string) (types.Service, error) {
|
func (d *Deployer) GetStatus(ctx context.Context, name string) (types.Service, error) {
|
||||||
var container dockerTypes.ContainerJSON
|
var container dockerTypes.ContainerJSON
|
||||||
if err := d.dockerClient.InspectContainer(ctx, name, &container); err != nil {
|
if err := d.cli.InspectContainer(ctx, name, &container); err != nil {
|
||||||
return types.Service{}, err
|
return types.Service{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +55,6 @@ func (d *Driver) GetStatus(ctx context.Context, name string) (types.Service, err
|
|||||||
ID: container.ID,
|
ID: container.ID,
|
||||||
Name: container.Name,
|
Name: container.Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, bindings := range container.NetworkSettings.Ports {
|
for _, bindings := range container.NetworkSettings.Ports {
|
||||||
if len(bindings) > 0 {
|
if len(bindings) > 0 {
|
||||||
binding := bindings[0]
|
binding := bindings[0]
|
||||||
@@ -95,12 +76,26 @@ func (d *Driver) GetStatus(ctx context.Context, name string) (types.Service, err
|
|||||||
return service, nil
|
return service, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ping check healty status of infra
|
||||||
|
func (d *Deployer) Ping(ctx context.Context) error {
|
||||||
|
if _, err := d.cli.Version(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// List services
|
// List services
|
||||||
func (d *Driver) 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.dockerClient.ListContainer(ctx, name)
|
return d.cli.ListContainer(ctx, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ driver.Driver = &Driver{}
|
_ infra.Deployer = &Deployer{}
|
||||||
)
|
)
|
||||||
43
infra/docker/deployer_test.go
Normal file
43
infra/docker/deployer_test.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDocker(t *testing.T) {
|
||||||
|
// ctx := context.Background()
|
||||||
|
// cli, err := CreateClient(ctx)
|
||||||
|
// if err != nil {
|
||||||
|
// t.Fatal(err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// name := "helloworld"
|
||||||
|
// bindings := []types.PortBinding{
|
||||||
|
// types.PortBinding{
|
||||||
|
// ServiceBindingPort: 80,
|
||||||
|
// ContainerExposePort: 3000,
|
||||||
|
// },
|
||||||
|
// types.PortBinding{
|
||||||
|
// ServiceBindingPort: 443,
|
||||||
|
// ContainerExposePort: 3000,
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fn := types.Func{
|
||||||
|
// Language: "node",
|
||||||
|
// Source: `
|
||||||
|
// module.exports = (ctx) => {
|
||||||
|
// ctx.body = 'hello world'
|
||||||
|
// }
|
||||||
|
// `,
|
||||||
|
// }
|
||||||
|
// if err := cli.Deploy(ctx, fn, name, name, bindings); err != nil {
|
||||||
|
// t.Fatal(err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// time.Sleep(1 * time.Second)
|
||||||
|
//
|
||||||
|
// if err := cli.Destroy(ctx, name); err != nil {
|
||||||
|
// t.Fatal(err)
|
||||||
|
// }
|
||||||
|
}
|
||||||
8
infra/docker/docker.go
Normal file
8
infra/docker/docker.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package docker
|
||||||
|
|
||||||
|
import containerruntimes "github.com/metrue/fx/container_runtimes"
|
||||||
|
|
||||||
|
// CreateDeployer create a deployer
|
||||||
|
func CreateDeployer(client containerruntimes.ContainerRuntime) (*Deployer, error) {
|
||||||
|
return &Deployer{cli: client}, nil
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package driver
|
package infra
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -6,8 +6,17 @@ import (
|
|||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Driver fx function running driver
|
// Clouder cloud interface
|
||||||
type Driver interface {
|
type Clouder interface {
|
||||||
|
Provision() error
|
||||||
|
GetConfig() (string, error)
|
||||||
|
GetType() string
|
||||||
|
Dump() ([]byte, error)
|
||||||
|
IsHealth() (bool, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deployer deploy interface
|
||||||
|
type Deployer interface {
|
||||||
Deploy(ctx context.Context, fn string, name string, image string, bindings []types.PortBinding) error
|
Deploy(ctx context.Context, fn string, name string, image string, bindings []types.PortBinding) error
|
||||||
Destroy(ctx context.Context, name string) error
|
Destroy(ctx context.Context, name string) error
|
||||||
Update(ctx context.Context, name string) error
|
Update(ctx context.Context, name string) error
|
||||||
@@ -15,3 +24,8 @@ type Driver interface {
|
|||||||
List(ctx context.Context, name string) ([]types.Service, error)
|
List(ctx context.Context, name string) ([]types.Service, error)
|
||||||
Ping(ctx context.Context) error
|
Ping(ctx context.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Infra infrastructure provision interface
|
||||||
|
type Infra interface {
|
||||||
|
Deployer
|
||||||
|
}
|
||||||
270
infra/k8s/cloud.go
Normal file
270
infra/k8s/cloud.go
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/metrue/fx/infra"
|
||||||
|
"github.com/metrue/fx/types"
|
||||||
|
"github.com/metrue/fx/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Cloud define a cloud
|
||||||
|
type Cloud struct {
|
||||||
|
// Define where is the location of kubeconf would be saved to
|
||||||
|
KubeConfig string `json:"config"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Nodes map[string]Noder `json:"nodes"`
|
||||||
|
|
||||||
|
token string
|
||||||
|
url string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load a cloud from config
|
||||||
|
func Load(meta []byte, messup ...func(n Noder) (Noder, error)) (*Cloud, error) {
|
||||||
|
var cloud Cloud
|
||||||
|
if err := json.Unmarshal(meta, &cloud); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, n := range cloud.Nodes {
|
||||||
|
// NOTE messup function is just for unit testing
|
||||||
|
// we use it to replace the real not with mock node
|
||||||
|
if len(messup) > 0 {
|
||||||
|
node, err := messup[0](n)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cloud.Nodes[name] = node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &cloud, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCloud new a cloud
|
||||||
|
func NewCloud(kubeconf string, node ...Noder) *Cloud {
|
||||||
|
nodes := map[string]Noder{}
|
||||||
|
for _, n := range node {
|
||||||
|
nodes[n.GetName()] = n
|
||||||
|
}
|
||||||
|
|
||||||
|
return &Cloud{
|
||||||
|
KubeConfig: kubeconf,
|
||||||
|
Type: types.CloudTypeK8S,
|
||||||
|
Nodes: nodes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provision provision cloud
|
||||||
|
func (c *Cloud) Provision() error {
|
||||||
|
var master Noder
|
||||||
|
agents := []Noder{}
|
||||||
|
for _, n := range c.Nodes {
|
||||||
|
if n.GetType() == NodeTypeMaster {
|
||||||
|
master = n
|
||||||
|
} else {
|
||||||
|
agents = append(agents, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// when it's k3s cluster
|
||||||
|
if master != nil {
|
||||||
|
c.url = fmt.Sprintf("https://%s:6443", master.GetIP())
|
||||||
|
if err := master.Provision(map[string]string{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tok, err := master.GetToken()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.token = tok
|
||||||
|
|
||||||
|
config, err := master.GetConfig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := utils.EnsureFile(c.KubeConfig); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(c.KubeConfig, []byte(config), 0666); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(agents) > 0 {
|
||||||
|
errCh := make(chan error, len(agents))
|
||||||
|
defer close(errCh)
|
||||||
|
|
||||||
|
for _, agent := range agents {
|
||||||
|
go func(node Noder) {
|
||||||
|
errCh <- node.Provision(map[string]string{
|
||||||
|
"url": c.url,
|
||||||
|
"token": c.token,
|
||||||
|
})
|
||||||
|
}(agent)
|
||||||
|
}
|
||||||
|
|
||||||
|
for range agents {
|
||||||
|
err := <-errCh
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddNode a node
|
||||||
|
func (c *Cloud) AddNode(n Noder, skipProvision bool) error {
|
||||||
|
if !skipProvision {
|
||||||
|
if err := n.Provision(map[string]string{
|
||||||
|
"url": c.url,
|
||||||
|
"token": c.token,
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Nodes[n.GetName()] = n
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteNode a node
|
||||||
|
func (c *Cloud) DeleteNode(name string) error {
|
||||||
|
node, ok := c.Nodes[name]
|
||||||
|
if ok {
|
||||||
|
delete(c.Nodes, name)
|
||||||
|
}
|
||||||
|
if node.GetType() == NodeTypeMaster && len(c.Nodes) > 0 {
|
||||||
|
return fmt.Errorf("could not delete master node since there is still agent node running")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// State get cloud state
|
||||||
|
func (c *Cloud) State() {}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarsha json
|
||||||
|
func (c *Cloud) UnmarshalJSON(data []byte) error {
|
||||||
|
var m map[string]interface{}
|
||||||
|
if err := json.Unmarshal(data, &m); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Nodes = make(map[string]Noder)
|
||||||
|
|
||||||
|
for k, v := range m {
|
||||||
|
if k == "nodes" {
|
||||||
|
nodes, ok := v.(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("invalid nodes data")
|
||||||
|
}
|
||||||
|
for name, n := range nodes {
|
||||||
|
node, ok := n.(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("invalid node data")
|
||||||
|
}
|
||||||
|
n, err := CreateNode(node["ip"].(string), node["user"].(string), node["type"].(string), node["name"].(string))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.Nodes[name] = n
|
||||||
|
}
|
||||||
|
} else if k == "token" {
|
||||||
|
tok, ok := v.(string)
|
||||||
|
if ok {
|
||||||
|
c.token = tok
|
||||||
|
} else {
|
||||||
|
c.token = ""
|
||||||
|
}
|
||||||
|
} else if k == "config" {
|
||||||
|
config, ok := v.(string)
|
||||||
|
if ok {
|
||||||
|
c.KubeConfig = config
|
||||||
|
} else {
|
||||||
|
c.KubeConfig = ""
|
||||||
|
}
|
||||||
|
} else if k == "type" {
|
||||||
|
typ, ok := v.(string)
|
||||||
|
if ok {
|
||||||
|
c.Type = typ
|
||||||
|
} else {
|
||||||
|
c.Type = ""
|
||||||
|
}
|
||||||
|
} else if k == "url" {
|
||||||
|
url, ok := v.(string)
|
||||||
|
if ok {
|
||||||
|
c.url = url
|
||||||
|
} else {
|
||||||
|
c.url = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON cloud information
|
||||||
|
func (c *Cloud) MarshalJSON() ([]byte, error) {
|
||||||
|
nodes := map[string]Node{}
|
||||||
|
for name, node := range c.Nodes {
|
||||||
|
nodes[name] = Node{
|
||||||
|
IP: node.GetIP(),
|
||||||
|
Type: node.GetType(),
|
||||||
|
User: node.GetUser(),
|
||||||
|
Name: node.GetName(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := json.Marshal(struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
KubeConfig string `json:"config"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
Nodes map[string]Node `json:"nodes"`
|
||||||
|
}{
|
||||||
|
KubeConfig: c.KubeConfig,
|
||||||
|
Type: c.Type,
|
||||||
|
Token: c.token,
|
||||||
|
URL: c.url,
|
||||||
|
Nodes: nodes,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return body, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetType get type of cloud
|
||||||
|
func (c *Cloud) GetType() string {
|
||||||
|
return c.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump cloud data
|
||||||
|
func (c *Cloud) Dump() ([]byte, error) {
|
||||||
|
return json.Marshal(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetConfig get config
|
||||||
|
func (c *Cloud) GetConfig() (string, error) {
|
||||||
|
if c.KubeConfig != "" {
|
||||||
|
return c.KubeConfig, nil
|
||||||
|
}
|
||||||
|
if err := c.Provision(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return c.KubeConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsHealth check if cloud is in health
|
||||||
|
func (c *Cloud) IsHealth() (bool, error) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ infra.Clouder = &Cloud{}
|
||||||
|
)
|
||||||
170
infra/k8s/cloud_test.go
Normal file
170
infra/k8s/cloud_test.go
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/golang/mock/gomock"
|
||||||
|
mock_infra "github.com/metrue/fx/infra/k8s/mocks"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLoad(t *testing.T) {
|
||||||
|
t.Run("empty meta", func(t *testing.T) {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
|
||||||
|
var createNodeFn = func(n Noder) (Noder, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := Load([]byte{}, createNodeFn)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("should load with error")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("only master node", func(t *testing.T) {
|
||||||
|
kubeconfig := "./kubeconfig.yml"
|
||||||
|
defer func() {
|
||||||
|
if err := os.RemoveAll("./kubeconfig.yml"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
|
||||||
|
master := mock_infra.NewMockNoder(ctrl)
|
||||||
|
var createNodeFn = func(n Noder) (Noder, error) {
|
||||||
|
return master, nil
|
||||||
|
}
|
||||||
|
typ := NodeTypeMaster
|
||||||
|
name := "master"
|
||||||
|
ip := "127.0.0.1"
|
||||||
|
user := "testuser"
|
||||||
|
kubeconfContent := "sample-content"
|
||||||
|
master.EXPECT().GetName().Return(name)
|
||||||
|
master.EXPECT().GetType().Return(typ).Times(2)
|
||||||
|
master.EXPECT().GetIP().Return(ip).Times(2)
|
||||||
|
master.EXPECT().GetUser().Return(user)
|
||||||
|
master.EXPECT().GetConfig().Return(kubeconfContent, nil)
|
||||||
|
|
||||||
|
claud := &Cloud{
|
||||||
|
KubeConfig: kubeconfig,
|
||||||
|
Type: "k8s",
|
||||||
|
url: "",
|
||||||
|
token: "",
|
||||||
|
Nodes: map[string]Noder{"master-node": master},
|
||||||
|
}
|
||||||
|
|
||||||
|
meta, err := json.Marshal(claud)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
cloud, err := Load(meta, createNodeFn)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(cloud.Nodes) != 1 {
|
||||||
|
t.Fatalf("should get %d but got %d", 1, len(cloud.Nodes))
|
||||||
|
}
|
||||||
|
|
||||||
|
master.EXPECT().Provision(map[string]string{}).Return(nil)
|
||||||
|
master.EXPECT().GetToken().Return("tok-1", nil)
|
||||||
|
if err := cloud.Provision(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
content, err := ioutil.ReadFile(claud.KubeConfig)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if string(content) != kubeconfContent {
|
||||||
|
t.Fatalf("should get %s but got %s", kubeconfContent, content)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("one master node and one agent", func(t *testing.T) {
|
||||||
|
kubeconfig := "./kubeconfig.yml"
|
||||||
|
defer func() {
|
||||||
|
if err := os.RemoveAll("./kubeconfig.yml"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
defer ctrl.Finish()
|
||||||
|
|
||||||
|
master := mock_infra.NewMockNoder(ctrl)
|
||||||
|
node := mock_infra.NewMockNoder(ctrl)
|
||||||
|
var createNodeFn = func(n Noder) (Noder, error) {
|
||||||
|
if n.GetType() == NodeTypeMaster {
|
||||||
|
return master, nil
|
||||||
|
}
|
||||||
|
return node, nil
|
||||||
|
}
|
||||||
|
typ := NodeTypeMaster
|
||||||
|
name := "master"
|
||||||
|
ip := "127.0.0.1"
|
||||||
|
user := "testuser"
|
||||||
|
kubeconfContent := "sample-config"
|
||||||
|
master.EXPECT().GetName().Return(name)
|
||||||
|
master.EXPECT().GetType().Return(typ).Times(2)
|
||||||
|
master.EXPECT().GetIP().Return(ip).Times(3)
|
||||||
|
master.EXPECT().GetConfig().Return(kubeconfContent, nil)
|
||||||
|
master.EXPECT().GetUser().Return(user)
|
||||||
|
|
||||||
|
nodeType := NodeTypeAgent
|
||||||
|
nodeName := "agent_name"
|
||||||
|
nodeIP := "12.12.12.12"
|
||||||
|
nodeUser := "testuser"
|
||||||
|
node.EXPECT().GetName().Return(nodeName)
|
||||||
|
node.EXPECT().GetType().Return(nodeType).Times(2)
|
||||||
|
node.EXPECT().GetIP().Return(nodeIP)
|
||||||
|
node.EXPECT().GetUser().Return(nodeUser)
|
||||||
|
|
||||||
|
url := fmt.Sprintf("https://%s:6443", master.GetIP())
|
||||||
|
tok := "tok-1"
|
||||||
|
claud := &Cloud{
|
||||||
|
KubeConfig: kubeconfig,
|
||||||
|
url: url,
|
||||||
|
token: tok,
|
||||||
|
Type: "k8s",
|
||||||
|
Nodes: map[string]Noder{"master-node": master, "agent-node": node},
|
||||||
|
}
|
||||||
|
meta, err := json.Marshal(claud)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cloud, err := Load(meta, createNodeFn)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(cloud.Nodes) != 2 {
|
||||||
|
t.Fatalf("should get %d but got %d", 2, len(cloud.Nodes))
|
||||||
|
}
|
||||||
|
|
||||||
|
master.EXPECT().Provision(map[string]string{}).Return(nil)
|
||||||
|
master.EXPECT().GetToken().Return(tok, nil)
|
||||||
|
node.EXPECT().Provision(map[string]string{
|
||||||
|
"url": cloud.url,
|
||||||
|
"token": cloud.token,
|
||||||
|
}).Return(nil)
|
||||||
|
if err := cloud.Provision(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
content, err := ioutil.ReadFile(claud.KubeConfig)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if string(content) != kubeconfContent {
|
||||||
|
t.Fatalf("should get %s but got %s", kubeconfContent, content)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestProvision(t *testing.T) {}
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/metrue/fx/driver"
|
"github.com/metrue/fx/infra"
|
||||||
"github.com/metrue/fx/pkg/spinner"
|
"github.com/metrue/fx/pkg/spinner"
|
||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
@@ -37,11 +37,6 @@ func Create(kubeconfig string) (*K8S, error) {
|
|||||||
return &K8S{clientset}, nil
|
return &K8S{clientset}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provision TODO may need support manually k8s cluster creation
|
|
||||||
func (k *K8S) Provision(ctx context.Context, isRemote bool) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deploy a image to be a service
|
// Deploy a image to be a service
|
||||||
func (k *K8S) Deploy(
|
func (k *K8S) Deploy(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
@@ -191,5 +186,5 @@ func (k *K8S) Ping(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ driver.Driver = &K8S{}
|
_ infra.Deployer = &K8S{}
|
||||||
)
|
)
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/metrue/fx/types"
|
"github.com/metrue/fx/types"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ func generateDeploymentSpec(
|
|||||||
Name: "fx-placeholder-container-name",
|
Name: "fx-placeholder-container-name",
|
||||||
Image: image,
|
Image: image,
|
||||||
Ports: ports,
|
Ports: ports,
|
||||||
ImagePullPolicy: apiv1.PullIfNotPresent,
|
ImagePullPolicy: v1.PullIfNotPresent,
|
||||||
}
|
}
|
||||||
return &appsv1.Deployment{
|
return &appsv1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
@@ -2,6 +2,7 @@ package k8s
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
|
apiv1 "k8s.io/api/core/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ func injectInitContainer(name string, deployment *appsv1.Deployment) *appsv1.Dep
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
deployment.Spec.Template.Spec.InitContainers = []v1.Container{initContainer}
|
deployment.Spec.Template.Spec.InitContainers = []apiv1.Container{initContainer}
|
||||||
deployment.Spec.Template.Spec.Volumes = volumes
|
deployment.Spec.Template.Spec.Volumes = volumes
|
||||||
return deployment
|
return deployment
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user