diff --git a/apis/management.cattle.io/v3/authz_types.go b/apis/management.cattle.io/v3/authz_types.go index f89a3d86..bd04cbef 100644 --- a/apis/management.cattle.io/v3/authz_types.go +++ b/apis/management.cattle.io/v3/authz_types.go @@ -1,17 +1,43 @@ package v3 import ( + "github.com/rancher/norman/condition" "github.com/rancher/norman/types" + "k8s.io/api/core/v1" extv1 "k8s.io/api/extensions/v1beta1" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var ( + NamespaceBackedResource condition.Cond = "BackingNamespaceCreated" +) + type Project struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ProjectSpec `json:"spec,omitempty"` + Spec ProjectSpec `json:"spec,omitempty"` + Status ProjectStatus `json:"status"` +} + +type ProjectStatus struct { + Conditions []ProjectCondition `json:"conditions"` +} + +type ProjectCondition struct { + // Type of project condition. + Type string `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status v1.ConditionStatus `json:"status"` + // The last time this condition was updated. + LastUpdateTime string `json:"lastUpdateTime,omitempty"` + // Last time the condition transitioned from one status to another. + LastTransitionTime string `json:"lastTransitionTime,omitempty"` + // The reason for the condition's last transition. + Reason string `json:"reason,omitempty"` + // Human-readable, longer explanation of the last transition + Message string `json:"message,omitempty"` } type ProjectSpec struct { diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index c4baf063..568e849d 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -87,7 +87,9 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas { func authzTypes(schemas *types.Schemas) *types.Schemas { return schemas. - AddMapperForType(&Version, v3.Project{}, m.DisplayName{}). + MustImport(&Version, v3.ProjectStatus{}). + AddMapperForType(&Version, v3.Project{}, m.DisplayName{}, + &m.Embed{Field: "status"}). AddMapperForType(&Version, v3.GlobalRole{}, m.DisplayName{}). AddMapperForType(&Version, v3.RoleTemplate{}, m.DisplayName{}). AddMapperForType(&Version, v3.ProjectRoleTemplateBinding{}, diff --git a/status/status.go b/status/status.go index f62960cc..e94dc777 100644 --- a/status/status.go +++ b/status/status.go @@ -43,6 +43,7 @@ var conditionMappings = []conditionMapping{ {Name: "Unschedulable", Error: true, FalseIsGood: true}, {Name: "ReplicaFailure", Error: true, FalseIsGood: true}, {Name: "Ready", Transition: false, State: "activating"}, + {Name: "BackingNamespaceCreated", Transition: true, State: "activating"}, } func Set(data map[string]interface{}) { @@ -120,6 +121,11 @@ func Set(data map[string]interface{}) { if !good && conditionMapping.Transition { transitioning = true + if len(message) > 0 { + message = strings.Join([]string{message, condition.Message}, ",") + } else { + message = condition.Message + } } if !good && state == "" && conditionMapping.State != "" {