v1

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 9 Imported by: 7

Documentation

Overview

Package v1 defines schemes used by apimachinery-apiserver.

Index

Constants

View Source
const GroupName = "iam.api"

GroupName is the group name use in this package. If use a public domain name, need set the GroupName to service name. For example: if restful path is: https://marmotedu.com/apimachinery/v1/secrets, we can set GroupName="apimachinery".

Variables

View Source
var SchemeGroupVersion = scheme.GroupVersion{Group: GroupName, Version: "v1"}

SchemeGroupVersion is group version used to register these objects.

Functions

func Resource

func Resource(resource string) scheme.GroupResource

Resource takes an unqualified resource and returns a Group qualified GroupResource.

Types

type AuthzPolicy added in v0.0.3

type AuthzPolicy ladon.DefaultPolicy

AuthzPolicy defines iam policy type.

func (AuthzPolicy) String added in v0.0.3

func (ap AuthzPolicy) String() string

String returns the string format of Policy.

type Policy

type Policy struct {

	// Standard object's metadata.
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// The user of the policy.
	Username string `json:"username" gorm:"column:username" validate:"omitempty"`

	// AuthzPolicy policy, will not be stored in db.
	Policy AuthzPolicy `json:"policy,omitempty" gorm:"-" validate:"omitempty"`

	// 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 restful resource, include a ladon policy. It is also used as gorm model.

func (*Policy) AfterCreate added in v0.0.3

func (p *Policy) AfterCreate(tx *gorm.DB) (err error)

AfterCreate run after create database record.

func (*Policy) AfterFind

func (p *Policy) AfterFind(tx *gorm.DB) (err error)

AfterFind run after find to unmarshal a policy string into ladon.DefaultPolicy struct.

func (*Policy) BeforeCreate

func (p *Policy) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate run before create database record.

func (*Policy) BeforeUpdate

func (p *Policy) BeforeUpdate(tx *gorm.DB) (err error)

BeforeUpdate run before update database record.

func (*Policy) TableName

func (p *Policy) TableName() string

TableName maps to mysql table name.

func (*Policy) Validate

func (p *Policy) Validate() field.ErrorList

Validate validates that a policy object is valid.

type PolicyList

type PolicyList struct {

	// Standard list metadata.
	metav1.ListMeta `json:",inline"`

	// List of policies.
	Items []*Policy `json:"items"`
}

PolicyList is the whole list of all policies which have been stored in stroage.

type Secret

type Secret struct {

	// Standard object's metadata.
	metav1.ObjectMeta `       json:"metadata,omitempty"`
	Username          string `json:"username"           gorm:"column:username"  validate:"omitempty"`
	SecretID          string `json:"secretID"           gorm:"column:secretID"  validate:"omitempty"`
	SecretKey         string `json:"secretKey"          gorm:"column:secretKey" validate:"omitempty"`

	// Required: true
	Expires     int64  `json:"expires"     gorm:"column:expires"     validate:"omitempty"`
	Description string `json:"description" gorm:"column:description" validate:"description"`
}

Secret represents a secret restful resource. It is also used as gorm model.

func (*Secret) AfterCreate added in v0.0.3

func (s *Secret) AfterCreate(tx *gorm.DB) (err error)

AfterCreate run after create database record.

func (*Secret) AfterFind added in v0.0.3

func (s *Secret) AfterFind(tx *gorm.DB) (err error)

AfterFind run after find to unmarshal a extend shadown string into metav1.Extend struct.

func (*Secret) BeforeCreate

func (s *Secret) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate run before create database record.

func (*Secret) BeforeUpdate added in v0.0.3

func (s *Secret) BeforeUpdate(tx *gorm.DB) (err error)

BeforeUpdate run before update database record.

func (*Secret) TableName

func (s *Secret) TableName() string

TableName maps to mysql table name.

func (*Secret) Validate

func (s *Secret) Validate() field.ErrorList

Validate validates that a secret object is valid.

type SecretList

type SecretList struct {

	// Standard list metadata.
	metav1.ListMeta `json:",inline"`

	// List of secrets
	Items []*Secret `json:"items"`
}

SecretList is the whole list of all secrets which have been stored in stroage.

type User

type User struct {

	// Standard object's metadata.
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Required: true
	Nickname string `json:"nickname" gorm:"column:nickname" validate:"required,min=1,max=30"`

	// Required: true
	Password string `json:"password,omitempty" gorm:"column:password" validate:"required"`

	// Required: true
	Email string `json:"email" gorm:"column:email" validate:"required,email,min=1,max=100"`

	Phone string `json:"phone" gorm:"column:phone" validate:"omitempty"`

	IsAdmin int `json:"isAdmin,omitempty" gorm:"column:isAdmin" validate:"omitempty"`

	TotalPolicy int64 `json:"totalPolicy" gorm:"-" validate:"omitempty"`
}

User represents a user restful resource. It is also used as gorm model.

func (*User) AfterCreate added in v0.0.3

func (u *User) AfterCreate(tx *gorm.DB) (err error)

AfterCreate run after create database record.

func (*User) AfterFind added in v0.0.3

func (u *User) AfterFind(tx *gorm.DB) (err error)

AfterFind run after find to unmarshal a extend shadown string into metav1.Extend struct.

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate run before create database record.

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(tx *gorm.DB) (err error)

BeforeUpdate run before update database record.

func (*User) Compare

func (u *User) Compare(pwd string) (err error)

Compare with the plain text password. Returns true if it's the same as the encrypted one (in the `User` struct).

func (*User) TableName

func (u *User) TableName() string

TableName maps to mysql table name.

func (*User) Validate

func (u *User) Validate() field.ErrorList

Validate validates that a user object is valid.

func (*User) ValidateUpdate

func (u *User) ValidateUpdate() field.ErrorList

ValidateUpdate validates that a user object is valid when update. Like User.Validate but not validate password.

type UserList

type UserList struct {

	// Standard list metadata.
	// +optional
	metav1.ListMeta `json:",inline"`

	Items []*User `json:"items"`
}

UserList is the whole list of all users which have been stored in stroage.

Jump to

Keyboard shortcuts

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