Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
cli/init: Update how init upserts pipelines
Browse files Browse the repository at this point in the history
Prior to this commit, the init CLI would upsert the full protobuf
structure of a pipeline. This was fine before input variables, but now
given how Waypoint internally lazy-evaluates input variables later, this
approach no logner works.

This commit updates the init cli to instead behave more like how the
init CLI handles syncing Applications: The smallest structure possible
i.e. a name, owner, and a root step. This data gets re-upserted on
configsync and before running a pipeline, so this init simply upserts a
basic structure on initialiation.
  • Loading branch information
briancain committed Oct 28, 2022
1 parent 771c681 commit f8c820a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions internal/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,29 @@ func (c *InitCommand) validateProject() bool {
}

sp := sg.Add("Registering all pipelines for project %q", ref.Project)
protoPipes, err := c.cfg.PipelineProtos()
if err != nil {
c.stepError(s, initStepPipeline, err)
return false
}
pipeNames := c.cfg.Pipelines()

// We do a shallow sync of pipelines on the init phase in the same way we
// shallow sync Applications. Prior to running a pipeline - we do a full
// HCL eval and protobuf sync that will upsert over this data.
for _, pn := range pipeNames {
sp.Update("Registering Pipeline %q with the server...", pn)

for _, pipeline := range protoPipes {
sp.Update("Registering Pipeline %q with the server...", pipeline.Name)
baseStep := map[string]*pb.Pipeline_Step{"root": &pb.Pipeline_Step{
Name: "root",
Kind: &pb.Pipeline_Step_Pipeline_{},
}}

_, err := client.UpsertPipeline(c.Ctx, &pb.UpsertPipelineRequest{
Pipeline: pipeline,
Pipeline: &pb.Pipeline{
Name: pn,
Owner: &pb.Pipeline_Project{
Project: &pb.Ref_Project{
Project: ref.Project,
},
},
Steps: baseStep,
},
})
if err != nil {
c.stepError(sp, initStepPipeline, err)
Expand Down

0 comments on commit f8c820a

Please sign in to comment.