1
0
mirror of https://github.com/rancher/types.git synced 2025-05-08 15:16:18 +00:00

Add status to project

This commit is contained in:
Craig Jellick 2017-12-27 09:48:28 -07:00 committed by Darren Shepherd
parent 3a6275d2a9
commit 46a1ea01a8
3 changed files with 36 additions and 2 deletions
apis/management.cattle.io/v3
status

View File

@ -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 {

View File

@ -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{},

View File

@ -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 != "" {