mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-23 22:46:53 +00:00
Fix: the error of the run APi
Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
@@ -29,10 +29,14 @@ type Project struct {
|
||||
Alias string `json:"alias"`
|
||||
Owner string `json:"owner"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Namespace string `json:"namespace"`
|
||||
}
|
||||
|
||||
// GetNamespace get the namespace name of this project.
|
||||
func (p *Project) GetNamespace() string {
|
||||
if p.Namespace != "" {
|
||||
return p.Namespace
|
||||
}
|
||||
return fmt.Sprintf("project-%s", p.Name)
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,12 @@ type PipelineService interface {
|
||||
}
|
||||
|
||||
type pipelineServiceImpl struct {
|
||||
ProjectService ProjectService `inject:""`
|
||||
ContextService ContextService `inject:""`
|
||||
KubeClient client.Client `inject:"kubeClient"`
|
||||
KubeConfig *rest.Config `inject:"kubeConfig"`
|
||||
Apply apply.Applicator `inject:"apply"`
|
||||
ProjectService ProjectService `inject:""`
|
||||
ContextService ContextService `inject:""`
|
||||
KubeClient client.Client `inject:"kubeClient"`
|
||||
KubeConfig *rest.Config `inject:"kubeConfig"`
|
||||
Apply apply.Applicator `inject:"apply"`
|
||||
PipelineRunService PipelineRunService `inject:""`
|
||||
}
|
||||
|
||||
// PipelineRunService is the interface for pipelineRun service
|
||||
@@ -458,7 +459,11 @@ func (p pipelineServiceImpl) RunPipeline(ctx context.Context, pipeline apis.Pipe
|
||||
if err := p.KubeClient.Create(ctx, &run); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return workflowRun2PipelineRun(run, project)
|
||||
return p.PipelineRunService.GetPipelineRun(ctx, apis.PipelineRunMeta{
|
||||
PipelineName: pipeline.Name,
|
||||
Project: apis.NameAlias{Name: project.Name},
|
||||
PipelineRunName: name,
|
||||
})
|
||||
}
|
||||
|
||||
// GetPipelineRun will get a pipeline run
|
||||
@@ -693,9 +698,7 @@ func workflow2PipelineBase(wf v1alpha1.Workflow, p ProjectService) (*apis.Pipeli
|
||||
}
|
||||
|
||||
func workflowRun2PipelineRun(run v1alpha1.WorkflowRun, project *model.Project) (*apis.PipelineRun, error) {
|
||||
|
||||
mergeSteps(&run)
|
||||
|
||||
return &apis.PipelineRun{
|
||||
PipelineRunBase: apis.PipelineRunBase{
|
||||
PipelineRunMeta: apis.PipelineRunMeta{
|
||||
@@ -715,6 +718,9 @@ func workflowRun2PipelineRun(run v1alpha1.WorkflowRun, project *model.Project) (
|
||||
}
|
||||
|
||||
func mergeSteps(run *v1alpha1.WorkflowRun) {
|
||||
if run.Spec.WorkflowSpec == nil {
|
||||
return
|
||||
}
|
||||
if run.Status.Steps == nil {
|
||||
run.Status.Steps = make([]v1alpha1.WorkflowStepStatus, 0)
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ func (n *projectAPIInterface) deletePipelineRun(req *restful.Request, res *restf
|
||||
}
|
||||
|
||||
func (n *projectAPIInterface) listContextValues(req *restful.Request, res *restful.Response) {
|
||||
pipeline := req.Request.Context().Value(&apis.CtxKeyPipeline).(*apis.PipelineBase)
|
||||
pipeline := req.Request.Context().Value(&apis.CtxKeyPipeline).(apis.PipelineBase)
|
||||
contextValues, err := n.ContextService.ListContexts(req.Request.Context(), pipeline.Project.Name, pipeline.Name)
|
||||
if err != nil {
|
||||
log.Logger.Errorf("list context values failure: %s", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user