Skip to content

GCP-XXXX: Split Script Across Multiple Files #34

Merged
tedkahwaji merged 2 commits into
mainfrom
teddy.kahwaji/gcp-xxxx/split-script
Oct 10, 2025
Merged

GCP-XXXX: Split Script Across Multiple Files #34
tedkahwaji merged 2 commits into
mainfrom
teddy.kahwaji/gcp-xxxx/split-script

Conversation

@tedkahwaji
Copy link
Copy Markdown
Collaborator

Summary

This change refactors the single-file script into a modular structure, splitting it across multiple files for better organization and maintainability. All components are now bundled into a single .pyz executable: gcp_integration_quickstart.pyz.

What's new:

  1. Modular structure
    The codebase has been split into multiple files and directories while preserving functionality. This improves readability, testing, and future extensibility.

  2. Executable .pyz archive
    The project is now packaged as a .pyz (Python executable zip), allowing it to be distributed and run as a single file:

    python gcp_integration_quickstart.pyz
    
  3. Gcloud CLI check
    The script now explicitly checks for the presence of the Google Cloud CLI and informs the user if it is not installed.

  4. Graceful shutdown on SIGTERM
    Tracebacks are now suppressed when the script receives a SIGTERM signal

@tedkahwaji tedkahwaji requested a review from a team as a code owner October 10, 2025 01:57
@tedkahwaji tedkahwaji requested review from ChrisHansenDatadog and removed request for a team October 10, 2025 01:57


if __name__ == "__main__":
signal.signal(signal.SIGINT, lambda _, __: sys.exit(0))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handles SigTerm gracefully

Copy link
Copy Markdown

@dtru-ddog dtru-ddog Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a SIGINT handler, something like:

def sigint_handler(signal, frame):
  print("Script terminating.")
  sys.exit(0)

....

if __name__ == "__main__":
    signal.signal(signal.SIGINT, lambda _, __: sigint_handler))
    main()

ensure_login()
except Exception as e:
if "gcloud: command not found" in str(e):
print("You must install the GCloud CLI and log in to run this script.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would add link to guide users to install via Google's guide

Suggested change
print("You must install the GCloud CLI and log in to run this script.")
print("You must install the GCloud CLI and log in to run this script.\nhttps://cloud.google.com/sdk/docs/install")

Copy link
Copy Markdown

@dtru-ddog dtru-ddog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, but looks great!

@tedkahwaji tedkahwaji force-pushed the teddy.kahwaji/gcp-xxxx/split-script branch from 21fe680 to 8bb9a47 Compare October 10, 2025 13:38
@tedkahwaji tedkahwaji merged commit a8f1bd6 into main Oct 10, 2025
1 check passed
@tedkahwaji tedkahwaji deleted the teddy.kahwaji/gcp-xxxx/split-script branch October 10, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants