Repository navigation
refactor(jira): share todos' Jira client for the time service - #147
Merged
Merged
Conversation
The time service will read and write worklogs on the same Jira site, with the same settings and token as todos (decision 103), so the client and the code that reads its settings move to the root internal/jira. todos' poller of my tickets moves to its own package, tickets. Nothing changes in behaviour. Decision 180 plans the rest of time-tracking in eleven steps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief
Goal. todos' Jira client moves to the root
internal/jira, so that thetimeservice can read worklogs with the same client, settings and token (decision 103). It's the first oftime-tracking's eleven steps (plan §8.2, decision 180). Nothing changes in behaviour.Scope.
services/todos/internal/jira's client (client.go,fetch.go,ticket.go) and its tests move tointernal/jira, unchanged but for the package doc.jira.FromEnvininternal/jira/env.go: todos'jiraClient, moved verbatim. It readsBAKHYARD_JIRA_SITE,BAKHYARD_JIRA_APIandBAKHYARD_JIRA_EMAILand thejira-tokensecret, and gives no client when no setting is set. Its tests move with it.poll.go, withPoller,NewPoller,FoundandFinder) moves toservices/todos/internal/tickets, since it's todos' own;internal/jirakeeps only what talks to Jira.attentionandapipackages andmainfollow the moves. Their parameters and fields namedticketsbecomepoller, so they don't shadow the new package.time-tracking's eleven steps), §0's ideas (a holidays setting), and decision 180, which amends decision 135.Out of scope. Worklogs, the
timeservice and anything else oftime-tracking's later steps; any change to how todos polls Jira or what it answers.Acceptance criteria.
internal/jiraholds the client andFromEnv;services/todos/internal/jirais gone.services/todos/internal/ticketsholds the poller; todos builds and serves as before.TestJiraClient*nowinternal/jira'sTestFromEnv*.mise run checkpasses.What changed
internal/jira/{client,fetch,ticket}.goand{client,fail,fake,fetch,fetchfail}_test.go;services/todos/internal/tickets/{poll.go,poll_test.go,done_test.go,finder_test.go}.internal/jira/env.go(FromEnv) andenv_test.go(the four tests fromservices/todos/jira_test.go, with their helpers).services/todos/jira.gokeeps onlypoll;main.gocallsjira.FromEnv.attention.Lister's field andNewLister's andapi.Register's parametertickets→poller; a test's localtickets→open.time-trackingand its choices, which are the lead's, for the user's end review: the eleven steps; the shared client; how worklogs are read (/myself, aworklogAuthorsearch a day wider than the span, each ticket's worklogs filtered to mine);timepolling 7 days every 5 minutes with no database, on port 8088; days in the pod's time zone, weeks Monday to Sunday, 8 hours a weekday; writes with Jira's defaults, starting at 09:00;timereusing todos' Jira settings and token on the laptop, whose homelab PR the user said may merge once its check is green.QA
mise run --jobs 1 checkgreen: Go lint 0 issues, govulncheck clean, Go coverage 95.7%; the web gates, with Vitest 1082 passed; E2E 319 passed, 7 skipped.git diff -Mshows the client files as renames with only their import path changed,fetch.goandticket.gounchanged, andFromEnvidentical tojiraClientbut for its constants' names.TestJiraClient*→TestFromEnv*.FromEnv, the poller and todos'poll, run behind a dead HTTPS proxy so that a mutant can't call a real Jira. One survived at first: reading the token before checking the settings, since the rejection tests had the token. They now run without it, as pulls' do (decision 146), and all 22 are caught.Review
No blocking findings. Non-blocking:
internal/jirahas one user, todos, untiltime-service; it moves a step ahead of its second user, asshared-poller(refactor: share the Jira poller's loop as internal/poll #109) andshared-database(refactor: share the Keychain reader and the database code #70) did.FromEnvreads the token withcontext.Background(), as todos did.Merged under the user's standing OK once CI's
checkis green.