diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 3cb299f7..46bf36e8 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -640,12 +640,21 @@ func volumeTypes(schemas *types.Schemas) *types.Schemas { AddMapperForType(&Version, v1.PersistentVolumeClaimVolumeSource{}, &m.Move{From: "claimName", To: "persistentVolumeClaimName"}, ). + AddMapperForType(&Version, v1.VolumeMount{}, + m.Required{Fields: []string{ + "mountPath", + "name", + }}, + ). MustImport(&Version, v1.PersistentVolumeClaimVolumeSource{}, struct { ClaimName string `norman:"type=reference[persistentVolumeClaim]"` }{}). MustImport(&Version, v1.SecretVolumeSource{}, struct { SecretName string `norman:"type=reference[secret]"` }{}). + MustImport(&Version, v1.VolumeMount{}, struct { + MountPath string `json:"mountPath" norman:"required"` + }{}). MustImport(&Version, v1.Volume{}, struct { }{}). MustImport(&Version, v1.PersistentVolumeSpec{}, struct { diff --git a/mapper/namespace_reference.go b/mapper/namespace_reference.go index 09abddeb..6c643f7f 100644 --- a/mapper/namespace_reference.go +++ b/mapper/namespace_reference.go @@ -29,7 +29,11 @@ func (n *NamespaceReference) FromInternal(data map[string]interface{}) { func (n *NamespaceReference) ToInternal(data map[string]interface{}) { for _, path := range n.fields { convert.Transform(data, path, func(input interface{}) interface{} { - return strings.SplitN(convert.ToString(input), ":", 2)[0] + parts := strings.SplitN(convert.ToString(input), ":", 2) + if len(parts) == 2 { + return parts[1] + } + return parts[0] }) } } diff --git a/status/status.go b/status/status.go index 11e830f5..c2b596dc 100644 --- a/status/status.go +++ b/status/status.go @@ -29,7 +29,6 @@ var transitioningMap = map[string]string{ "Active": "activating", "AddonDeploy": "deploying", "AgentDeployed": "installing", - "Available": "activating", "BackingNamespaceCreated": "configuring", "ConfigOK": "configuring", "Created": "creating", @@ -44,7 +43,6 @@ var transitioningMap = map[string]string{ "NodesCreated": "provisioning", "Pending": "pending", "PodScheduled": "scheduling", - "Progressing": "updating", "Provisioned": "provisioning", "Registered": "registering", "Removed": "removing", @@ -81,6 +79,14 @@ var errorMapping = map[string]bool{ var doneMap = map[string]string{ "Completed": "activating", "Ready": "unavailable", + "Available": "updating", +} + +// True == transitioning +// False == +// Unknown == +var progressMap = map[string]string{ + "Progressing": "progressing", } func concat(str, next string) string { @@ -117,40 +123,6 @@ func Set(data map[string]interface{}) { } } - val, ok := values.GetValue(data, "metadata", "removed") - if ok && val != "" && val != nil { - data["state"] = "removing" - data["transitioning"] = "yes" - - finalizers, ok := values.GetStringSlice(data, "metadata", "finalizers") - if !ok { - finalizers, ok = values.GetStringSlice(data, "spec", "finalizers") - } - - msg := "" - for _, cond := range conditions { - if cond.Type == "Removed" && (cond.Status == "Unknown" || cond.Status == "False") && cond.Message != "" { - msg = cond.Message - } - } - - if ok && len(finalizers) > 0 { - if len(msg) > 0 { - msg = msg + "; waiting on " + finalizers[0] - } else { - msg = "waiting on " + finalizers[0] - } - data["transitioningMessage"] = msg - if i, err := convert.ToTimestamp(val); err == nil { - if time.Unix(i/1000, 0).Add(5 * time.Minute).Before(time.Now()) { - data["transitioning"] = "error" - } - } - } - - return - } - state := "" error := false transitioning := false @@ -209,6 +181,21 @@ func Set(data map[string]interface{}) { } } + for _, c := range conditions { + if state != "" { + break + } + newState, ok := progressMap[c.Type] + if !ok { + continue + } + if c.Status == "True" { + transitioning = true + state = newState + message = concat(message, c.Message) + } + } + if state == "" { val, ok := values.GetValue(data, "spec", "active") if ok { @@ -253,4 +240,41 @@ func Set(data map[string]interface{}) { data["state"] = strings.ToLower(state) data["transitioningMessage"] = message + + val, ok := values.GetValue(data, "metadata", "removed") + if ok && val != "" && val != nil { + data["state"] = "removing" + data["transitioning"] = "yes" + + finalizers, ok := values.GetStringSlice(data, "metadata", "finalizers") + if !ok { + finalizers, ok = values.GetStringSlice(data, "spec", "finalizers") + } + + msg := message + for _, cond := range conditions { + if cond.Type == "Removed" && (cond.Status == "Unknown" || cond.Status == "False") && cond.Message != "" { + msg = cond.Message + } + } + + if ok && len(finalizers) > 0 { + parts := strings.Split(finalizers[0], "controller.cattle.io/") + f := parts[len(parts)-1] + + if len(msg) > 0 { + msg = msg + "; waiting on " + f + } else { + msg = "waiting on " + f + } + data["transitioningMessage"] = msg + if i, err := convert.ToTimestamp(val); err == nil { + if time.Unix(i/1000, 0).Add(5 * time.Minute).Before(time.Now()) { + data["transitioning"] = "error" + } + } + } + + return + } }