mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-03-03 03:02:11 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8848fd305 | ||
|
|
193fc2becc | ||
|
|
9b616839bc | ||
|
|
29ed9edb64 | ||
|
|
c88d068bfa | ||
|
|
f839212b30 | ||
|
|
6b7cb16a9f | ||
|
|
919a5e6e6d | ||
|
|
69dbd81837 | ||
|
|
d93913733e | ||
|
|
7e52f46030 |
1
.github/workflows/publish.yml
vendored
1
.github/workflows/publish.yml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
branches:
|
||||
- 'develop'
|
||||
- 'main'
|
||||
- 'feature/versioning'
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user