Skip to content

Conversation

fromsaurav
Copy link
Contributor

@fromsaurav fromsaurav commented Aug 18, 2025

Summary

Refactored core initialization functions to return error instead of bool for improved error handling and debugging capabilities.

Changes Made

Functions Refactored

  • InitK8sClient() - k8sHandler.go:103
  • InitLocalAPIClient() - k8sHandler.go:126
  • InitInclusterAPIClient() - k8sHandler.go:152
  • InitLogger() - kubeArmor.go:231
  • InitSystemMonitor() - kubeArmor.go:261

Validation

Before

func InitK8sClient() bool {
    if !InitLocalAPIClient() {
        kg.Print("Failed to initialize local API client")
        return false
    }
    return true
}

After

func InitK8sClient() error {
    if err := InitLocalAPIClient(); err != nil {
        return fmt.Errorf("failed to initialize local API client: %w", err)
    }
    return nil
}

Testing

  • ✅ Code compiles successfully
  • ✅ Passes go vet analysis
  • ✅ No functional regressions
  • ✅ Enhanced error reporting verified

Fixes #2153

@Aryan-sharma11 Aryan-sharma11 self-requested a review August 18, 2025 17:54
@Aryan-sharma11
Copy link
Member

@fromsaurav Thanks for handling this.

@fromsaurav
Copy link
Contributor Author

@Aryan-sharma11 Thanks for reviewing! Could you please help with the failing check ? doesn't seem related to this pr.

@GAURAV-DEEP01
Copy link

Changes look good from my side

@fromsaurav fromsaurav force-pushed the refactor/core-functions-return-error-issue-2153 branch 2 times, most recently from ebf182d to 328b369 Compare August 20, 2025 07:27
@fromsaurav fromsaurav force-pushed the refactor/core-functions-return-error-issue-2153 branch from 328b369 to 826d190 Compare August 20, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor core functions to return error instead of bool
3 participants