Before a new version goes live, a release checklist makes sure nothing was forgotten on the server. Your function releaseChecklist(env, db, baseURL) gets the server's environment variables as a map[string]string, its database, and the base URL of its running app. It collects what is wrong in a slice, problems, and the code at the end prints it.
Each check reads a value, compares it, and appends a sentence when something is wrong. Here is a check for another setting:
env := map[string]string{"SHOP_NAME": "Mug Shop", "ADMIN_EMAIL": ""}
problems := []string{}
if env["ADMIN_EMAIL"] == "" {
problems = append(problems, "set ADMIN_EMAIL")
}
fmt.Println(problems) // [set ADMIN_EMAIL]
Your checklist asks four things, in this order. Debug mode is off: DEBUG is "0", or not set at all (this check is already written). Every name in secrets is set and not empty. Every name in migrations has its row in the table migrations: Scan returns sql.ErrNoRows when it doesn't. And GET /health answers 200.
Six test servers go through the checklist. The finished code prints:
Server 1: all set Ready to release Server 2: debug left on To do: turn debug off (DEBUG is 1) Server 3: secrets forgotten To do: set the secret SECRET_KEY To do: set the secret WEBHOOK_SECRET Server 4: new code, old database To do: run the migration 003_add_reviews Server 5: the app is not healthy To do: fix /health, it answers 503 Server 6: nothing done yet To do: turn debug off (DEBUG is true) To do: set the secret SECRET_KEY To do: set the secret PAYMENTS_API_KEY To do: set the secret WEBHOOK_SECRET To do: run the migration 001_create_products To do: run the migration 002_create_orders To do: run the migration 003_add_reviews To do: fix /health, it answers 503
Your task: inside releaseChecklist, below the debug check, add the other three checks: the secrets, then the migrations, then /health. Each one appends the sentence that follows To do: in the output above.
Assignment
Follow the Coding Tutorial to add the rest of the release checklist: secrets set, migrations run and /health green.
Hint
A missing key in a map[string]string gives "", the same as an empty value. Look up each migration with db.QueryRow, a ? placeholder and name as its argument, then .Scan(&found). Turn the status code into text with strconv.Itoa before adding it to a sentence.
Free plan: 30 tutor messages. PRO is unlimited.
