Skip to content

Commit

Permalink
fix receiver name
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Scherba <[email protected]>
  • Loading branch information
miklezzzz committed Dec 29, 2024
1 parent cd2f876 commit bb55dec
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/module_manager/models/hooks/kind/batch_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (h *BatchHook) GetHookConfigDescription() string {
}

// Execute runs the hook via the OS interpreter and returns the result of the execution
func (sh *BatchHook) Execute(configVersion string, bContext []bindingcontext.BindingContext, moduleSafeName string, configValues, values utils.Values, logLabels map[string]string) (*HookResult, error) {
func (h *BatchHook) Execute(configVersion string, bContext []bindingcontext.BindingContext, moduleSafeName string, configValues, values utils.Values, logLabels map[string]string) (*HookResult, error) {
result := &HookResult{
Patches: make(map[utils.ValuesPatchType]*utils.ValuesPatch),
}
Expand All @@ -104,7 +104,7 @@ func (sh *BatchHook) Execute(configVersion string, bContext []bindingcontext.Bin
}

// tmp files has uuid in name and create only in tmp folder (because of RO filesystem)
tmpFiles, err := sh.prepareTmpFilesForHookRun(bindingContextBytes, moduleSafeName, configValues, values)
tmpFiles, err := h.prepareTmpFilesForHookRun(bindingContextBytes, moduleSafeName, configValues, values)
if err != nil {
return nil, err
}
Expand All @@ -116,7 +116,7 @@ func (sh *BatchHook) Execute(configVersion string, bContext []bindingcontext.Bin
for _, f := range tmpFiles {
err := os.Remove(f)
if err != nil {
sh.Hook.Logger.With("hook", sh.GetName()).
h.Hook.Logger.With("hook", h.GetName()).
Error("Remove tmp file",
slog.String("file", f),
log.Err(err))
Expand All @@ -130,20 +130,20 @@ func (sh *BatchHook) Execute(configVersion string, bContext []bindingcontext.Bin

envs := make([]string, 0)
args := make([]string, 0)
args = append(args, "hook", "run", strconv.Itoa(int(sh.ID)))
args = append(args, "hook", "run", strconv.Itoa(int(h.ID)))
envs = append(envs, os.Environ()...)
for envName, filePath := range tmpFiles {
envs = append(envs, fmt.Sprintf("%s=%s", envName, filePath))
}

cmd := executor.NewExecutor(
"",
sh.GetPath(),
h.GetPath(),
args,
envs).
WithLogProxyHookJSON(shapp.LogProxyHookJSON).
WithLogProxyHookJSONKey(sh.LogProxyHookJSONKey).
WithLogger(sh.Logger.Named("executor"))
WithLogProxyHookJSONKey(h.LogProxyHookJSONKey).
WithLogger(h.Logger.Named("executor"))

usage, err := cmd.RunAndLogLines(logLabels)
result.Usage = usage
Expand Down Expand Up @@ -248,41 +248,41 @@ func (h *BatchHook) GetAfterDeleteHelm() *float64 {
}

// PrepareTmpFilesForHookRun creates temporary files for hook and returns environment variables with paths
func (sh *BatchHook) prepareTmpFilesForHookRun(bindingContext []byte, moduleSafeName string, configValues, values utils.Values) (map[string]string, error) {
func (h *BatchHook) prepareTmpFilesForHookRun(bindingContext []byte, moduleSafeName string, configValues, values utils.Values) (map[string]string, error) {
var err error
tmpFiles := make(map[string]string)

tmpFiles["CONFIG_VALUES_PATH"], err = sh.prepareConfigValuesJsonFile(moduleSafeName, configValues)
tmpFiles["CONFIG_VALUES_PATH"], err = h.prepareConfigValuesJsonFile(moduleSafeName, configValues)
if err != nil {
return tmpFiles, err
}

tmpFiles["VALUES_PATH"], err = sh.prepareValuesJsonFile(moduleSafeName, values)
tmpFiles["VALUES_PATH"], err = h.prepareValuesJsonFile(moduleSafeName, values)
if err != nil {
return tmpFiles, err
}

tmpFiles["BINDING_CONTEXT_PATH"], err = sh.prepareBindingContextJsonFile(moduleSafeName, bindingContext)
tmpFiles["BINDING_CONTEXT_PATH"], err = h.prepareBindingContextJsonFile(moduleSafeName, bindingContext)
if err != nil {
return tmpFiles, err
}

tmpFiles["CONFIG_VALUES_JSON_PATCH_PATH"], err = sh.prepareConfigValuesJsonPatchFile()
tmpFiles["CONFIG_VALUES_JSON_PATCH_PATH"], err = h.prepareConfigValuesJsonPatchFile()
if err != nil {
return tmpFiles, err
}

tmpFiles["VALUES_JSON_PATCH_PATH"], err = sh.prepareValuesJsonPatchFile()
tmpFiles["VALUES_JSON_PATCH_PATH"], err = h.prepareValuesJsonPatchFile()
if err != nil {
return tmpFiles, err
}

tmpFiles["METRICS_PATH"], err = sh.prepareMetricsFile()
tmpFiles["METRICS_PATH"], err = h.prepareMetricsFile()
if err != nil {
return tmpFiles, err
}

tmpFiles["KUBERNETES_PATCH_PATH"], err = sh.prepareKubernetesPatchFile()
tmpFiles["KUBERNETES_PATCH_PATH"], err = h.prepareKubernetesPatchFile()
if err != nil {
return tmpFiles, err
}
Expand Down

0 comments on commit bb55dec

Please sign in to comment.