mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-25 04:17:25 +00:00
🎨 Merge uiUtils
and units
packages into utils
package
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
"github.com/kubeshark/kubeshark/uiUtils"
|
||||
"github.com/kubeshark/kubeshark/utils"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
@@ -65,7 +64,7 @@ func InitConfig(cmd *cobra.Command) error {
|
||||
return fmt.Errorf("config validation failed, err: %v", err)
|
||||
}
|
||||
|
||||
finalConfigPrettified, _ := uiUtils.PrettyJson(Config)
|
||||
finalConfigPrettified, _ := utils.PrettyJson(Config)
|
||||
log.Printf("Init config finished\n Final config: %v", finalConfigPrettified)
|
||||
|
||||
return nil
|
||||
@@ -84,7 +83,7 @@ func GetConfigWithDefaults() (*ConfigStruct, error) {
|
||||
}
|
||||
|
||||
func WriteConfig(config *ConfigStruct) error {
|
||||
template, err := uiUtils.PrettyYaml(config)
|
||||
template, err := utils.PrettyYaml(config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed converting config to yaml, err: %v", err)
|
||||
}
|
||||
@@ -130,20 +129,20 @@ func initFlag(f *pflag.Flag) {
|
||||
sliceValue, isSliceValue := f.Value.(pflag.SliceValue)
|
||||
if !isSliceValue {
|
||||
if err := mergeFlagValue(configElemValue, flagPath, strings.Join(flagPath, "."), f.Value.String()); err != nil {
|
||||
log.Printf(uiUtils.Warning, err)
|
||||
log.Printf(utils.Warning, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if f.Name == SetCommandName {
|
||||
if err := mergeSetFlag(configElemValue, sliceValue.GetSlice()); err != nil {
|
||||
log.Printf(uiUtils.Warning, err)
|
||||
log.Printf(utils.Warning, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := mergeFlagValues(configElemValue, flagPath, strings.Join(flagPath, "."), sliceValue.GetSlice()); err != nil {
|
||||
log.Printf(uiUtils.Warning, err)
|
||||
log.Printf(utils.Warning, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,10 +8,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/kubeshark/kubeshark/uiUtils"
|
||||
"github.com/kubeshark/kubeshark/utils"
|
||||
"github.com/kubeshark/worker/models"
|
||||
|
||||
"github.com/kubeshark/kubeshark/units"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -61,7 +59,7 @@ func (config *TapConfig) PodRegex() *regexp.Regexp {
|
||||
}
|
||||
|
||||
func (config *TapConfig) MaxEntriesDBSizeBytes() int64 {
|
||||
maxEntriesDBSizeBytes, _ := units.HumanReadableToBytes(config.HumanMaxEntriesDBSize)
|
||||
maxEntriesDBSizeBytes, _ := utils.HumanReadableToBytes(config.HumanMaxEntriesDBSize)
|
||||
return maxEntriesDBSizeBytes
|
||||
}
|
||||
|
||||
@@ -71,7 +69,7 @@ func (config *TapConfig) GetInsertionFilter() string {
|
||||
if _, err := os.Stat(insertionFilter); err == nil {
|
||||
b, err := os.ReadFile(insertionFilter)
|
||||
if err != nil {
|
||||
log.Printf(uiUtils.Warning, fmt.Sprintf("Couldn't read the file on path: %s, err: %v", insertionFilter, err))
|
||||
log.Printf(utils.Warning, fmt.Sprintf("Couldn't read the file on path: %s, err: %v", insertionFilter, err))
|
||||
} else {
|
||||
insertionFilter = string(b)
|
||||
}
|
||||
@@ -125,7 +123,7 @@ func (config *TapConfig) Validate() error {
|
||||
return fmt.Errorf("%s is not a valid regex %s", config.PodRegexStr, compileErr)
|
||||
}
|
||||
|
||||
_, parseHumanDataSizeErr := units.HumanReadableToBytes(config.HumanMaxEntriesDBSize)
|
||||
_, parseHumanDataSizeErr := utils.HumanReadableToBytes(config.HumanMaxEntriesDBSize)
|
||||
if parseHumanDataSizeErr != nil {
|
||||
return fmt.Errorf("Could not parse --%s value %s", HumanMaxEntriesDBSizeTapName, config.HumanMaxEntriesDBSize)
|
||||
}
|
||||
|
Reference in New Issue
Block a user