hashicorp / waypoint

A tool to build, deploy, and release any application on any platform.
https://waypointproject.io
Other
4.76k stars 326 forks source link

tech debt: Update `pb.Job_DeployOp` to take a reference to a pushed artifact stead of the full PushedArtifact message #2884

Open briancain opened 2 years ago

briancain commented 2 years ago

Is your feature request related to a problem? Please describe.

The Job_DeployOp operation requires the full pb.PushedArtifact message to be set to properly queue and execute a Deployment job. This is not ideal when you are trying to queue a job and already have all of the references you'd need (i.e. the workspace/project/app refs and artifact sequence ID or just wanting to deploy latest). Additionally, if you specify your own pb.PushedArtifact that only includes some of the attributes on that message, the Deployment operation fails in an odd way where the Deployment some how gets Upserted without an ID (this is probably a separate bug).

Describe the solution you'd like

Ideally, this operation should take an Artifact reference like how our other operations take references to workspaces or projects, etc. So one could queue a Deployment operation with a pb.Ref_Artifact.

We could also make it a oneof Target so you could easily specify you want the latest build artifact without needing to query for it from the database.

Artifact: &pb.Ref_Artifact{
  Target: &pb.Artifact_Latest{}
}
// Or by ID
Artifact: &pb.Ref_Artifact{
  Target: &pb.Artifact_BySeq{
    Application: &pb.Ref_Application{ ... },
    Workspace: &pb.Ref_Workspace{ ... },
    Sequence: 123,
  },
}

Then in our execute deployment operation, we can take the artifact reference and look up which one we should use based on the ref supplied.

This now means the caller/requester queueing a Deployment operation no longer needs to supply the full Artifact message, and can just supply a Ref similar to other operations.

Describe alternatives you've considered

Nothing really 😅

Explain any additional use-cases

I could see this being important as we add more ways to queue jobs with Waypoint beyond the CLI and Triggers.

evanphx commented 2 years ago

Totally support this, let's add references along side where there are the full values, with the reader code supporting both refs and full values. That gives us a smooth upgrade path, then we can drop the full values in a release or two.

briancain commented 2 years ago

Just a future note to self: There are a handful of other Job operations that have the same issue that can benefit from the same solution! Like the status report operations, pushed artifact ops, etc. Keep an eye on the other operations when implementing this fix so they all get the same resolution.