Create WorkItem::AgentPlan and its table, with object store for blobs
What does this MR do and why?
Create WorkItem::AgentPlan and its table; use CarrierWave to store the actual work plan content and rendered HTML.
Follow-up MR is at Add agent plan WI widget; expose through GraphQL (!232348 - merged).
- Added the
GitLab::ExternallyStoredFieldconcern, which can be used to store field(s) in CarrierWave on save (after_commit) and retrieve them on access.- This concern isn't tied into Markdown at all, and hopefully can be helpful to other teams in need of object storage!
- Taught
CacheMarkdownField'scache_markdown_fieldwhatstorage: :externalmeans.- Causes
GitLab::MarkdownCache::ExternalStorage::Extensionto be mixed in. - That in turn brings in
GitLab::ExternallyStoredField, declaresfieldand"#{field}_html"as belonging to external storage, and interceptsCacheMarkdownFieldcallbacks to handle externally-stored fields while letting everything else fall through.
- Causes
- Followed
WorkItems::Descriptionfor the model'sset_namespacebehaviour.- Did the same for the factory's
after(:build)work_iteminit.
- Did the same for the factory's
WorkItems::AgentPlanContentUploaderuses hashed paths like most other uploaders so we don't put every single object under the same prefix.- Basic assoc/validation/Markdown rendering specs on the model itself.
- I haven't included a cleanup worker to catch orphaned blobs yet; this MR is already getting unwieldy large.
Tagging as feature flag since this functionality, while currently totally unused, will in future be used exclusively by feature flagged code.
How to set up and validate locally
There's only a model, so you could check out the code and see if the migration runs, but CI will do that anyway! You could also create some work plans associated with any work items (manually, at the console; nothing's wired up on the frontend yet), check that the Markdown is rendered, saved locally, and retrieved!
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.