Documentation ¶
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.
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.
type Policy ¶
type Policy struct { // Standard object metadata. ObjectMeta `json:"metadata,omitempty"` // The user of the policy. Username string `json:"username,omitempty" gorm:"column:username"` Policy ladon.DefaultPolicy `json:"policy,omitempty" gorm:"-"` // The ladon policy content, just a string format of ladon.DefaultPolicy. DO NOT modify directly. PolicyShadow string `json:"-" gorm:"column:policyShadow" validate:"omitempty"` }
Policy represents a policy resource including a ladon policy. It is also used as gorm model.
func (*Policy) AfterCreate ¶
AfterCreate runs after create database record.
func (*Policy) AfterFind ¶
AfterFind runs after find to unmarshal a policy string into ladon.DefaultPolicy struct.
func (*Policy) BeforeCreate ¶
BeforeCreate runs before create database record.
type PolicyList ¶
type PolicyList struct { // Standard list metadata. ListMeta `json:",inline"` // List of policies. Items []*Policy `json:"items"` }
PolicyList represents a collection of policies.
type Secret ¶
type Secret struct { // Standard object metadata. ObjectMeta `json:"metadata,omitempty"` Username string `json:"username,omitempty" gorm:"column:username"` SecretID string `json:"secretID,omitempty" gorm:"column:secretID"` SecretKey string `json:"secretKey,omitempty" gorm:"column:secretKey"` Expires int64 `json:"expires" gorm:"column:expires" validate:"required"` Description string `json:"description" gorm:"column:description" validate:"required,email,min=1,max=100"` }
Secret represents a secret resource. It is also used as gorm model.
type SecretList ¶
type SecretList struct { // Standard list metadata. ListMeta `json:",inline"` // List of secrets Items []*Secret `json:"items"` }
SecretList represents a collection of secrets.
type User ¶
type User struct { // Standard object metadata. ObjectMeta `json:"metadata,omitempty"` Username string `json:"username" gorm:"column:username" validate:"required,min=1,max=30"` Password string `json:"password,omitempty" gorm:"column:password" validate:"required"` Email string `json:"email" gorm:"column:email" validate:"required,email,min=1,max=100"` Phone string `json:"phone,omitempty" gorm:"column:phone"` TotalPolicy int64 `json:"totalPolicy,omitempty" gorm:"-"` LoginedAt *time.Time `json:"loginedAt,omitempty" gorm:"column:loginedAt"` IsAdmin bool `json:"isAdmin,omitempty" gorm:"column:isAdmin;default:false"` IsActive bool `json:"isActive,omitempty" gorm:"column:isActive;default:true"` }
User represents a user resource. It is also used as gorm model.
func (*User) AfterCreate ¶
AfterCreate runs after create database record.
func (*User) VerifyPassword ¶
VerifyPassword verifies the plain text password.