mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 05:36:50 +08:00
Revert "poc: Using a custom type for labels backed by JSONB"
This reverts commit 023713da32
.
This commit is contained in:
@@ -17,11 +17,6 @@ const (
|
||||
VersionLatest = OnepanelPrefix + "version-latest"
|
||||
)
|
||||
|
||||
type Label struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
// Function that modifies an input string
|
||||
type StringModifier func(string) string
|
||||
|
||||
|
@@ -1,46 +0,0 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Labels map[string]string
|
||||
|
||||
// Unmarshal unmarshal's the json in j to v, as in json.Unmarshal.
|
||||
func (l *Labels) Unmarshal(v interface{}) error {
|
||||
if len(*l) == 0 {
|
||||
*l = make(map[string]string)
|
||||
}
|
||||
v = l
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns j as a value. This does a validating unmarshal into another
|
||||
// RawMessage. If j is invalid json, it returns an error.
|
||||
func (l Labels) Value() (driver.Value, error) {
|
||||
return json.Marshal(l)
|
||||
}
|
||||
|
||||
// Scan stores the src in *j. No validation is done.
|
||||
func (l *Labels) Scan(src interface{}) error {
|
||||
var source []byte
|
||||
switch t := src.(type) {
|
||||
case string:
|
||||
source = []byte(t)
|
||||
case []byte:
|
||||
if len(t) == 0 {
|
||||
source = []byte("{}")
|
||||
} else {
|
||||
source = t
|
||||
}
|
||||
case nil:
|
||||
*l = make(map[string]string)
|
||||
default:
|
||||
// TODO rename to JSONLabels
|
||||
return errors.New("Incompatible type for Labels")
|
||||
}
|
||||
|
||||
return json.Unmarshal(source, l)
|
||||
}
|
@@ -745,16 +745,6 @@ func (c *Client) CountWorkflowExecutions(namespace, workflowTemplateUID, workflo
|
||||
RunWith(c.DB).
|
||||
QueryRow().
|
||||
Scan(&count)
|
||||
//
|
||||
//test := types.Labels{}
|
||||
//test["test"] = "how"
|
||||
//test["language"] = "golang"
|
||||
//
|
||||
//_, err = sb.Update("workflow_executions").
|
||||
// SetMap(sq.Eq{
|
||||
// "labels": test,
|
||||
// }).Where("id = 738").RunWith(c.DB).
|
||||
// Exec()
|
||||
|
||||
return
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package v1
|
||||
import (
|
||||
"encoding/json"
|
||||
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
|
||||
"github.com/onepanelio/core/pkg/util/types"
|
||||
uid2 "github.com/onepanelio/core/pkg/util/uid"
|
||||
"github.com/onepanelio/core/util/sql"
|
||||
"time"
|
||||
@@ -26,7 +25,6 @@ type WorkflowExecution struct {
|
||||
WorkflowTemplate *WorkflowTemplate `db:"workflow_template"`
|
||||
Labels map[string]string
|
||||
ArgoWorkflow *wfv1.Workflow
|
||||
Labels2 types.Labels `db:"labels"`
|
||||
}
|
||||
|
||||
// WorkflowExecutionOptions are options you have for an executing workflow
|
||||
@@ -106,6 +104,6 @@ func (we *WorkflowExecution) GetParameterValue(name string) *string {
|
||||
// getWorkflowExecutionColumns returns all of the columns for workflowExecution modified by alias, destination.
|
||||
// see formatColumnSelect
|
||||
func getWorkflowExecutionColumns(aliasAndDestination ...string) []string {
|
||||
columns := []string{"id", "created_at", "uid", "name", "parameters", "phase", "started_at", "finished_at", "labels"}
|
||||
columns := []string{"id", "created_at", "uid", "name", "parameters", "phase", "started_at", "finished_at"}
|
||||
return sql.FormatColumnSelect(columns, aliasAndDestination...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user