clean: cleaned up code for getting/setting parameters.

This commit is contained in:
Andrey Melnikov
2020-04-15 16:22:45 -07:00
parent 527ea03b41
commit 259c9f8a57
4 changed files with 182 additions and 126 deletions

View File

@@ -4,9 +4,7 @@ import (
"context"
"github.com/onepanelio/core/pkg/util"
"github.com/onepanelio/core/server/converter"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"gopkg.in/yaml.v2"
"math"
"sort"
"strings"
@@ -46,35 +44,7 @@ func apiWorkflowExecution(wf *v1.WorkflowExecution) (workflow *api.WorkflowExecu
}
if wf.WorkflowTemplate != nil {
wftManifestMap, err := v1.RemoveAllButSpec(wf.WorkflowTemplate.GetManifestBytes())
if err != nil {
log.WithFields(log.Fields{
"Method": "apiWorkflowExecution",
"Step": "RemoveAllButSpec",
"Error": err.Error(),
}).Error("Invalid status.")
}
if wf.WorkflowTemplate.ArgoWorkflowTemplate != nil {
v1.AddWorkflowTemplateParametersFromAnnotations(wftManifestMap, wf.WorkflowTemplate.ArgoWorkflowTemplate.Annotations)
}
manifestBytes := []byte{}
if wftManifestMap != nil {
manifestBytes, err = yaml.Marshal(wftManifestMap)
if err != nil {
// todo log
}
}
workflow.WorkflowTemplate = &api.WorkflowTemplate{
Uid: wf.WorkflowTemplate.UID,
CreatedAt: wf.WorkflowTemplate.CreatedAt.UTC().Format(time.RFC3339),
Name: wf.WorkflowTemplate.Name,
Version: wf.WorkflowTemplate.Version,
Manifest: string(manifestBytes),
IsLatest: wf.WorkflowTemplate.IsLatest,
IsArchived: wf.WorkflowTemplate.IsArchived,
}
workflow.WorkflowTemplate = apiWorkflowTemplate(wf.WorkflowTemplate)
}
return