1
0
mirror of https://github.com/rancher/types.git synced 2025-09-01 05:09:10 +00:00

update pipeline types

This commit is contained in:
gitlawr
2018-07-03 16:30:15 +08:00
committed by Alena Prokharchyk
parent 977d3d15e3
commit 36f2de76ce
7 changed files with 536 additions and 341 deletions

View File

@@ -20,6 +20,10 @@ func (n *NamespaceReference) FromInternal(data map[string]interface{}) {
if ok {
for _, path := range n.fields {
convert.Transform(data, path, func(input interface{}) interface{} {
parts := strings.SplitN(convert.ToString(input), ":", 2)
if len(parts) == 2 {
return input
}
return fmt.Sprintf("%s:%v", namespaceID, input)
})
}
@@ -27,13 +31,17 @@ func (n *NamespaceReference) FromInternal(data map[string]interface{}) {
}
func (n *NamespaceReference) ToInternal(data map[string]interface{}) error {
namespaceID, ok := data["namespaceId"]
if !ok {
return nil
}
for _, path := range n.fields {
convert.Transform(data, path, func(input interface{}) interface{} {
parts := strings.SplitN(convert.ToString(input), ":", 2)
if len(parts) == 2 {
if len(parts) == 2 && (parts[0] == namespaceID) {
return parts[1]
}
return parts[0]
return input
})
}