🐛 Fix selfnamespace issue by changing its location in the config and adding --selfnamespace flag to tap and clean commands

This commit is contained in:
M. Mert Yildiran
2023-03-26 23:26:35 +03:00
parent 261df8261f
commit 7f6f710b3f
13 changed files with 49 additions and 37 deletions

View File

@@ -58,7 +58,7 @@ func InitConfig(cmd *cobra.Command) error {
Config = CreateDefaultConfig()
cmdName = cmd.Name()
if utils.Contains([]string{"console", "pro", "proxy", "scripts"}, cmdName) {
if utils.Contains([]string{"clean", "console", "pro", "proxy", "scripts"}, cmdName) {
cmdName = "tap"
}

View File

@@ -11,7 +11,6 @@ import (
)
const (
SelfNamespaceConfigName = "selfnamespace"
KubeConfigPathConfigName = "kube-configpath"
)
@@ -29,7 +28,6 @@ type ConfigStruct struct {
Logs configStructs.LogsConfig `yaml:"logs"`
Config configStructs.ConfigConfig `yaml:"config,omitempty"`
Kube KubeConfig `yaml:"kube"`
SelfNamespace string `yaml:"selfnamespace" default:"kubeshark"`
DumpLogs bool `yaml:"dumplogs" default:"false"`
HeadlessMode bool `yaml:"headless" default:"false"`
License string `yaml:"license" default:""`
@@ -51,7 +49,7 @@ func (config *ConfigStruct) ImagePullSecrets() []v1.LocalObjectReference {
}
func (config *ConfigStruct) IsNsRestrictedMode() bool {
return config.SelfNamespace != misc.Program // Notice "kubeshark" string must match the default SelfNamespace
return config.Tap.SelfNamespace != misc.Program // Notice "kubeshark" string must match the default SelfNamespace
}
func (config *ConfigStruct) KubeConfigPath() string {

View File

@@ -18,6 +18,7 @@ const (
ProxyHostLabel = "proxy-host"
NamespacesLabel = "namespaces"
AllNamespacesLabel = "allnamespaces"
SelfNamespaceLabel = "selfnamespace"
StorageLimitLabel = "storagelimit"
DryRunLabel = "dryrun"
PcapLabel = "pcap"
@@ -73,6 +74,7 @@ type TapConfig struct {
PodRegexStr string `yaml:"regex" default:".*"`
Namespaces []string `yaml:"namespaces"`
AllNamespaces bool `yaml:"allnamespaces" default:"false"`
SelfNamespace string `yaml:"selfnamespace" default:"kubeshark"`
StorageLimit string `yaml:"storagelimit" default:"200MB"`
DryRun bool `yaml:"dryrun" default:"false"`
Pcap string `yaml:"pcap" default:""`