Skip to content

Refactor/oshell shellcheck fixes#2

Merged
rozdolsky33 merged 22 commits intomainfrom
refactor/oshell-shellcheck-fixes
Jul 9, 2025
Merged

Refactor/oshell shellcheck fixes#2
rozdolsky33 merged 22 commits intomainfrom
refactor/oshell-shellcheck-fixes

Conversation

@rozdolsky33
Copy link
Contributor

@rozdolsky33 rozdolsky33 commented Jul 7, 2025

Summary

This PR significantly refactors and enhances oshell’s OCI session authentication and management scripts, with a major focus on reliability, usability, and cross-platform compatibility. The improvements affect oci_auth_refresher.sh, oshell.sh, documentation, and usage examples.


Key Changes

1. Robust Session Lifecycle Management

  • Consistent Logging: All profiles now log to $HOME/.oci/sessions/<profile>/oci-auth-refresher_<profile>.log instead of ~/Library/Logs.
  • Refresher Process Handling: The background refresher (oci_auth_refresher.sh) is now reliably launched, tracked, and terminated per profile.
  • Graceful Session Termination: ociexit [profile] terminates both the refresher process and the OCI session for the specified or current profile, with clear user feedback.
  • Profile Switching: Improved support for managing multiple profiles and switching/refresher handling.

2. Improved Cross-Platform Compatibility

  • Date Parsing: Added logic in oci_auth_refresher.sh to support both GNU (date -d) and BSD/macOS (date -j -f) date utilities for timestamp handling.
  • Shell Compatibility: Added shellcheck directives and improved sourcing/quoting for better portability.

3. Enhanced User Experience

  • Better Logging: More detailed logs for session validation, refresh attempts, errors, and session expiration.
  • Informative Output: Improved CLI messages for all authentication and logout operations.
  • oshell.sh Functions: Refactored functions for clarity, parameter handling, and edge-case robustness.
  • Dynamic Path Handling: Paths for logs and session files are dynamically set per profile.

4. Documentation Improvements

  • README.md: Expanded documentation on all lifecycle commands, session maintenance, logs, troubleshooting, and multi-profile support.
  • Usage Examples: Updated example .zshrc and shell integration notes for clarity and correctness.

5. CI Improvements

  • Workflow Renaming: Renamed the CI job for clarity.
  • Linting: Ensured shell scripts are checked with shellcheck.
  • Removed Redundant Steps: Dropped unnecessary test execution steps for .sh/.zsh files in CI.

How to Test

  1. Authenticate with ociauth <profile> and confirm background refresher launches and logs are created.
  2. Switch profiles with ociset <profile> and verify session management.
  3. Logout with ociexit and ociexit <profile>; confirm both refresher and session are terminated.
  4. Check logs in $HOME/.oci/sessions/<profile>/oci-auth-refresher_<profile>.log.
  5. Review CLI output and ensure all commands provide clear, actionable feedback.

Related Issues

  • Improves reliability and multi-profile support (# if any relevant issues exist)
  • Addresses cross-platform compatibility
  • Enhances documentation for onboarding and troubleshooting

Checklist

  • Refresher process properly managed for each profile
  • Session status and logs are consistent and accessible
  • Documentation updated and expanded
  • Shell scripts pass linting and CI

@rozdolsky33 rozdolsky33 requested a review from dnlloyd July 7, 2025 13:58
@dnlloyd
Copy link
Contributor

dnlloyd commented Jul 7, 2025

The latest changes are producing a file at $HOME/.oci/sessions/oci-auth-refresher_.log which contain the checks for an existing refresh process:

Mon Jul  7 14:12:36 CDT 2025: Checking for existing refresher process for OTEST-3
Mon Jul  7 14:12:36 CDT 2025: Starting new refresher process for OTEST-3
Mon Jul  7 14:13:51 CDT 2025: Killing refresher process for profile OTEST-3
Mon Jul  7 14:20:09 CDT 2025: Checking for existing refresher process for OTEST-4
Mon Jul  7 14:20:09 CDT 2025: Starting new refresher process for OTEST-4
image

@rozdolsky33
Copy link
Contributor Author

Here is my output:
Screenshot 2025-07-07 at 4 33 00 PM
Screenshot 2025-07-07 at 4 33 32 PM

rozdolsky33 and others added 5 commits July 8, 2025 13:11
…h handling, centralize dynamic path setup, enhance logging and validation
…ry oshiv references, and ensure alignment with updated scripts. Introduce `oci_tenancy_map` functionality and improvements in color-coded tenancy management display. Streamline script functions, replacing redundant `oshiv` calls with direct oshell equivalents.
…able formatting, improve variable handling consistency
… TSV output and refine colored environment variable instructions for clarity.
…date tenancy map path logic, clean up oci_tenancy_map messaging, and remove redundant session status write.
…fresher.sh` and `oshell.sh`. Streamline session listing by refining status file retrieval and simplifying profile identification logic.
@rozdolsky33 rozdolsky33 requested a review from dnlloyd July 9, 2025 18:38
@rozdolsky33 rozdolsky33 requested a review from dnlloyd July 9, 2025 20:02
@rozdolsky33 rozdolsky33 requested a review from dnlloyd July 9, 2025 20:24
@rozdolsky33 rozdolsky33 requested a review from dnlloyd July 9, 2025 20:40
@rozdolsky33 rozdolsky33 merged commit 9f82582 into main Jul 9, 2025
1 check passed
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.

2 participants