Documentation ¶
Index ¶
- Constants
- func ClientIP(r *http.Request) string
- func ContextWithUserInfo(ctx context.Context) context.Context
- func ExtractPagingParams(req *restful.Request, minPageSize, maxPageSize int) (int, int, error)
- func FirstLower(s string) string
- func FirstUpper(s string) string
- func GenerateVersion(pre string) string
- func GetDefaultUIType(apiType string, haveOptions bool, subType string, haveSub bool) string
- func GetDexConnectors(ctx context.Context, k8sClient client.Client) ([]map[string]interface{}, error)
- func NewAuthApplicationClient(cli client.Client) client.Client
- func ProjectFrom(ctx context.Context) (string, bool)
- func RenderLabel(source interface{}) string
- func SetUsernameAndProjectInRequestContext(req *restful.Request, userName string, projectName string)
- func StringsContain(items []string, source string) bool
- func UsernameFrom(ctx context.Context) (string, bool)
- func WithProject(parent context.Context, project string) context.Context
- func WithUsername(parent context.Context, username string) context.Context
- type Condition
- type GroupOption
- type MemoryCacheStore
- type Option
- type ResponseCapture
- type Style
- type UIParameter
- type UISchema
- type Validate
Constants ¶
const KubeVelaProjectGroupPrefix = "kubevela:project:"
KubeVelaProjectGroupPrefix the prefix kubevela project
Variables ¶
This section is empty.
Functions ¶
func ContextWithUserInfo ¶
ContextWithUserInfo extract user from context (parse username and project) for impersonation
func ExtractPagingParams ¶
ExtractPagingParams extract `page` and `pageSize` params from request
func FirstLower ¶
FirstLower Sets the first letter of the string to lowercase.
func FirstUpper ¶
FirstUpper Sets the first letter of the string to upper.
func GenerateVersion ¶
GenerateVersion Generate version numbers by time
func GetDefaultUIType ¶
GetDefaultUIType Set the default mapping for API Schema Type
func GetDexConnectors ¶
func GetDexConnectors(ctx context.Context, k8sClient client.Client) ([]map[string]interface{}, error)
GetDexConnectors returns the dex connectors for Dex connector controller
func NewAuthApplicationClient ¶
NewAuthApplicationClient will carry UserInfo for mutating requests related to application automatically
func ProjectFrom ¶
ProjectFrom extract project from context
func SetUsernameAndProjectInRequestContext ¶
func SetUsernameAndProjectInRequestContext(req *restful.Request, userName string, projectName string)
SetUsernameAndProjectInRequestContext .
func StringsContain ¶
StringsContain strings contain
func UsernameFrom ¶
UsernameFrom extract username from context
func WithProject ¶
WithProject carries project in context
Types ¶
type Condition ¶
type Condition struct { // JSONKey specifies the path of the field, support the peer and subordinate fields. JSONKey string `json:"jsonKey"` // Op options includes `==` 、`!=` and `in`, default is `==` // +optional Op string `json:"op,omitempty"` // Value specifies the prospective value. Value interface{} `json:"value"` // Action options includes `enable` or `disable`, default is `enable` // +optional Action string `json:"action,omitempty"` }
Condition control whether fields are enabled or disabled by certain conditions.
type GroupOption ¶
GroupOption define multiple data structure composition options.
type MemoryCacheStore ¶
type MemoryCacheStore struct {
// contains filtered or unexported fields
}
MemoryCacheStore a sample memory cache instance, if data set cache duration, will auto clear after timeout. But, Expired cleanup is not necessarily accurate, it has a 3-second window.
func NewMemoryCacheStore ¶
func NewMemoryCacheStore(ctx context.Context) *MemoryCacheStore
NewMemoryCacheStore memory cache store
func (*MemoryCacheStore) Delete ¶
func (m *MemoryCacheStore) Delete(key interface{})
Delete cache data from store
func (*MemoryCacheStore) Get ¶
func (m *MemoryCacheStore) Get(key interface{}) (value interface{})
Get cache data from store, if not exist or timeout, will return nil
func (*MemoryCacheStore) Put ¶
func (m *MemoryCacheStore) Put(key, value interface{}, cacheDuration time.Duration)
Put cache data, if cacheDuration>0, store will clear data after timeout.
type Option ¶
type Option struct { Label string `json:"label"` Value interface{} `json:"value"` }
Option select option
type ResponseCapture ¶
type ResponseCapture struct { http.ResponseWriter // contains filtered or unexported fields }
ResponseCapture capture response and get response info
func NewResponseCapture ¶
func NewResponseCapture(w http.ResponseWriter) *ResponseCapture
NewResponseCapture new response capture
func (ResponseCapture) Bytes ¶
func (c ResponseCapture) Bytes() []byte
Bytes return response body bytes
func (ResponseCapture) Header ¶
func (c ResponseCapture) Header() http.Header
Header return response writer header
func (ResponseCapture) StatusCode ¶
func (c ResponseCapture) StatusCode() int
StatusCode return status code
func (ResponseCapture) Write ¶
func (c ResponseCapture) Write(data []byte) (int, error)
Write write data to response writer and body
func (*ResponseCapture) WriteHeader ¶
func (c *ResponseCapture) WriteHeader(statusCode int)
WriteHeader write header to response writer
type Style ¶
type Style struct { // ColSpan the width of a responsive layout ColSpan int `json:"colSpan"` }
Style ui style
type UIParameter ¶
type UIParameter struct { Sort uint `json:"sort"` Label string `json:"label"` Description string `json:"description"` Validate *Validate `json:"validate,omitempty"` JSONKey string `json:"jsonKey"` UIType string `json:"uiType"` Style *Style `json:"style,omitempty"` // means disable parameter in ui Disable *bool `json:"disable,omitempty"` // Conditions: control whether fields are enabled or disabled by certain conditions. // Rules: // if all conditions are not matching, the parameter will be disabled // if there are no conditions, and disable==false the parameter will be enabled. // if one disable action condition is matched, the parameter will be disabled. // if all enable actions conditions are matched, the parameter will be enabled. // +optional Conditions []Condition `json:"conditions,omitempty"` SubParameterGroupOption []GroupOption `json:"subParameterGroupOption,omitempty"` SubParameters []*UIParameter `json:"subParameters,omitempty"` AdditionalParameter *UIParameter `json:"additionalParameter,omitempty"` Additional *bool `json:"additional,omitempty"` }
UIParameter Structured import table simple UI model
type Validate ¶
type Validate struct { Required bool `json:"required,omitempty"` Max *float64 `json:"max,omitempty"` MaxLength *uint64 `json:"maxLength,omitempty"` Min *float64 `json:"min,omitempty"` MinLength uint64 `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` Options []Option `json:"options,omitempty"` DefaultValue interface{} `json:"defaultValue,omitempty"` // the parameter cannot be changed twice. Immutable bool `json:"immutable"` }
Validate parameter validate rule