Skip to content

Commit

Permalink
fix nil (#555)
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Okhlopkov <[email protected]>
Co-authored-by: Pavel Okhlopkov <[email protected]>
  • Loading branch information
ldmonster and Pavel Okhlopkov authored Jan 24, 2025
1 parent 1f36a5c commit 53477c0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
20 changes: 20 additions & 0 deletions pkg/module_manager/models/hooks/kind/batch_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,42 @@ func (h *BatchHook) GetConfigForModule(_ string) (*config.HookConfig, error) {
}

func (h *BatchHook) GetOnStartup() *float64 {
if h.config == nil || h.config.OnStartup == nil {
return nil
}

res := float64(*h.config.OnStartup)

return &res
}

func (h *BatchHook) GetBeforeAll() *float64 {
if h.config == nil || h.config.OnBeforeHelm == nil {
return nil
}

res := float64(*h.config.OnBeforeHelm)

return &res
}

func (h *BatchHook) GetAfterAll() *float64 {
if h.config == nil || h.config.OnAfterHelm == nil {
return nil
}

res := float64(*h.config.OnAfterHelm)

return &res
}

func (h *BatchHook) GetAfterDeleteHelm() *float64 {
if h.config == nil || h.config.OnAfterDeleteHelm == nil {
return nil
}

res := float64(*h.config.OnAfterDeleteHelm)

return &res
}

Expand Down
26 changes: 11 additions & 15 deletions pkg/module_manager/models/hooks/kind/gohook.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,43 +198,39 @@ func (h *GoHook) GetConfigForModule(_ string) (*config.HookConfig, error) {
}

func (h *GoHook) GetOnStartup() *float64 {
if h.config.OnStartup != nil {
return &h.config.OnStartup.Order
if h.config == nil || h.config.OnStartup == nil {
return nil
}

return nil
return &h.config.OnStartup.Order
}

func (h *GoHook) GetBeforeAll() *float64 {
if h.config.OnBeforeAll != nil {
return &h.config.OnBeforeAll.Order
}

if h.config.OnBeforeHelm != nil {
return &h.config.OnBeforeHelm.Order
if h.config == nil || h.config.OnBeforeAll == nil {
return nil
}

return nil
return &h.config.OnBeforeAll.Order
}

func (h *GoHook) GetAfterAll() *float64 {
if h.config.OnAfterAll != nil {
if h.config != nil && h.config.OnAfterAll != nil {
return &h.config.OnAfterAll.Order
}

if h.config.OnAfterHelm != nil {
if h.config != nil && h.config.OnAfterHelm != nil {
return &h.config.OnAfterHelm.Order
}

return nil
}

func (h *GoHook) GetAfterDeleteHelm() *float64 {
if h.config.OnAfterDeleteHelm != nil {
return &h.config.OnAfterDeleteHelm.Order
if h.config == nil || h.config.OnAfterDeleteHelm == nil {
return nil
}

return nil
return &h.config.OnAfterDeleteHelm.Order
}

func newHookConfigFromGoConfig(input *gohook.HookConfig) (config.HookConfig, error) {
Expand Down

0 comments on commit 53477c0

Please sign in to comment.