Skip to content

Commit

Permalink
Add pending mapper to set resource state to pending when no conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Oct 10, 2018
1 parent 611d7cb commit 0363cc2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions types/mapper/pendingstatus.go
@@ -0,0 +1,35 @@
package mapper

import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/values"
)

type PendingStatus struct {
}

func (s PendingStatus) FromInternal(data map[string]interface{}) {
if data == nil {
return
}

if data["state"] != "active" {
return
}

conditions := convert.ToMapSlice(values.GetValueN(data, "status", "conditions"))
if len(conditions) > 0 {
return
}

data["state"] = "pending"
}

func (s PendingStatus) ToInternal(data map[string]interface{}) error {
return nil
}

func (s PendingStatus) ModifySchema(schema *types.Schema, schemas *types.Schemas) error {
return nil
}

0 comments on commit 0363cc2

Please sign in to comment.