Documentation ¶
Overview ¶
Package v1 contains API types that are common to all versions.
The package contains two categories of types:
- external (serialized) types that lack their own version (e.g TypeMeta)
- internal (never-serialized) types that are needed by several different api groups, and so live here, to avoid duplication and/or import loops (e.g. LabelSelector).
In the future, we will probably move these categories of objects into separate packages.
Index ¶
- type AuthorizeOptions
- type CreateOptions
- type DeleteOptions
- type ExportOptions
- type Extend
- type GetOptions
- type ListInterface
- type ListMeta
- type ListOptions
- type Object
- type ObjectMeta
- func (obj *ObjectMeta) AfterFind(tx *gorm.DB) error
- func (obj *ObjectMeta) BeforeCreate(tx *gorm.DB) error
- func (obj *ObjectMeta) BeforeUpdate(tx *gorm.DB) error
- func (meta *ObjectMeta) GetCreatedAt() time.Time
- func (meta *ObjectMeta) GetID() uint64
- func (meta *ObjectMeta) GetName() string
- func (obj *ObjectMeta) GetObjectMeta() Object
- func (meta *ObjectMeta) GetUpdatedAt() time.Time
- func (meta *ObjectMeta) SetCreatedAt(createdAt time.Time)
- func (meta *ObjectMeta) SetID(id uint64)
- func (meta *ObjectMeta) SetName(name string)
- func (meta *ObjectMeta) SetUpdatedAt(updatedAt time.Time)
- type ObjectMetaAccessor
- type PatchOptions
- type TableOptions
- type Type
- type TypeMeta
- func (meta *TypeMeta) GetAPIVersion() string
- func (meta *TypeMeta) GetKind() string
- func (obj *TypeMeta) GetObjectKind() scheme.ObjectKind
- func (obj *TypeMeta) GroupVersionKind() scheme.GroupVersionKind
- func (meta *TypeMeta) SetAPIVersion(version string)
- func (obj *TypeMeta) SetGroupVersionKind(gvk scheme.GroupVersionKind)
- func (meta *TypeMeta) SetKind(kind string)
- type UpdateOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizeOptions ¶
type AuthorizeOptions struct {
TypeMeta `json:",inline"`
}
AuthorizeOptions may be provided when authorize an API object.
type CreateOptions ¶
type CreateOptions struct { TypeMeta `json:",inline"` // When present, indicates that modifications should not be // persisted. An invalid or unrecognized dryRun directive will // result in an error response and no further processing of the // request. Valid values are: // - All: all dry run stages will be processed // +optional DryRun []string `json:"dryRun,omitempty"` }
CreateOptions may be provided when creating an API object.
type DeleteOptions ¶
type DeleteOptions struct { TypeMeta `json:",inline"` // +optional 是否为软删除 Unscoped bool `json:"unscoped"` }
DeleteOptions may be provided when deleting an API object.
type ExportOptions ¶
type ExportOptions struct { TypeMeta `json:",inline"` // Should this value be exported. Export strips fields that a user can not specify. // Deprecated. Planned for removal in 1.18. Export bool `json:"export"` // Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'. // Deprecated. Planned for removal in 1.18. Exact bool `json:"exact"` }
ExportOptions is the query options to the standard REST get call. Deprecated. Planned for removal in 1.18.
type Extend ¶
type Extend map[string]interface{}
Extend defines a new type used to store extended fields.
type GetOptions ¶
type GetOptions struct {
TypeMeta `json:",inline"`
}
GetOptions is the standard query options to the standard REST get call.
type ListInterface ¶
ListInterface lets you work with list metadata from any of the versioned or internal API objects. Attempting to set or retrieve a field on an object that does not support that field will be a no-op and return a default value.
type ListMeta ¶
type ListMeta struct {
TotalCount int64 `json:"totalCount,omitempty"`
}
ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.
func (*ListMeta) GetListMeta ¶
func (obj *ListMeta) GetListMeta() ListInterface
func (*ListMeta) GetTotalCount ¶
func (*ListMeta) SetTotalCount ¶
type ListOptions ¶
type ListOptions struct { TypeMeta `json:",inline"` // LabelSelector is used to find matching REST resources. LabelSelector string `json:"labelSelector,omitempty" form:"labelSelector"` // //FieldSelector按返回对象的字段限制其列表。默认为一切。 // FieldSelector restricts the list of returned objects by their fields. Defaults to everything. FieldSelector string `json:"fieldSelector,omitempty" form:"fieldSelector"` // TimeoutSeconds specifies the seconds of ClientIP type session sticky time. TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` // Offset specify the number of records to skip before starting to return the records. Offset *int64 `json:"offset,omitempty" form:"offset"` // Limit specify the number of records to be retrieved. Limit *int64 `json:"limit,omitempty" form:"limit"` }
ListOptions is the query options to a standard REST list call.
type Object ¶
type Object interface { GetID() uint64 SetID(id uint64) GetName() string SetName(name string) GetCreatedAt() time.Time SetCreatedAt(createdAt time.Time) GetUpdatedAt() time.Time SetUpdatedAt(updatedAt time.Time) }
Object lets you work with object metadata from any of the versioned or internal API objects. Attempting to set or retrieve a field on an object that does not support that field (Name, UID, Namespace on lists) will be a no-op and return a default value.
type ObjectMeta ¶
type ObjectMeta struct { // ID is the unique in time and space value for this object. It is typically generated by // the storage on successful creation of a resource and is not allowed to change on PUT // operations. // // Populated by the system. // Read-only. 数据库中的 id 字段 ID uint64 `json:"id,omitempty" gorm:"primary_key;AUTO_INCREMENT;column:id"` // InstanceID defines a string type resource identifier, // use prefixed to distinguish resource types, easy to remember, Url-friendly. // 资源的唯一标识 格式为<resource.identifier>-xxxxxx // resource.identifier 为资源英文标识符号 xxxxxx 是随机字符串 // InstanceID 的生成和更新都是自动化的,通过 gorm 提供的 AfterCreate Hooks 在记录插入数据库之后,生成并更新到数据库的 instanceID字段: InstanceID string `json:"instanceID,omitempty" gorm:"unique;column:instanceID;type:varchar(32);not null"` // Required: true // Name must be unique. Is required when creating resources. // Name is primarily intended for creation idempotence and configuration // definition. // It will be generated automated only if Name is not specified. // Cannot be updated. // 资源的名字 Name string `json:"name,omitempty" gorm:"column:name;type:varchar(64);not null" validate:"name"` // Extend store the fields that need to be added, but do not want to add a new table column, will not be stored in db. // Extend 为map[string]interface{}记录额外字段 Extend Extend `json:"extend,omitempty" gorm:"-" validate:"omitempty"` // ExtendShadow is the shadow of Extend. DO NOT modify directly. // ExtendShadow 是 Extend 在数据库中的影子 当从数据库查询数据时,ExtendShadow 的值会自动 Unmarshal 到 Extend 类型的变量中 // 借助 gorm 提供的 BeforeCreate、BeforeUpdate Hooks,在插入记录、更新记录时,将 Extend 的值转换成字符串, // 保存在 ExtendShadow 字段中,并最终保存在数据库的 ExtendShadow 字段中。 // 借助 gorm 提供的 AfterFind Hooks,在查询数据后,将 ExtendShadow 的值 Unmarshal 到 Extend 字段中, // 之后程序就可以通过 Extend 字段来使用其中的属性。 ExtendShadow string `json:"-" gorm:"column:extendShadow" validate:"omitempty"` // CreatedAt is a timestamp representing the server time when this object was // created. It is not guaranteed to be set in happens-before order across separate operations. // Clients may not set this value. It is represented in RFC3339 form and is in UTC. // // Populated by the system. // Read-only. // Null for lists. // 创建时间 CreatedAt time.Time `json:"createdAt,omitempty" gorm:"column:createdAt"` // UpdatedAt is a timestamp representing the server time when this object was updated. // Clients may not set this value. It is represented in RFC3339 form and is in UTC. // // Populated by the system. // Read-only. // Null for lists. // 更改时间 UpdatedAt time.Time `json:"updatedAt,omitempty" gorm:"column:updatedAt"` }
ObjectMeta is metadata that all persisted resources must have, which includes all objects ObjectMeta is also used by gorm.
func (*ObjectMeta) AfterFind ¶
func (obj *ObjectMeta) AfterFind(tx *gorm.DB) error
AfterFind run after find to unmarshal a extend shadown string into metav1.Extend struct.
func (*ObjectMeta) BeforeCreate ¶
func (obj *ObjectMeta) BeforeCreate(tx *gorm.DB) error
BeforeCreate run before create database record.
func (*ObjectMeta) BeforeUpdate ¶
func (obj *ObjectMeta) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate run before update database record.
func (*ObjectMeta) GetCreatedAt ¶
func (meta *ObjectMeta) GetCreatedAt() time.Time
func (*ObjectMeta) GetID ¶
func (meta *ObjectMeta) GetID() uint64
func (*ObjectMeta) GetName ¶
func (meta *ObjectMeta) GetName() string
func (*ObjectMeta) GetObjectMeta ¶
func (obj *ObjectMeta) GetObjectMeta() Object
func (*ObjectMeta) GetUpdatedAt ¶
func (meta *ObjectMeta) GetUpdatedAt() time.Time
func (*ObjectMeta) SetCreatedAt ¶
func (meta *ObjectMeta) SetCreatedAt(createdAt time.Time)
func (*ObjectMeta) SetID ¶
func (meta *ObjectMeta) SetID(id uint64)
func (*ObjectMeta) SetName ¶
func (meta *ObjectMeta) SetName(name string)
func (*ObjectMeta) SetUpdatedAt ¶
func (meta *ObjectMeta) SetUpdatedAt(updatedAt time.Time)
type ObjectMetaAccessor ¶
type ObjectMetaAccessor interface {
GetObjectMeta() Object
}
type PatchOptions ¶
type PatchOptions struct { TypeMeta `json:",inline"` // When present, indicates that modifications should not be // persisted. An invalid or unrecognized dryRun directive will // result in an error response and no further processing of the // request. Valid values are: // - All: all dry run stages will be processed // +optional DryRun []string `json:"dryRun,omitempty"` // Force is going to "force" Apply requests. It means user will // re-acquire conflicting fields owned by other people. Force // flag must be unset for non-apply patch requests. // +optional Force bool `json:"force,omitempty"` }
PatchOptions may be provided when patching an API object. PatchOptions is meant to be a superset of UpdateOptions.
type TableOptions ¶
type TableOptions struct { TypeMeta `json:",inline"` // NoHeaders is only exposed for internal callers. It is not included in our OpenAPI definitions // and may be removed as a field in a future release. NoHeaders bool `json:"-"` }
TableOptions are used when a Table is requested by the caller.
type Type ¶
type Type interface { GetAPIVersion() string SetAPIVersion(version string) GetKind() string SetKind(kind string) }
Type exposes the type and APIVersion of versioned or internal API objects.
type TypeMeta ¶
type TypeMeta struct { // Kind is a string value representing the REST resource this object represents. // Servers may infer this from the endpoint the client submits requests to. // Cannot be updated. // In CamelCase. // required: false Kind string `json:"kind,omitempty"` // APIVersion defines the versioned schema of this representation of an object. // Servers should convert recognized schemas to the latest internal value, and // may reject unrecognized values. APIVersion string `json:"apiVersion,omitempty"` }
TypeMeta describes an individual object in an API response or request with strings representing the type of the object and its API schema version. Structures that are versioned or persisted should inline TypeMeta. TypeMeta描述API响应或请求中的单个对象 字符串表示对象的类型及其API架构版本。 版本控制或持久化的结构应该内联TypeMeta。
func (*TypeMeta) GetAPIVersion ¶
func (*TypeMeta) GetObjectKind ¶
func (obj *TypeMeta) GetObjectKind() scheme.ObjectKind
func (*TypeMeta) GroupVersionKind ¶
func (obj *TypeMeta) GroupVersionKind() scheme.GroupVersionKind
GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta.
func (*TypeMeta) SetAPIVersion ¶
func (*TypeMeta) SetGroupVersionKind ¶
func (obj *TypeMeta) SetGroupVersionKind(gvk scheme.GroupVersionKind)
SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta.
type UpdateOptions ¶
type UpdateOptions struct { TypeMeta `json:",inline"` // When present, indicates that modifications should not be // persisted. An invalid or unrecognized dryRun directive will // result in an error response and no further processing of the // request. Valid values are: // - All: all dry run stages will be processed // +optional DryRun []string `json:"dryRun,omitempty"` }
UpdateOptions may be provided when updating an API object. All fields in UpdateOptions should also be present in PatchOptions.