mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-06 12:59:13 +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
|
// Scripting
|
||||||
connector.PostConsts(config.Config.Scripting.Consts)
|
connector.PostEnv(config.Config.Scripting.Env)
|
||||||
|
|
||||||
scripts, err := config.Config.Scripting.GetScripts()
|
scripts, err := config.Config.Scripting.GetScripts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ScriptingConfig struct {
|
type ScriptingConfig struct {
|
||||||
Consts map[string]interface{} `yaml:"consts"`
|
Env map[string]interface{} `yaml:"env"`
|
||||||
Source string `yaml:"source" default:""`
|
Source string `yaml:"source" default:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,27 +181,27 @@ func (connector *Connector) PostLicense(license string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (connector *Connector) PostConsts(consts map[string]interface{}) {
|
func (connector *Connector) PostEnv(env map[string]interface{}) {
|
||||||
if len(consts) == 0 {
|
if len(env) == 0 {
|
||||||
return
|
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 {
|
if envMarshalled, err := json.Marshal(env); err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to marshal the consts:")
|
log.Error().Err(err).Msg("Failed to marshal the env:")
|
||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
for !ok {
|
||||||
var resp *http.Response
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
log.Warn().Err(err).Msg("Failed sending the constants to Hub:")
|
log.Warn().Err(err).Msg("Failed sending the constants to Hub:")
|
||||||
} else {
|
} else {
|
||||||
ok = true
|
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)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user