saucelabs / saucectl

A command line interface for the Sauce Labs platform.
Apache License 2.0
42 stars 16 forks source link

refactor: jobservice #959

Closed alexplischke closed 4 weeks ago

alexplischke commented 1 month ago

Description

One PR of many to simplify Job resource interactions.

The changes focus on saucecloud.JobService, which acts as a proxy wrapper for easier interactions with the cloud APIs by conditionally handling the differences between RDC and VDC.

Too Many Abstractions

saucecloud.JobService came with its own layer of abstractions instead of directly interacting with the implementations. The burden to instantiate saucecloud.JobService correctly was on the caller. Despite its heavy use of interfaces, only certain implementations were able to satisfy either VDC or RDC, but not both, despite the interface claiming that it can. Thus there were duplicate field members depending on the device type.

Furthermore, one of those was the job.ArtifactDownloader interface, whose implementation is downloader.ArtifactDownloader, which in turn had its layer of abstractions to interact with the Job APIs, a responsibility that saucecloud.JobService ought to have.

Solution