init go mod #821

This commit is contained in:
barnettZQG 2020-09-06 11:09:48 +08:00
parent d4fe3201ac
commit 6c2807a856
5000 changed files with 474 additions and 2910885 deletions

5
.gitignore vendored
View File

@ -44,6 +44,7 @@ venv/
.release/
_output/
.cache
hack/deb/ubuntu-trusty
@ -54,4 +55,6 @@ test.db
*.bak
temp
.scannerwork
.scannerwork
Library

View File

@ -40,23 +40,6 @@ image:
binary:
@echo "🐳build binary ${WHAT} os ${GOOS}"
@ GOOS=${GOOS} bash ./release.sh binary ${WHAT}
run-c:image
test/run/run_${WHAT}.sh
run:build
ifeq ($(WHAT),mq)
${BIN_PATH}/${BASE_NAME}-mq --log-level=debug
else ifeq ($(WHAT),worker)
test/run/run_worker.sh ${BIN_PATH}/${BASE_NAME}-worker
else ifeq ($(WHAT),builder)
${BIN_PATH}/${BASE_NAME}-chaos \
--log-level=debug \
--mysql="root:@tcp(127.0.0.1:3306)/region"
else
test/run/run_${WHAT}.sh ${BIN_PATH}/${BASE_NAME}-$(WHAT)
endif
doc:
@cd cmd/api && swagger generate spec -o ../../hack/contrib/docker/api/html/swagger.json
check:
./check.sh
mock:

View File

@ -26,7 +26,7 @@ import (
"github.com/go-chi/chi"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//Routes routes

View File

@ -25,7 +25,7 @@ import (
"github.com/go-chi/chi"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//License license struct

View File

@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/controller/upload"
"github.com/goodrain/rainbond/api/handler"

View File

@ -6,7 +6,7 @@ import (
"io/ioutil"
"net/http"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"
"github.com/goodrain/rainbond/api/model"

View File

@ -22,7 +22,7 @@ import (
"net/http"
"strconv"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/jinzhu/gorm"
"github.com/goodrain/rainbond/api/handler"

View File

@ -22,7 +22,7 @@ import (
"fmt"
"net/http"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"

View File

@ -21,7 +21,7 @@ package controller
import (
"net/http"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/handler"
httputil "github.com/goodrain/rainbond/util/http"

View File

@ -26,7 +26,7 @@ import (
"github.com/jinzhu/gorm"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/bitly/go-simplejson"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/db"

View File

@ -27,7 +27,7 @@ import (
httputil "github.com/goodrain/rainbond/util/http"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"

View File

@ -24,7 +24,7 @@ import (
"net/url"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/jinzhu/gorm"
k8svalidation "k8s.io/apimachinery/pkg/util/validation"

View File

@ -27,8 +27,8 @@ import (
httputil "github.com/goodrain/rainbond/util/http"
"github.com/Sirupsen/logrus"
validator "github.com/thedevsaddam/govalidator"
validator "github.com/goodrain/rainbond/util/govalidator"
"github.com/sirupsen/logrus"
)
//LicenseManager license manager

View File

@ -23,7 +23,7 @@ import (
"net/http"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"

View File

@ -28,7 +28,6 @@ import (
"strconv"
"strings"
"github.com/Sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"
@ -39,11 +38,12 @@ import (
dbmodel "github.com/goodrain/rainbond/db/model"
mqclient "github.com/goodrain/rainbond/mq/client"
validation "github.com/goodrain/rainbond/util/endpoint"
"github.com/goodrain/rainbond/util/fuzzy"
httputil "github.com/goodrain/rainbond/util/http"
"github.com/goodrain/rainbond/worker/client"
"github.com/jinzhu/gorm"
"github.com/renstorm/fuzzysearch/fuzzy"
validator "github.com/thedevsaddam/govalidator"
"github.com/sirupsen/logrus"
validator "github.com/goodrain/rainbond/util/govalidator"
)
//V2Routes v2Routes

View File

@ -24,9 +24,9 @@ import (
"net/http"
"os"
validator "github.com/thedevsaddam/govalidator"
validator "github.com/goodrain/rainbond/util/govalidator"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"

View File

@ -22,7 +22,7 @@ import (
"encoding/json"
"net/http"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"
"github.com/goodrain/rainbond/api/model"

View File

@ -23,7 +23,7 @@ import (
"net/http"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/middleware"

View File

@ -24,7 +24,7 @@ import (
"os"
"path"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/discover"
"github.com/goodrain/rainbond/api/handler"

View File

@ -25,7 +25,7 @@ import (
"os/exec"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//StartRegionAPI 启动

View File

@ -22,7 +22,7 @@ import (
"encoding/json"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
tsdbClient "github.com/bluebreezecf/opentsdb-goclient/client"
tsdbConfig "github.com/bluebreezecf/opentsdb-goclient/config"
"github.com/goodrain/rainbond/cmd/api/option"

View File

@ -27,7 +27,7 @@ import (
corediscoverconfig "github.com/goodrain/rainbond/discover/config"
etcdutil "github.com/goodrain/rainbond/util/etcd"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//EndpointDiscover 后端服务自动发现

View File

@ -11,7 +11,7 @@ import (
"regexp"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/pkg/errors"

View File

@ -4,7 +4,7 @@ import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
apimodel "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/db/errors"

View File

@ -31,7 +31,7 @@ import (
"math/big"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/jinzhu/gorm"
api_model "github.com/goodrain/rainbond/api/model"

View File

@ -25,7 +25,7 @@ import (
"os"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/db"

View File

@ -4,7 +4,7 @@ import (
"fmt"
"runtime"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/model"
"github.com/shirou/gopsutil/disk"
corev1 "k8s.io/api/core/v1"

View File

@ -3,7 +3,7 @@ package handler
import (
"context"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
)

View File

@ -25,7 +25,7 @@ import (
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"
tutil "github.com/goodrain/rainbond/util"

View File

@ -28,7 +28,7 @@ import (
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
func TestEmessage(t *testing.T) {

View File

@ -27,7 +27,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
apimodel "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/db"

View File

@ -26,7 +26,7 @@ import (
"testing"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/db"
apimodel "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/cmd/api/option"

View File

@ -26,7 +26,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/jinzhu/gorm"
"github.com/pquerna/ffjson/ffjson"

View File

@ -19,7 +19,7 @@
package handler
import (
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
api_db "github.com/goodrain/rainbond/api/db"
"github.com/goodrain/rainbond/api/handler/group"

View File

@ -23,7 +23,7 @@ import (
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/jinzhu/gorm"
"github.com/pquerna/ffjson/ffjson"
)

View File

@ -25,7 +25,7 @@ import (
"github.com/pquerna/ffjson/ffjson"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"

View File

@ -33,7 +33,7 @@ import (
builder_model "github.com/goodrain/rainbond/builder/model"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//PluginAction plugin action struct

View File

@ -26,7 +26,7 @@ import (
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//RootAction root function action struct

View File

@ -28,7 +28,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/jinzhu/gorm"
"github.com/pquerna/ffjson/ffjson"

View File

@ -23,7 +23,7 @@ import (
"strings"
"container/list"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/db"
gclient "github.com/goodrain/rainbond/mq/client"

View File

@ -24,7 +24,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/builder/exector"

View File

@ -22,7 +22,7 @@ import (
"fmt"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"

View File

@ -25,7 +25,7 @@ import (
"github.com/jinzhu/gorm"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/db"

View File

@ -27,7 +27,7 @@ import (
api_model "github.com/goodrain/rainbond/api/model"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/pquerna/ffjson/ffjson"
)

View File

@ -24,7 +24,7 @@ import (
"github.com/goodrain/rainbond/mq/client"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/builder/exector"

View File

@ -32,7 +32,7 @@ import (
"github.com/goodrain/rainbond/db"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"

View File

@ -28,7 +28,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/cmd/api/option"

View File

@ -1,7 +1,7 @@
package handler
import (
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
dbmodel "github.com/goodrain/rainbond/db/model"
"github.com/pkg/errors"
)

View File

@ -23,7 +23,7 @@ import (
"strconv"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"

View File

@ -24,7 +24,7 @@ import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"

View File

@ -26,7 +26,7 @@ import (
"net/http"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/util"

View File

@ -28,7 +28,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//HTTPProxy HTTPProxy

View File

@ -23,7 +23,7 @@ import (
"strings"
"sync/atomic"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//ContextKey context key

View File

@ -25,7 +25,7 @@ import (
"strings"
"testing"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
func TestHttpProxy(t *testing.T) {

View File

@ -26,7 +26,7 @@ import (
"net/url"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/gorilla/websocket"
)

View File

@ -23,7 +23,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/node/api/model"
utilhttp "github.com/goodrain/rainbond/util/http"

View File

@ -23,7 +23,7 @@ import (
"encoding/json"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/node/api/model"
utilhttp "github.com/goodrain/rainbond/util/http"

View File

@ -30,7 +30,7 @@ import (
"path"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/cmd"

View File

@ -21,7 +21,7 @@ package region
import (
"path"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/api/util"
dbmodel "github.com/goodrain/rainbond/db/model"
utilhttp "github.com/goodrain/rainbond/util/http"

View File

@ -50,7 +50,7 @@ import (
apimiddleware "github.com/goodrain/rainbond/api/middleware"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
)

View File

@ -21,7 +21,7 @@ package util
import (
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"
"github.com/goodrain/rainbond/util"

View File

@ -27,7 +27,7 @@ import (
"github.com/jinzhu/gorm"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
//APIHandleError handle create err for api

View File

@ -1,7 +1,7 @@
package util
import (
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"strings"
"encoding/json"

View File

@ -28,7 +28,7 @@ import (
"net/http"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/bitly/go-simplejson"
"github.com/goodrain/rainbond/builder/discover"
"io/ioutil"

View File

@ -19,7 +19,7 @@
package controller
import (
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/bitly/go-simplejson"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"

View File

@ -25,7 +25,7 @@ import (
"os/exec"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/bitly/go-simplejson"
"github.com/go-chi/chi"
"github.com/goodrain/rainbond/builder"

View File

@ -31,7 +31,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/eapache/channels"

View File

@ -23,7 +23,7 @@ import (
"path"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/goodrain/rainbond/builder"
"github.com/goodrain/rainbond/builder/sources"

View File

@ -29,7 +29,7 @@ import (
"github.com/docker/docker/client"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/goodrain/rainbond/builder"

View File

@ -23,7 +23,7 @@ import (
"os"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/util"

View File

@ -25,7 +25,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/builder/exector"
"github.com/goodrain/rainbond/cmd/builder/option"
"github.com/goodrain/rainbond/mq/api/grpc/pb"

View File

@ -22,7 +22,7 @@ import (
"fmt"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder"
"github.com/goodrain/rainbond/builder/build"

View File

@ -22,7 +22,7 @@ import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/builder"
"github.com/goodrain/rainbond/builder/sources"
"github.com/goodrain/rainbond/event"

View File

@ -28,7 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder"
"github.com/goodrain/rainbond/builder/build"

View File

@ -29,7 +29,7 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/docker/docker/client"
"github.com/tidwall/gjson"

View File

@ -29,7 +29,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder"
"github.com/goodrain/rainbond/builder/sources"

View File

@ -22,7 +22,7 @@ import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/cmd/builder/option"
eventutil "github.com/goodrain/rainbond/eventlog/util"
"github.com/pquerna/ffjson/ffjson"

View File

@ -34,7 +34,7 @@ import (
"github.com/goodrain/rainbond/builder/sources/registry"
"github.com/goodrain/rainbond/db"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder/cloudos"
dbmodel "github.com/goodrain/rainbond/db/model"

View File

@ -29,7 +29,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder"

View File

@ -21,7 +21,7 @@ package exector
import (
"testing"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/pquerna/ffjson/ffjson"
dbmodel "github.com/goodrain/rainbond/db/model"

View File

@ -28,7 +28,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
simplejson "github.com/bitly/go-simplejson"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/api/model"

View File

@ -35,7 +35,7 @@ import (
"github.com/goodrain/rainbond/builder/model"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/mq/api/grpc/pb"
)

View File

@ -30,7 +30,7 @@ import (
"github.com/goodrain/rainbond/mq/api/grpc/pb"
"github.com/pquerna/ffjson/ffjson"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
func (e *exectorManager) pluginImageBuild(task *pb.TaskMessage) {

View File

@ -25,7 +25,7 @@ import (
"github.com/ghodss/yaml"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/builder/parser"
"github.com/goodrain/rainbond/event"
"github.com/goodrain/rainbond/mq/api/grpc/pb"

View File

@ -24,7 +24,7 @@ import (
"github.com/goodrain/rainbond/builder"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder/sources"

View File

@ -25,7 +25,7 @@ import (
"github.com/goodrain/rainbond/builder"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder/sources"

View File

@ -26,7 +26,7 @@ import (
"os/exec"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/coreos/etcd/clientv3"
"github.com/goodrain/rainbond/builder/sources"
"github.com/goodrain/rainbond/event"

View File

@ -25,7 +25,7 @@ import (
"sync"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/eapache/channels"
corev1 "k8s.io/api/core/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"

View File

@ -25,7 +25,7 @@ import (
"path"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/builder/parser/types"
"github.com/goodrain/rainbond/util"
)

View File

@ -23,7 +23,7 @@ import (
"io/ioutil"
"path"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/goodrain/rainbond/util"
yaml "gopkg.in/yaml.v2"
)

View File

@ -26,7 +26,7 @@ import (
yaml "gopkg.in/yaml.v2"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/libcompose/project"
"github.com/fatih/structs"
)

View File

@ -1,384 +0,0 @@
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package compose
import (
"os"
"reflect"
"strings"
"testing"
"time"
"github.com/docker/cli/cli/compose/types"
"github.com/docker/libcompose/config"
"github.com/docker/libcompose/project"
"github.com/docker/libcompose/yaml"
"github.com/kubernetes/kompose/pkg/kobject"
"github.com/pkg/errors"
"k8s.io/kubernetes/pkg/api"
)
func durationPtr(value time.Duration) *time.Duration {
return &value
}
func TestParseHealthCheck(t *testing.T) {
helperValue := uint64(2)
check := types.HealthCheckConfig{
Test: []string{"CMD-SHELL", "echo", "foobar"},
Timeout: durationPtr(1 * time.Second),
Interval: durationPtr(2 * time.Second),
Retries: &helperValue,
StartPeriod: durationPtr(3 * time.Second),
}
// CMD-SHELL or SHELL is included Test within docker/cli, thus we remove the first value in Test
expected := kobject.HealthCheck{
Test: []string{"echo", "foobar"},
Timeout: 1,
Interval: 2,
Retries: 2,
StartPeriod: 3,
}
output, err := parseHealthCheck(check)
if err != nil {
t.Errorf("Unable to convert HealthCheckConfig: %s", err)
}
if !reflect.DeepEqual(output, expected) {
t.Errorf("Structs are not equal, expected: %v, output: %v", expected, output)
}
}
func TestLoadV3Volumes(t *testing.T) {
vol := types.ServiceVolumeConfig{
Type: "volume",
Source: "/tmp/foobar",
Target: "/tmp/foobar",
ReadOnly: true,
}
volumes := []types.ServiceVolumeConfig{vol}
output := loadV3Volumes(volumes)
expected := "/tmp/foobar:/tmp/foobar:ro"
if output[0] != expected {
t.Errorf("Expected %s, got %s", expected, output[0])
}
}
func TestLoadV3Ports(t *testing.T) {
port := types.ServicePortConfig{
Target: 80,
Published: 80,
Protocol: "TCP",
}
ports := []types.ServicePortConfig{port}
output := loadV3Ports(ports)
expected := kobject.Ports{
HostPort: 80,
ContainerPort: 80,
Protocol: api.Protocol("TCP"),
}
if output[0] != expected {
t.Errorf("Expected %v, got %v", expected, output[0])
}
}
// Test if service types are parsed properly on user input
// give a service type and expect correct input
func TestHandleServiceType(t *testing.T) {
tests := []struct {
labelValue string
serviceType string
}{
{"NodePort", "NodePort"},
{"nodeport", "NodePort"},
{"LoadBalancer", "LoadBalancer"},
{"loadbalancer", "LoadBalancer"},
{"ClusterIP", "ClusterIP"},
{"clusterip", "ClusterIP"},
{"", "ClusterIP"},
}
for _, tt := range tests {
result, err := handleServiceType(tt.labelValue)
if err != nil {
t.Error(errors.Wrap(err, "handleServiceType failed"))
}
if result != tt.serviceType {
t.Errorf("Expected %q, got %q", tt.serviceType, result)
}
}
}
// Test loading of ports
func TestLoadPorts(t *testing.T) {
port1 := []string{"127.0.0.1:80:80/tcp"}
result1 := kobject.Ports{
HostIP: "127.0.0.1",
HostPort: 80,
ContainerPort: 80,
Protocol: api.ProtocolTCP,
}
port2 := []string{"80:80/tcp"}
result2 := kobject.Ports{
HostPort: 80,
ContainerPort: 80,
Protocol: api.ProtocolTCP,
}
port3 := []string{"80:80"}
result3 := kobject.Ports{
HostPort: 80,
ContainerPort: 80,
Protocol: api.ProtocolTCP,
}
port4 := []string{"80"}
result4 := kobject.Ports{
HostPort: 0,
ContainerPort: 80,
Protocol: api.ProtocolTCP,
}
tests := []struct {
ports []string
result kobject.Ports
}{
{port1, result1},
{port2, result2},
{port3, result3},
{port4, result4},
}
for _, tt := range tests {
result, err := loadPorts(tt.ports)
if err != nil {
t.Errorf("Unexpected error with loading ports %v", err)
}
if result[0] != tt.result {
t.Errorf("Expected %q, got %q", tt.result, result[0])
}
}
}
func TestLoadEnvVar(t *testing.T) {
ev1 := []string{"foo=bar"}
rs1 := kobject.EnvVar{
Name: "foo",
Value: "bar",
}
ev2 := []string{"foo:bar"}
rs2 := kobject.EnvVar{
Name: "foo",
Value: "bar",
}
ev3 := []string{"foo"}
rs3 := kobject.EnvVar{
Name: "foo",
Value: "",
}
ev4 := []string{"osfoo"}
rs4 := kobject.EnvVar{
Name: "osfoo",
Value: "osbar",
}
ev5 := []string{"foo:bar=foobar"}
rs5 := kobject.EnvVar{
Name: "foo",
Value: "bar=foobar",
}
ev6 := []string{"foo=foo:bar"}
rs6 := kobject.EnvVar{
Name: "foo",
Value: "foo:bar",
}
ev7 := []string{"foo:"}
rs7 := kobject.EnvVar{
Name: "foo",
Value: "",
}
ev8 := []string{"foo="}
rs8 := kobject.EnvVar{
Name: "foo",
Value: "",
}
tests := []struct {
envvars []string
results kobject.EnvVar
}{
{ev1, rs1},
{ev2, rs2},
{ev3, rs3},
{ev4, rs4},
{ev5, rs5},
{ev6, rs6},
{ev7, rs7},
{ev8, rs8},
}
os.Setenv("osfoo", "osbar")
for _, tt := range tests {
result := loadEnvVars(tt.envvars)
if result[0] != tt.results {
t.Errorf("Expected %q, got %q", tt.results, result[0])
}
}
}
// TestUnsupportedKeys test checkUnsupportedKey function with various
// docker-compose projects
func TestUnsupportedKeys(t *testing.T) {
// create project that will be used in test cases
projectWithNetworks := project.NewProject(&project.Context{}, nil, nil)
projectWithNetworks.ServiceConfigs = config.NewServiceConfigs()
projectWithNetworks.ServiceConfigs.Add("foo", &config.ServiceConfig{
Image: "foo/bar",
Build: yaml.Build{
Context: "./build",
},
Hostname: "localhost",
Ports: []string{}, // test empty array
Networks: &yaml.Networks{
Networks: []*yaml.Network{
&yaml.Network{
Name: "net1",
},
},
},
})
projectWithNetworks.ServiceConfigs.Add("bar", &config.ServiceConfig{
Image: "bar/foo",
Build: yaml.Build{
Context: "./build",
},
Hostname: "localhost",
Ports: []string{}, // test empty array
Networks: &yaml.Networks{
Networks: []*yaml.Network{
&yaml.Network{
Name: "net1",
},
},
},
})
projectWithNetworks.VolumeConfigs = map[string]*config.VolumeConfig{
"foo": &config.VolumeConfig{
Driver: "storage",
},
}
projectWithNetworks.NetworkConfigs = map[string]*config.NetworkConfig{
"foo": &config.NetworkConfig{
Driver: "bridge",
},
}
projectWithEmptyNetwork := project.NewProject(&project.Context{}, nil, nil)
projectWithEmptyNetwork.ServiceConfigs = config.NewServiceConfigs()
projectWithEmptyNetwork.ServiceConfigs.Add("foo", &config.ServiceConfig{
Networks: &yaml.Networks{},
})
projectWithDefaultNetwork := project.NewProject(&project.Context{}, nil, nil)
projectWithDefaultNetwork.ServiceConfigs = config.NewServiceConfigs()
projectWithDefaultNetwork.ServiceConfigs.Add("foo", &config.ServiceConfig{
Networks: &yaml.Networks{
Networks: []*yaml.Network{
&yaml.Network{
Name: "default",
},
},
},
})
// define all test cases for checkUnsupportedKey function
testCases := map[string]struct {
composeProject *project.Project
expectedUnsupportedKeys []string
}{
"With Networks (service and root level)": {
projectWithNetworks,
[]string{"root level networks", "root level volumes", "hostname", "networks"},
},
"Empty Networks on Service level": {
projectWithEmptyNetwork,
[]string{"networks"},
},
"Default root level Network": {
projectWithDefaultNetwork,
[]string(nil),
},
}
for name, test := range testCases {
t.Log("Test case:", name)
keys := checkUnsupportedKey(test.composeProject)
if !reflect.DeepEqual(keys, test.expectedUnsupportedKeys) {
t.Errorf("ERROR: Expecting unsupported keys: ['%s']. Got: ['%s']", strings.Join(test.expectedUnsupportedKeys, "', '"), strings.Join(keys, "', '"))
}
}
}
func TestNormalizeServiceNames(t *testing.T) {
testCases := []struct {
composeServiceName string
normalizedServiceName string
}{
{"foo_bar", "foo-bar"},
{"foo", "foo"},
{"foo.bar", "foo.bar"},
//{"", ""},
}
for _, testCase := range testCases {
returnValue := normalizeServiceNames(testCase.composeServiceName)
if returnValue != testCase.normalizedServiceName {
t.Logf("Expected %q, got %q", testCase.normalizedServiceName, returnValue)
}
}
}
func TestCheckLabelsPorts(t *testing.T) {
testCases := []struct {
name string
noOfPort int
labels string
svcName string
expectError bool
}{
{"ports is defined", 1, "NodePort", "foo", false},
{"ports is not defined", 0, "NodePort", "foo", true},
}
var err error
for _, testcase := range testCases {
t.Log(testcase.name)
err = checkLabelsPorts(testcase.noOfPort, testcase.labels, testcase.svcName)
if testcase.expectError && err == nil {
t.Log("Expected error, got ", err)
}
}
}

View File

@ -24,7 +24,7 @@ import (
"path/filepath"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
)
// load environment variables from compose file

View File

@ -25,7 +25,7 @@ import (
"strconv"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/libcompose/project"
)

View File

@ -24,7 +24,7 @@ import (
"strconv"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
libcomposeyaml "github.com/docker/libcompose/yaml"
"github.com/twinj/uuid"

View File

@ -25,7 +25,7 @@ import (
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
c "github.com/coreos/etcd/clientv3"
)

View File

@ -23,7 +23,7 @@ import (
"runtime"
"strings"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/client"
"github.com/goodrain/rainbond/builder/parser/compose"
"github.com/goodrain/rainbond/builder/parser/types"

View File

@ -25,7 +25,7 @@ import (
"github.com/goodrain/rainbond/event"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/docker/client"
"github.com/ghodss/yaml"
)

View File

@ -22,7 +22,7 @@ import (
"fmt"
"testing"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
//"github.com/docker/docker/client"
"github.com/docker/docker/client"
)

View File

@ -24,7 +24,7 @@ import (
dbmodel "github.com/goodrain/rainbond/db/model"
"github.com/Sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/docker/distribution/reference"
"github.com/goodrain/rainbond/builder/parser/code"
"github.com/goodrain/rainbond/builder/parser/discovery"

Some files were not shown because too many files have changed in this diff Show More