meta

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package meta contains API types that are common to all versions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extend

type Extend map[string]interface{}

Extend defines a new type used to store extended fields.

func (Extend) String

func (ext Extend) String() string

String returns the string format of Extend.

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}.

type ListOptions

type ListOptions struct {
	// Offset specify the number of records to skip before starting to return the records.
	Offset *int `json:"offset,omitempty" form:"offset,omitempty"`

	// Limit specify the number of records to be retrieved.
	Limit *int `json:"limit,omitempty" form:"limit,omitempty"`
}

ListOptions is the query options to a standard REST list call.

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 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.
	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:"unique;column:name;type:varchar(64);not null"`

	// 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 Extend `json:"extend,omitempty" gorm:"-"`

	// ExtendShadow is the shadow of Extend. DO NOT modify directly.
	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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL