Compare commits

..

11 Commits

Author SHA1 Message Date
Roee Gadot
e8848fd305 no message 2021-07-15 15:14:40 +03:00
Roee Gadot
193fc2becc no message 2021-07-15 14:38:07 +03:00
Roee Gadot
9b616839bc Merge branch 'feature/TRA-3442_versioning' into feature/versioning 2021-07-15 14:35:42 +03:00
nimrod-up9
29ed9edb64 Added endpoint for metadata. 2021-07-15 14:34:48 +03:00
Roee Gadot
c88d068bfa no message 2021-07-15 14:34:40 +03:00
Roee Gadot
f839212b30 no message 2021-07-15 14:09:27 +03:00
Roee Gadot
6b7cb16a9f no message 2021-07-15 13:46:24 +03:00
Roee Gadot
919a5e6e6d no message 2021-07-15 13:28:56 +03:00
nimrod-up9
69dbd81837 Renamed public_routes.go -> entries_routes.go 2021-07-15 13:26:47 +03:00
nimrod-up9
d93913733e Moved version parser to shared. 2021-07-15 13:20:42 +03:00
nimrod-up9
7e52f46030 Default image uses semver. 2021-07-15 13:00:42 +03:00
10 changed files with 20 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ on:
branches:
- 'develop'
- 'main'
- 'feature/versioning'
jobs:
docker:
runs-on: ubuntu-latest

View File

@@ -16,6 +16,7 @@ import (
"mizuserver/pkg/routes"
"mizuserver/pkg/sensitiveDataFiltering"
"mizuserver/pkg/utils"
"mizuserver/pkg/version"
"os"
"os/signal"
"strings"
@@ -27,6 +28,8 @@ var standalone = flag.Bool("standalone", false, "Run in standalone tapper and AP
var aggregatorAddress = flag.String("aggregator-address", "", "Address of mizu collector for tapping")
func main() {
rlog.Infof("Version parameters are: %s %s %s %s", version.Branch, version.SemVer, version.GitCommitHash, version.BuildTimestamp)
flag.Parse()
hostMode := os.Getenv(shared.HostModeEnvVar) == "1"
tapOpts := &tap.TapOpts{HostMode: hostMode}

View File

@@ -10,7 +10,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
"path/filepath"
"os"
)
func NewFromInCluster(errOut chan error) (*Resolver, error) {
@@ -27,13 +26,8 @@ func NewFromInCluster(errOut chan error) (*Resolver, error) {
func NewFromOutOfCluster(kubeConfigPath string, errOut chan error) (*Resolver, error) {
if kubeConfigPath == "" {
env := os.Getenv("KUBECONFIG")
if env != "" {
kubeConfigPath = env
} else {
home := homedir.HomeDir()
kubeConfigPath = filepath.Join(home, ".kube", "config")
}
home := homedir.HomeDir()
kubeConfigPath = filepath.Join(home, ".kube", "config")
}
configPathList := filepath.SplitList(kubeConfigPath)

View File

@@ -5,7 +5,7 @@ import (
"mizuserver/pkg/controllers"
)
// EntriesRoutes defines the group of har entries routes.
// EntriesRoutes func for describe group of public routes.
func EntriesRoutes(fiberApp *fiber.App) {
routeGroup := fiberApp.Group("/api")

View File

@@ -5,7 +5,7 @@ import (
"mizuserver/pkg/controllers"
)
// MetadataRoutes defines the group of metadata routes.
// EntriesRoutes func for describe group of public routes.
func MetadataRoutes(fiberApp *fiber.App) {
routeGroup := fiberApp.Group("/metadata")

View File

@@ -2,7 +2,7 @@ package routes
import "github.com/gofiber/fiber/v2"
// NotFoundRoute defines the 404 Error route.
// NotFoundRoute func for describe 404 Error route.
func NotFoundRoute(fiberApp *fiber.App) {
fiberApp.Use(
func(c *fiber.Ctx) error {

View File

@@ -3,6 +3,7 @@ COMMIT_HASH=$(shell git rev-parse HEAD)
GIT_BRANCH=$(shell git branch --show-current | tr '[:upper:]' '[:lower:]')
GIT_VERSION=$(shell git branch --show-current | tr '[:upper:]' '[:lower:]')
BUILD_TIMESTAMP=$(shell date +%s)
SEM_VER=0.0.0
.PHONY: help
.DEFAULT_GOAL := help

View File

@@ -18,9 +18,7 @@ var fetchCmd = &cobra.Command{
Use: "fetch",
Short: "Download recorded traffic to files",
RunE: func(cmd *cobra.Command, args []string) error {
if isCompatible, err := mizu.CheckVersionCompatibility(mizuFetchOptions.MizuPort); err != nil {
return err
} else if !isCompatible {
if !mizu.CheckVersionCompatibility(mizuFetchOptions.MizuPort) {
return nil
}
RunMizuFetch(&mizuFetchOptions)

View File

@@ -15,9 +15,8 @@ var viewCmd = &cobra.Command{
Use: "view",
Short: "Open GUI in browser",
RunE: func(cmd *cobra.Command, args []string) error {
if isCompatible, err := mizu.CheckVersionCompatibility(mizuFetchOptions.MizuPort); err != nil {
return err
} else if !isCompatible {
if !mizu.CheckVersionCompatibility(mizuFetchOptions.MizuPort) {
return nil
}
runMizuView(mizuViewOptions)

View File

@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"github.com/up9inc/mizu/shared"
"github.com/up9inc/mizu/shared/semver"
"net/http"
"net/url"
)
@@ -23,24 +22,19 @@ func getApiVersion(port uint16) (string, error) {
defer statusResp.Body.Close()
versionResponse := &shared.VersionResponse{}
if err := json.NewDecoder(statusResp.Body).Decode(&versionResponse); err != nil {
return "", err
}
_ = json.NewDecoder(statusResp.Body).Decode(&versionResponse)
return versionResponse.SemVer, nil
}
func CheckVersionCompatibility(port uint16) (bool, error) {
func CheckVersionCompatibility(port uint16) bool {
apiSemVer, err := getApiVersion(port)
if err != nil {
return false, err
return true
}
if semver.SemVersion(apiSemVer).Major() == semver.SemVersion(SemVer).Major() &&
semver.SemVersion(apiSemVer).Minor() == semver.SemVersion(SemVer).Minor() {
return true, nil
if apiSemVer == SemVer {
return true
}
fmt.Printf(Red, fmt.Sprintf("cli version (%s) is not compatible with api version (%s)\n", SemVer, apiSemVer))
return false, nil
}
return false
}