Skip to content

Commit

Permalink
Merge pull request #375 from kube-tarian/tekton-project
Browse files Browse the repository at this point in the history
update the tekton project details
  • Loading branch information
vramk23 authored Jan 17, 2024
2 parents a806a2c + 6292c9e commit 6e6f954
Show file tree
Hide file tree
Showing 14 changed files with 10,832 additions and 20,271 deletions.
8 changes: 4 additions & 4 deletions capten/agent/internal/api/plugin_tekton_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ func (a *Agent) GetTektonProjects(ctx context.Context, request *captenpluginspb.
}, err
}

tekTonProjects := []*captenpluginspb.TektonProject{}
tekTonProject := &captenpluginspb.TektonProject{}
for _, project := range projects {
tekTonProject := &captenpluginspb.TektonProject{
Id: project.Id,
GitProjectUrl: project.GitProjectUrl,
Status: project.Status,
}
tekTonProjects = append(tekTonProjects, tekTonProject)
tekTonProject = tekTonProject
}

a.log.Infof("Fetched %d Tekton Git projects", len(tekTonProjects))
a.log.Infof("Fetched Tekton Git projects")
return &captenpluginspb.GetTektonProjectsResponse{
Status: captenpluginspb.StatusCode_OK,
StatusMessage: "successfully fetched the tekton projects",
Projects: tekTonProjects,
Project: tekTonProject,
}, nil
}

Expand Down
34 changes: 0 additions & 34 deletions capten/agent/internal/api/plugin_tekton_pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,40 +165,6 @@ func (a *Agent) GetTektonPipelines(ctx context.Context, request *captenpluginspb

}

func (a *Agent) SyncTektonPipelines(ctx context.Context, request *captenpluginspb.SyncTektonPipelinesRequest) (
*captenpluginspb.SyncTektonPipelinesResponse, error) {
a.log.Infof("Get tekton pipeline request recieved")
res, err := a.as.GetTektonPipeliness()
if err != nil {
a.log.Errorf("failed to get TektonPipeline from db, %v", err)
return &captenpluginspb.SyncTektonPipelinesResponse{
Status: captenpluginspb.StatusCode_INTERNAL_ERROR,
StatusMessage: "failed to fetch TektonPipelines",
}, nil
}

pipelines := make([]*captenpluginspb.TektonPipelines, len(res))
for index, r := range res {
pipelines[index] = &captenpluginspb.TektonPipelines{
Id: r.Id, PipelineName: r.PipelineName,
WebhookURL: r.WebhookURL, Status: r.Status, GitOrgId: r.GitProjectId,
ContainerRegistryIds: r.ContainerRegId, LastUpdateTime: r.LastUpdateTime,
}
if err := a.configureTektonPipelinesGitRepo(r, model.TektonPipelineSync); err != nil {
a.log.Errorf("failed to trigger the tekton pipeline sync for %s, %v", r.PipelineName, err)
pipelines[index].Status = "failed to trigger the sync"
continue
}
}

a.log.Infof("Successfully triggered the sync")
return &captenpluginspb.SyncTektonPipelinesResponse{
Pipelines: pipelines,
Status: captenpluginspb.StatusCode_OK,
StatusMessage: "Successfully triggered the sync",
}, nil
}

func (a *Agent) configureTektonPipelinesGitRepo(req *model.TektonPipeline, action string) error {
a.log.Infof("configuring tekton pipeline for the git repo %s", req.GitProjectUrl)
tektonProject := model.TektonPipeline{}
Expand Down
Loading

0 comments on commit 6e6f954

Please sign in to comment.