mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 13:46:51 +08:00
clean: cleaned up code for getting/setting parameters.
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user