Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pending mapper to set resource state to pending when no conditions
- Loading branch information
1 parent
611d7cb
commit 0363cc2
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |