diff --git a/cmd/tapPcapRunner.go b/cmd/tapPcapRunner.go index d5a9a702b..c89ff7667 100644 --- a/cmd/tapPcapRunner.go +++ b/cmd/tapPcapRunner.go @@ -331,6 +331,11 @@ func pcap(tarPath string) { connector = connect.NewConnector(kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort), connect.DefaultRetries, connect.DefaultTimeout) connector.PostWorkerPodToHub(workerPod) + // License + if config.Config.License != "" { + connector.PostLicense(config.Config.License) + } + log.Info(). Str("url", kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort)). Msg(fmt.Sprintf(utils.Green, "Hub is available at:")) diff --git a/cmd/tapRunner.go b/cmd/tapRunner.go index f6904d94e..8df068f9f 100644 --- a/cmd/tapRunner.go +++ b/cmd/tapRunner.go @@ -435,35 +435,36 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider // Grace period log.Info().Msg("Waiting for worker containers...") time.Sleep(5 * time.Second) - } + } else { - // Storage limit - connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes()) + // Storage limit + connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes()) - // Pod regex - connector.PostRegexToHub(config.Config.Tap.PodRegexStr, state.targetNamespaces) + // Pod regex + connector.PostRegexToHub(config.Config.Tap.PodRegexStr, state.targetNamespaces) - // License - if config.Config.License != "" { - connector.PostLicense(config.Config.License) - } + // License + if config.Config.License != "" { + connector.PostLicense(config.Config.License) + } - // Scripting - connector.PostEnv(config.Config.Scripting.Env) + // Scripting + connector.PostEnv(config.Config.Scripting.Env) - scripts, err := config.Config.Scripting.GetScripts() - if err != nil { - log.Error().Err(err).Send() - } - - for _, script := range scripts { - _, err = connector.PostScript(script) + scripts, err := config.Config.Scripting.GetScripts() if err != nil { log.Error().Err(err).Send() } - } - connector.PostScriptDone() + for _, script := range scripts { + _, err = connector.PostScript(script) + if err != nil { + log.Error().Err(err).Send() + } + } + + connector.PostScriptDone() + } if !update { // Hub proxy URL diff --git a/kubernetes/provider.go b/kubernetes/provider.go index 4f7e66743..08926671a 100644 --- a/kubernetes/provider.go +++ b/kubernetes/provider.go @@ -3,6 +3,7 @@ package kubernetes import ( "bytes" "context" + "encoding/json" "errors" "fmt" "io" @@ -212,6 +213,25 @@ func (provider *Provider) BuildHubPod(opts *PodOptions) (*core.Pod, error) { command = append(command, "-debug") } + // Scripting environment variables + scriptingEnvMarshalled, err := json.Marshal(config.Config.Scripting.Env) + if err != nil { + return nil, err + } + + // Scripting scripts + scripts, err := config.Config.Scripting.GetScripts() + if err != nil { + return nil, err + } + if scripts == nil { + scripts = []*misc.Script{} + } + scriptsMarshalled, err := json.Marshal(scripts) + if err != nil { + return nil, err + } + containers := []core.Container{ { Name: opts.PodName, @@ -245,6 +265,14 @@ func (provider *Provider) BuildHubPod(opts *PodOptions) (*core.Pod, error) { Name: "LICENSE", Value: "", }, + { + Name: "SCRIPTING_ENV", + Value: string(scriptingEnvMarshalled), + }, + { + Name: "SCRIPTING_SCRIPTS", + Value: string(scriptsMarshalled), + }, }, }, }