orbitalci / orbital

Orbital is a self-hosted CI system for solo/small consulting dev teams. Written in Rust.
GNU General Public License v3.0
29 stars 2 forks source link

Package refactor #203

Closed tjtelan closed 5 years ago

tjtelan commented 5 years ago

In preparation for #214

Fixes #107 Fixes #186 Fixes #182 - (Also the casing in Go is a matter of syntax.) Fixes #190

tjtelan commented 5 years ago

The bulk of this refactor was to achieve 3 things in the codebase:

  1. Break out the common package There were a lot of very specific tasks left in this package namespace. A lot of this resulted in splitting out code within a file into multiple different packages, then using the compiler to tell me when a function call in the common package no longer worked due to scope breakages.

  2. Reorganize the codebase in a more functional layout The new top-level layout still requires some fine tuning, but the code is laid out in a hopefully more improved, easier to scan way.

  3. deprecate guideOcelotStruct.go by replacing it with more interfaces so that we could break it into multiple packages. Since the GuideOcelot service protobuf is defined as one giant service wrapper, this gets compiled as a single interface with ~52 individual functions.

Getting started on this was actually the worst part of this entire effort. The OcelotStructAPI struct took in the now deleted guideOcelotStruct under DeprecatedHandle , and I changed everything in the codebase to reference that handle. I made sure I could swap the structs out and that compilation still worked.

Then I slowly introduced more interfaces, and embedded them into OcelotStructAPI as I removed them from guideOcelotStruct using the compiler as validation.

This required a lot of duplication of code for implementing collection of creds. I'm pretty sure that is just the cost of splitting everything out. But at least I don't need to jump around files to read an interface.


Before I forget: Many of the tests were disabled, and placed in a top-level test/ directory. At the moment, I trust functional tests a little more than our unit tests. Rather than delete them immediately, I wanted to review them first.