mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-04 20:08:38 +00:00
⚡ Change consts
config field to env
This commit is contained in:
parent
72a18871b1
commit
9a95fa364c
@ -448,7 +448,7 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
||||
}
|
||||
|
||||
// Scripting
|
||||
connector.PostConsts(config.Config.Scripting.Consts)
|
||||
connector.PostEnv(config.Config.Scripting.Env)
|
||||
|
||||
scripts, err := config.Config.Scripting.GetScripts()
|
||||
if err != nil {
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type ScriptingConfig struct {
|
||||
Consts map[string]interface{} `yaml:"consts"`
|
||||
Env map[string]interface{} `yaml:"env"`
|
||||
Source string `yaml:"source" default:""`
|
||||
}
|
||||
|
||||
|
@ -181,27 +181,27 @@ func (connector *Connector) PostLicense(license string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (connector *Connector) PostConsts(consts map[string]interface{}) {
|
||||
if len(consts) == 0 {
|
||||
func (connector *Connector) PostEnv(env map[string]interface{}) {
|
||||
if len(env) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
postConstsUrl := fmt.Sprintf("%s/scripts/consts", connector.url)
|
||||
postEnvUrl := fmt.Sprintf("%s/scripts/env", connector.url)
|
||||
|
||||
if constsMarshalled, err := json.Marshal(consts); err != nil {
|
||||
log.Error().Err(err).Msg("Failed to marshal the consts:")
|
||||
if envMarshalled, err := json.Marshal(env); err != nil {
|
||||
log.Error().Err(err).Msg("Failed to marshal the env:")
|
||||
} else {
|
||||
ok := false
|
||||
for !ok {
|
||||
var resp *http.Response
|
||||
if resp, err = utils.Post(postConstsUrl, "application/json", bytes.NewBuffer(constsMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK {
|
||||
if resp, err = utils.Post(postEnvUrl, "application/json", bytes.NewBuffer(envMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK {
|
||||
if _, ok := err.(*url.Error); ok {
|
||||
break
|
||||
}
|
||||
log.Warn().Err(err).Msg("Failed sending the constants to Hub:")
|
||||
} else {
|
||||
ok = true
|
||||
log.Info().Interface("consts", consts).Msg("Reported constants to Hub:")
|
||||
log.Info().Interface("env", env).Msg("Reported constants to Hub:")
|
||||
}
|
||||
time.Sleep(DefaultSleep)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user