From b5f0e3d07ec21add7feef02362f6c69abe0930d8 Mon Sep 17 00:00:00 2001 From: deads2k Date: Fri, 17 Mar 2017 11:15:01 -0400 Subject: [PATCH] add APIService status conditions --- .../go2idl/go-to-protobuf/protobuf/cmd.go | 1 + .../pkg/apis/apiregistration/types.go | 37 +++++++++++++++++ .../apis/apiregistration/v1alpha1/types.go | 40 +++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/cmd/libs/go2idl/go-to-protobuf/protobuf/cmd.go b/cmd/libs/go2idl/go-to-protobuf/protobuf/cmd.go index b86fee57994..89ad41e4a88 100644 --- a/cmd/libs/go2idl/go-to-protobuf/protobuf/cmd.go +++ b/cmd/libs/go2idl/go-to-protobuf/protobuf/cmd.go @@ -68,6 +68,7 @@ func New() *Generator { `+k8s.io/apimachinery/pkg/runtime`, `k8s.io/apimachinery/pkg/apis/meta/v1`, `k8s.io/apiserver/pkg/apis/example/v1`, + `k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1`, `k8s.io/kubernetes/pkg/api/v1`, `k8s.io/kubernetes/pkg/apis/policy/v1beta1`, `k8s.io/kubernetes/pkg/apis/extensions/v1beta1`, diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/types.go b/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/types.go index 40d8bcee9be..b4a99abcd65 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/types.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/types.go @@ -63,8 +63,45 @@ type APIServiceSpec struct { Priority int64 } +type ConditionStatus string + +// These are valid condition statuses. "ConditionTrue" means a resource is in the condition; +// "ConditionFalse" means a resource is not in the condition; "ConditionUnknown" means kubernetes +// can't decide if a resource is in the condition or not. In the future, we could add other +// intermediate conditions, e.g. ConditionDegraded. +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// APIConditionConditionType is a valid value for APIServiceCondition.Type +type APIServiceConditionType string + +const ( + // Available indicates that the service exists and is reachable + Available APIServiceConditionType = "Available" +) + +// APIServiceCondition describes conditions for an APIService +type APIServiceCondition struct { + // Type is the type of the condition. + Type APIServiceConditionType + // Status is the status of the condition. + // Can be True, False, Unknown. + Status ConditionStatus + // Last time the condition transitioned from one status to another. + LastTransitionTime metav1.Time + // Unique, one-word, CamelCase reason for the condition's last transition. + Reason string + // Human-readable message indicating details about last transition. + Message string +} + // APIServiceStatus contains derived information about an API server type APIServiceStatus struct { + // Current service state of apiService. + Conditions []APIServiceCondition } // +genclient=true diff --git a/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1/types.go b/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1/types.go index 8fa17bb535a..7fcdb43ee10 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1/types.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1alpha1/types.go @@ -63,8 +63,48 @@ type APIServiceSpec struct { Priority int64 `json:"priority" protobuf:"varint,6,opt,name=priority"` } +type ConditionStatus string + +// These are valid condition statuses. "ConditionTrue" means a resource is in the condition; +// "ConditionFalse" means a resource is not in the condition; "ConditionUnknown" means kubernetes +// can't decide if a resource is in the condition or not. In the future, we could add other +// intermediate conditions, e.g. ConditionDegraded. +const ( + ConditionTrue ConditionStatus = "True" + ConditionFalse ConditionStatus = "False" + ConditionUnknown ConditionStatus = "Unknown" +) + +// APIConditionConditionType is a valid value for APIServiceCondition.Type +type APIServiceConditionType string + +const ( + // Available indicates that the service exists and is reachable + Available APIServiceConditionType = "Available" +) + +type APIServiceCondition struct { + // Type is the type of the condition. + Type APIServiceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=APIServiceConditionType"` + // Status is the status of the condition. + // Can be True, False, Unknown. + Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=ConditionStatus"` + // Last time the condition transitioned from one status to another. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` + // Unique, one-word, CamelCase reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` + // Human-readable message indicating details about last transition. + // +optional + Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` +} + // APIServiceStatus contains derived information about an API server type APIServiceStatus struct { + // Current service state of apiService. + // +optional + Conditions []APIServiceCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` } // +genclient=true