Documentation
¶
Index ¶
- Variables
- type AuthorizeOptions
- type AuthzPolicy
- type CreateOptions
- type DeleteOptions
- type ExportOptions
- type Extend
- type GetOptions
- type Greeter
- type GreeterRepo
- type GreeterUsecase
- type ListMeta
- type ListOptions
- type ObjectMeta
- type PatchOptions
- type Policy
- type PolicyList
- type PolicyRepo
- type PolicyUsecase
- type Secret
- type SecretList
- type SecretRepo
- type SecretUsecase
- type TableOptions
- type TypeMeta
- type UpdateOptions
- type User
- type UserList
- type UserRepo
- type UserUsecase
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUserNotFound is user not found. ErrUserNotFound = errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), "user not found") )
var ProviderSet = wire.NewSet( NewPolicyUsecase, NewUserUsecase, NewSecretUsecase, )
ProviderSet is biz providers.
Functions ¶
This section is empty.
Types ¶
type AuthorizeOptions ¶
type AuthorizeOptions struct {
TypeMeta `json:",inline"`
}
AuthorizeOptions may be provided when authorize an API object.
type AuthzPolicy ¶
type AuthzPolicy struct {
ladon.DefaultPolicy
}
AuthzPolicy defines iam policy type.
func (AuthzPolicy) String ¶
func (ap AuthzPolicy) String() string
String returns the string format of Policy.
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"`
}
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{}
type GetOptions ¶
type GetOptions struct {
TypeMeta `json:",inline"`
}
GetOptions is the standard query options to the standard REST get call.
type GreeterRepo ¶
type GreeterRepo interface {
Save(context.Context, *Greeter) (*Greeter, error)
Update(context.Context, *Greeter) (*Greeter, error)
FindByID(context.Context, int64) (*Greeter, error)
ListByHello(context.Context, string) ([]*Greeter, error)
ListAll(context.Context) ([]*Greeter, error)
}
GreeterRepo is a Greater repo.
type GreeterUsecase ¶
type GreeterUsecase struct {
// contains filtered or unexported fields
}
GreeterUsecase is a Greeter usecase.
func NewGreeterUsecase ¶
func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase
NewGreeterUsecase new a Greeter usecase.
func (*GreeterUsecase) CreateGreeter ¶
CreateGreeter creates a Greeter, and returns the new Greeter.
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 {
TypeMeta `json:",inline"`
// LabelSelector is used to find matching REST resources.
LabelSelector string `json:"labelSelector,omitempty" form:"labelSelector"`
// 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 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:"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 Extend `json:"extend,omitempty" gorm:"-" validate:"omitempty"`
// 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"`
}
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 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 Policy ¶
type Policy struct {
// Standard object's metadata.
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"`
}
func (*Policy) AfterCreate ¶
AfterCreate run after create database record.
func (*Policy) AfterFind ¶
AfterFind run after find to unmarshal a policy string into ladon.DefaultPolicy struct.
func (*Policy) BeforeCreate ¶
BeforeCreate run before create database record.
func (*Policy) BeforeUpdate ¶
BeforeUpdate run before update database record.
type PolicyList ¶
type PolicyList struct {
// Standard list metadata.
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 PolicyRepo ¶
type PolicyRepo interface {
Create(ctx context.Context, policy *Policy, opts CreateOptions) error
Update(ctx context.Context, policy *Policy, opts UpdateOptions) error
Delete(ctx context.Context, username string, name string, opts DeleteOptions) error
DeleteCollection(ctx context.Context, username string, names []string, opts DeleteOptions) error
Get(ctx context.Context, username string, name string, opts GetOptions) (*Policy, error)
List(ctx context.Context, username string, opts ListOptions) (*PolicyList, error)
}
PolicyRepo is a Greater repo.
type PolicyUsecase ¶
type PolicyUsecase struct {
// contains filtered or unexported fields
}
PolicyUsecase is a Policy usecase.
func NewPolicyUsecase ¶
func NewPolicyUsecase(repo PolicyRepo, logger log.Logger) *PolicyUsecase
type Secret ¶
type Secret struct {
// Standard object's metadata.
ObjectMeta ` json:"metadata,omitempty"`
Username string `json:"username" gorm:"column:username" validate:"omitempty"`
//nolint: tagliatelle
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 ¶
AfterCreate run after create database record.
type SecretList ¶
type SecretList struct {
// Standard list metadata.
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 SecretRepo ¶
type SecretRepo interface {
Create(ctx context.Context, secret Secret, opts CreateOptions) error
Update(ctx context.Context, secret Secret, opts UpdateOptions) error
Delete(ctx context.Context, username, secretID string, opts DeleteOptions) error
DeleteCollection(ctx context.Context, username string, secretIDs []string, opts DeleteOptions) error
Get(ctx context.Context, username, secretID string, opts GetOptions) (Secret, error)
List(ctx context.Context, username string, opts ListOptions) (*SecretList, error)
}
type SecretUsecase ¶
type SecretUsecase struct {
// contains filtered or unexported fields
}
PolicyUsecase is a Policy usecase.
func NewSecretUsecase ¶
func NewSecretUsecase(repo SecretRepo, logger log.Logger) *SecretUsecase
func (*SecretUsecase) Create ¶
func (uc *SecretUsecase) Create(ctx context.Context, secret Secret) error
func (*SecretUsecase) List ¶
func (uc *SecretUsecase) List(ctx context.Context, username string, opts ListOptions) (list *SecretList, err error)
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 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"`
}
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.
type User ¶
type User struct {
ObjectMeta
Status int `json:"status" gorm:"column:status" validate:"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"`
LoginedAt time.Time `json:"loginedAt,omitempty" gorm:"column:loginedAt"`
}
func (*User) AfterCreate ¶
AfterCreate run after create database record.
type UserList ¶
type UserList struct {
// Standard list metadata.
// +optional
ListMeta `json:",inline"`
Items []*User `json:"items"`
}
UserList is the whole list of all users which have been stored in stroage.
type UserRepo ¶
type UserRepo interface {
Create(ctx context.Context, user *User, opts CreateOptions) error
Update(ctx context.Context, user *User, opts UpdateOptions) error
Delete(ctx context.Context, username string, opts DeleteOptions) error
DeleteCollection(ctx context.Context, usernames []string, opts DeleteOptions) error
Get(ctx context.Context, user *User, opts GetOptions) (*User, error)
List(ctx context.Context, opts ListOptions) (*UserList, error)
}
PolicyRepo is a Greater repo.
type UserUsecase ¶
type UserUsecase struct {
// contains filtered or unexported fields
}
PolicyUsecase is a Policy usecase.