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

@@ -8,8 +8,6 @@ import (
"github.com/onepanelio/core/pkg/util/label"
"github.com/onepanelio/core/server/auth"
"github.com/onepanelio/core/server/converter"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
"strings"
"time"
)
@@ -21,24 +19,9 @@ func NewWorkflowTemplateServer() *WorkflowTemplateServer {
}
func apiWorkflowTemplate(wft *v1.WorkflowTemplate) *api.WorkflowTemplate {
manifestMap, err := v1.RemoveAllButSpec(wft.GetManifestBytes())
manifest, err := wft.FormatManifest()
if err != nil {
log.WithFields(log.Fields{
"Method": "apiWorkflowTemplate",
"Step": "RemoveAllButSpec",
"Error": err.Error(),
}).Error("Get Workflow Template failed.")
}
if wft.ArgoWorkflowTemplate != nil {
v1.AddWorkflowTemplateParametersFromAnnotations(manifestMap, wft.ArgoWorkflowTemplate.Annotations)
}
manifestBytes := []byte{}
if manifestMap != nil {
manifestBytes, err = yaml.Marshal(manifestMap)
if err != nil {
// todo log it
}
manifest = ""
}
return &api.WorkflowTemplate{
@@ -46,7 +29,7 @@ func apiWorkflowTemplate(wft *v1.WorkflowTemplate) *api.WorkflowTemplate {
CreatedAt: wft.CreatedAt.UTC().Format(time.RFC3339),
Name: wft.Name,
Version: wft.Version,
Manifest: string(manifestBytes),
Manifest: manifest,
IsLatest: wft.IsLatest,
IsArchived: wft.IsArchived,
}