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

Commit

Permalink
backport of commit f8c820a
Browse files Browse the repository at this point in the history
  • Loading branch information
briancain committed Oct 28, 2022
1 parent 4c83281 commit d921f94
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 d921f94

Please sign in to comment.