Skip to content

Conversation

sthaha
Copy link
Collaborator

@sthaha sthaha commented Jun 18, 2025

This refactoring improves the API by:

  1. Making the "not found" case explicit with a boolean rather than a special error
  2. Consolidating related information into a single ContainerInfo struct

Changes:

  • modify LookupByContainerID to return (ContainerInfo, bool, error) instead of (PodInfo, string, error)
  • Replace PodInfo struct with ContainerInfo that includes container name
  • Remove ErrNoPod error, use boolean flag to indicate found/not found

For more context ... returning found/not-found follows the go idiom of returning bool if an item ins't found instead of returning error
E.g. from docs ..

os.LookupEnv -  func LookupEnv(key string) (value string, ok bool)
sync.Map.Load - func (m *Map) Load(key any) (value any, ok bool)
strings.Cut - string splitting: -   func Cut(s, sep string) (before, after string, found bool)

@github-actions github-actions bot added the refactor Code refactoring without changing functionality label Jun 18, 2025
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.40%. Comparing base (7ed9575) to head (cc8d73c).
Report is 4 commits behind head on reboot.

Additional details and impacted files
@@            Coverage Diff             @@
##           reboot    #2166      +/-   ##
==========================================
- Coverage   91.51%   91.40%   -0.12%     
==========================================
  Files          36       36              
  Lines        3490     3491       +1     
==========================================
- Hits         3194     3191       -3     
- Misses        229      232       +3     
- Partials       67       68       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sthaha sthaha requested review from vprashar2929 and vimalk78 June 18, 2025 04:20
This refactoring improves the API by:
  1. Making the "not found" case explicit with a boolean rather than a
     special error
  2. Consolidating related information into a single ContainerInfo struct

Changes:
  - modify LookupByContainerID to return (ContainerInfo, bool, error)
    instead of (PodInfo, string, error)
  - Replace PodInfo struct with ContainerInfo that includes container name
  - Remove ErrNoPod error, use boolean flag to indicate found/not found

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
@sthaha sthaha force-pushed the refactor-pod-ctnr-lookup branch from 3ab2dd2 to cc8d73c Compare June 18, 2025 05:01
@vimalk78 vimalk78 merged commit bec7b86 into sustainable-computing-io:reboot Jun 18, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code refactoring without changing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants