mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-20 21:44:42 +00:00
✨ Watch scripts inside tap
command
This commit is contained in:
parent
ca35177b44
commit
cedb7bc8bc
@ -51,10 +51,14 @@ func runScripts() {
|
|||||||
runProxy(false)
|
runProxy(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
files := make(map[string]int64)
|
|
||||||
|
|
||||||
connector = connect.NewConnector(kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort), connect.DefaultRetries, connect.DefaultTimeout)
|
connector = connect.NewConnector(kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort), connect.DefaultRetries, connect.DefaultTimeout)
|
||||||
|
|
||||||
|
watchScripts(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func watchScripts(block bool) {
|
||||||
|
files := make(map[string]int64)
|
||||||
|
|
||||||
scripts, err := config.Config.Scripting.GetScripts()
|
scripts, err := config.Config.Scripting.GetScripts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Send()
|
log.Error().Err(err).Send()
|
||||||
@ -76,7 +80,9 @@ func runScripts() {
|
|||||||
log.Error().Err(err).Send()
|
log.Error().Err(err).Send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if block {
|
||||||
defer watcher.Close()
|
defer watcher.Close()
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@ -138,7 +144,9 @@ func runScripts() {
|
|||||||
|
|
||||||
log.Info().Str("directory", config.Config.Scripting.Source).Msg("Watching files against changes:")
|
log.Info().Str("directory", config.Config.Scripting.Source).Msg("Watching files against changes:")
|
||||||
|
|
||||||
|
if block {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
utils.WaitForTermination(ctx, cancel)
|
utils.WaitForTermination(ctx, cancel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,6 +469,10 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
|||||||
url := kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort)
|
url := kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort)
|
||||||
log.Info().Str("url", url).Msg(fmt.Sprintf(utils.Green, "Hub is available at:"))
|
log.Info().Str("url", url).Msg(fmt.Sprintf(utils.Green, "Hub is available at:"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.Config.Scripting.Source != "" && config.Config.Scripting.WatchScripts {
|
||||||
|
watchScripts(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func postFrontStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
func postFrontStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
type ScriptingConfig struct {
|
type ScriptingConfig struct {
|
||||||
Env map[string]interface{} `yaml:"env"`
|
Env map[string]interface{} `yaml:"env"`
|
||||||
Source string `yaml:"source" default:""`
|
Source string `yaml:"source" default:""`
|
||||||
|
WatchScripts bool `yaml:"watchScripts" default:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config *ScriptingConfig) GetScripts() (scripts []*misc.Script, err error) {
|
func (config *ScriptingConfig) GetScripts() (scripts []*misc.Script, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user