sslobodr | d046be8 | 2019-01-16 10:02:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // package v1beta1 is alpha objects from meta that will be introduced. |
| 18 | package v1beta1 |
| 19 | |
| 20 | import ( |
| 21 | "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | "k8s.io/apimachinery/pkg/runtime" |
| 23 | ) |
| 24 | |
| 25 | // TODO: Table does not generate to protobuf because of the interface{} - fix protobuf |
| 26 | // generation to support a meta type that can accept any valid JSON. |
| 27 | |
| 28 | // Table is a tabular representation of a set of API resources. The server transforms the |
| 29 | // object into a set of preferred columns for quickly reviewing the objects. |
| 30 | // +protobuf=false |
| 31 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 32 | type Table struct { |
| 33 | v1.TypeMeta `json:",inline"` |
| 34 | // Standard list metadata. |
| 35 | // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds |
| 36 | // +optional |
| 37 | v1.ListMeta `json:"metadata,omitempty"` |
| 38 | |
| 39 | // columnDefinitions describes each column in the returned items array. The number of cells per row |
| 40 | // will always match the number of column definitions. |
| 41 | ColumnDefinitions []TableColumnDefinition `json:"columnDefinitions"` |
| 42 | // rows is the list of items in the table. |
| 43 | Rows []TableRow `json:"rows"` |
| 44 | } |
| 45 | |
| 46 | // TableColumnDefinition contains information about a column returned in the Table. |
| 47 | // +protobuf=false |
| 48 | type TableColumnDefinition struct { |
| 49 | // name is a human readable name for the column. |
| 50 | Name string `json:"name"` |
| 51 | // type is an OpenAPI type definition for this column. |
| 52 | // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. |
| 53 | Type string `json:"type"` |
| 54 | // format is an optional OpenAPI type definition for this column. The 'name' format is applied |
| 55 | // to the primary identifier column to assist in clients identifying column is the resource name. |
| 56 | // See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more. |
| 57 | Format string `json:"format"` |
| 58 | // description is a human readable description of this column. |
| 59 | Description string `json:"description"` |
| 60 | // priority is an integer defining the relative importance of this column compared to others. Lower |
| 61 | // numbers are considered higher priority. Columns that may be omitted in limited space scenarios |
| 62 | // should be given a higher priority. |
| 63 | Priority int32 `json:"priority"` |
| 64 | } |
| 65 | |
| 66 | // TableRow is an individual row in a table. |
| 67 | // +protobuf=false |
| 68 | type TableRow struct { |
| 69 | // cells will be as wide as headers and may contain strings, numbers (float64 or int64), booleans, simple |
| 70 | // maps, or lists, or null. See the type field of the column definition for a more detailed description. |
| 71 | Cells []interface{} `json:"cells"` |
| 72 | // conditions describe additional status of a row that are relevant for a human user. |
| 73 | // +optional |
| 74 | Conditions []TableRowCondition `json:"conditions,omitempty"` |
| 75 | // This field contains the requested additional information about each object based on the includeObject |
| 76 | // policy when requesting the Table. If "None", this field is empty, if "Object" this will be the |
| 77 | // default serialization of the object for the current API version, and if "Metadata" (the default) will |
| 78 | // contain the object metadata. Check the returned kind and apiVersion of the object before parsing. |
| 79 | // +optional |
| 80 | Object runtime.RawExtension `json:"object,omitempty"` |
| 81 | } |
| 82 | |
| 83 | // TableRowCondition allows a row to be marked with additional information. |
| 84 | // +protobuf=false |
| 85 | type TableRowCondition struct { |
| 86 | // Type of row condition. |
| 87 | Type RowConditionType `json:"type"` |
| 88 | // Status of the condition, one of True, False, Unknown. |
| 89 | Status ConditionStatus `json:"status"` |
| 90 | // (brief) machine readable reason for the condition's last transition. |
| 91 | // +optional |
| 92 | Reason string `json:"reason,omitempty"` |
| 93 | // Human readable message indicating details about last transition. |
| 94 | // +optional |
| 95 | Message string `json:"message,omitempty"` |
| 96 | } |
| 97 | |
| 98 | type RowConditionType string |
| 99 | |
| 100 | // These are valid conditions of a row. This list is not exhaustive and new conditions may be |
| 101 | // included by other resources. |
| 102 | const ( |
| 103 | // RowCompleted means the underlying resource has reached completion and may be given less |
| 104 | // visual priority than other resources. |
| 105 | RowCompleted RowConditionType = "Completed" |
| 106 | ) |
| 107 | |
| 108 | type ConditionStatus string |
| 109 | |
| 110 | // These are valid condition statuses. "ConditionTrue" means a resource is in the condition. |
| 111 | // "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes |
| 112 | // can't decide if a resource is in the condition or not. In the future, we could add other |
| 113 | // intermediate conditions, e.g. ConditionDegraded. |
| 114 | const ( |
| 115 | ConditionTrue ConditionStatus = "True" |
| 116 | ConditionFalse ConditionStatus = "False" |
| 117 | ConditionUnknown ConditionStatus = "Unknown" |
| 118 | ) |
| 119 | |
| 120 | // IncludeObjectPolicy controls which portion of the object is returned with a Table. |
| 121 | type IncludeObjectPolicy string |
| 122 | |
| 123 | const ( |
| 124 | // IncludeNone returns no object. |
| 125 | IncludeNone IncludeObjectPolicy = "None" |
| 126 | // IncludeMetadata serializes the object containing only its metadata field. |
| 127 | IncludeMetadata IncludeObjectPolicy = "Metadata" |
| 128 | // IncludeObject contains the full object. |
| 129 | IncludeObject IncludeObjectPolicy = "Object" |
| 130 | ) |
| 131 | |
| 132 | // TableOptions are used when a Table is requested by the caller. |
| 133 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 134 | type TableOptions struct { |
| 135 | v1.TypeMeta `json:",inline"` |
William Kurkian | daa6bb2 | 2019-03-07 12:26:28 -0500 | [diff] [blame] | 136 | |
| 137 | // NoHeaders is only exposed for internal callers. |
| 138 | NoHeaders bool `json:"-"` |
| 139 | |
sslobodr | d046be8 | 2019-01-16 10:02:22 -0500 | [diff] [blame] | 140 | // includeObject decides whether to include each object along with its columnar information. |
| 141 | // Specifying "None" will return no object, specifying "Object" will return the full object contents, and |
| 142 | // specifying "Metadata" (the default) will return the object's metadata in the PartialObjectMetadata kind |
| 143 | // in version v1beta1 of the meta.k8s.io API group. |
| 144 | IncludeObject IncludeObjectPolicy `json:"includeObject,omitempty" protobuf:"bytes,1,opt,name=includeObject,casttype=IncludeObjectPolicy"` |
| 145 | } |
| 146 | |
| 147 | // PartialObjectMetadata is a generic representation of any object with ObjectMeta. It allows clients |
| 148 | // to get access to a particular ObjectMeta schema without knowing the details of the version. |
| 149 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 150 | type PartialObjectMetadata struct { |
| 151 | v1.TypeMeta `json:",inline"` |
| 152 | // Standard object's metadata. |
| 153 | // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata |
| 154 | // +optional |
| 155 | v1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 156 | } |
| 157 | |
| 158 | // PartialObjectMetadataList contains a list of objects containing only their metadata |
| 159 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 160 | type PartialObjectMetadataList struct { |
| 161 | v1.TypeMeta `json:",inline"` |
| 162 | |
| 163 | // items contains each of the included items. |
| 164 | Items []*PartialObjectMetadata `json:"items" protobuf:"bytes,1,rep,name=items"` |
| 165 | } |