Skip to content

Instantly share code, notes, and snippets.

@greyhoundforty
Created April 18, 2023 19:21
Show Gist options
  • Save greyhoundforty/972e2f4cdd789dd1dec1456bcdfd86bd to your computer and use it in GitHub Desktop.
Save greyhoundforty/972e2f4cdd789dd1dec1456bcdfd86bd to your computer and use it in GitHub Desktop.
chatGPT prompt

The current system is a containerized app. Tech stack: docker, python, ibm cloud schematics python SDK, ibm cloud core python SDK

High level: Use python to interact with the IBM Cloud schematics API. The code should allow for running destroy, plan, apply, and status check functions

Schematics workspaces can have the following status codes:

  1. INACTIVE = no resources are provisioned, need to run a workspace plan
  2. ACTIVE = workspace plan was applied and resources were deployed
  3. INPROGRESS = workspace is running a destroy, plan or, apply
  4. SCANNING = only applicable during initial workspace creation or when pulling latest version
  5. FAILED = workspace destroy, plan, or apply failed
  6. CANCELLED = workspace destroy, plan, or apply was cancelled by user

Application Flow:

  1. Check workspace status
  2. If workspace is INACTIVE call the PLAN FUNCTION. Once PLAN FUNCTION completes, move on to APPLY FUNCTION
  3. if workspace is ACTIVE, call the workspace destroy function. Once that completes run the PLAN FUNCTION. When that completes move on to APPLY FUNCTION
  4. When APPLY FUNCTION and status = ACTIVE send a message to a discord server

PLAN FUNCTION: Plan function should include check for workspace status, when plan status = INACTIVE move on to apply function. Status returns outside of INACTIVE / SCANNING / INPROGRESS should be considered an error.

APPLY FUNCTION: Apply function should include check for workspace status, when status = ACTIVE the job is considered complete. While status = INPROGRESS, use sleep and check status in 10 minutes. Status returns outside of ACTIVE / INPROGRESS should be considered an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment