🔨 Replace kubeshark occurrences with misc.Program, misc.Software and "self" wording

This commit is contained in:
M. Mert Yildiran
2022-12-29 04:12:03 +03:00
parent 9ab9f139c0
commit b0e83a9e25
27 changed files with 221 additions and 192 deletions

View File

@@ -1,11 +1,15 @@
package misc
import (
"fmt"
"os"
"path"
)
var (
Software = "Kubeshark"
Program = "kubeshark"
Website = "https://kubeshark.co"
Ver = "0.0"
Branch = "develop"
GitCommitHash = "" // this var is overridden using ldflags in makefile when building
@@ -19,5 +23,5 @@ func GetDotFolderPath() string {
if homeDirErr != nil {
return ""
}
return path.Join(home, ".kubeshark")
return path.Join(home, fmt.Sprintf(".%s", Program))
}

View File

@@ -9,18 +9,19 @@ import (
"github.com/kubeshark/kubeshark/config"
"github.com/kubeshark/kubeshark/kubernetes"
"github.com/kubeshark/kubeshark/misc"
"github.com/rs/zerolog/log"
)
func DumpLogs(ctx context.Context, provider *kubernetes.Provider, filePath string) error {
podExactRegex := regexp.MustCompile("^" + kubernetes.KubesharkResourcesPrefix)
podExactRegex := regexp.MustCompile("^" + kubernetes.SelfResourcesPrefix)
pods, err := provider.ListAllPodsMatchingRegex(ctx, podExactRegex, []string{config.Config.SelfNamespace})
if err != nil {
return err
}
if len(pods) == 0 {
return fmt.Errorf("no kubeshark pods found in namespace %s", config.Config.SelfNamespace)
return fmt.Errorf("No %s pods found in namespace %s", misc.Software, config.Config.SelfNamespace)
}
newZipFile, err := os.Create(filePath)

View File

@@ -21,7 +21,7 @@ func CheckNewerVersion() {
log.Info().Msg("Checking for a newer version...")
start := time.Now()
client := github.NewClient(nil)
latestRelease, _, err := client.Repositories.GetLatestRelease(context.Background(), "kubeshark", "kubeshark")
latestRelease, _, err := client.Repositories.GetLatestRelease(context.Background(), misc.Program, misc.Program)
if err != nil {
log.Error().Msg("Failed to get latest release.")
return
@@ -72,9 +72,9 @@ func CheckNewerVersion() {
if greater {
var downloadCommand string
if runtime.GOOS == "windows" {
downloadCommand = fmt.Sprintf("curl -LO %v/kubeshark.exe", strings.Replace(*latestRelease.HTMLURL, "tag", "download", 1))
downloadCommand = fmt.Sprintf("curl -LO %v/%s.exe", strings.Replace(*latestRelease.HTMLURL, "tag", "download", 1), misc.Program)
} else {
downloadCommand = "sh <(curl -Ls https://kubeshark.co/install)"
downloadCommand = fmt.Sprintf("sh <(curl -Ls %s/install)", misc.Website)
}
msg := fmt.Sprintf("Update available! %v -> %v run:", misc.Ver, gitHubVersion)
log.Warn().Str("command", downloadCommand).Msg(fmt.Sprintf(utils.Yellow, msg))