util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2016 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Become         string = "^(sudo|su|pbrun|pfexec|runas|doas|dzdo)$"
	CredentialKind string = "^(windows|ssh|net|scm|aws|rax|vmware|satellite6|cloudforms|gce|azure|openstack)$"
	ScmType        string = "^(manual|git|hg|svn)$"
	JobType        string = "^(run|check|scan)$"

	DNSName      string = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62}){1}(\.[a-zA-Z0-9]{1}[a-zA-Z0-9_-]{1,62})*$`
	IP           string = `` /* 659-byte string literal not displayed */
	URLSchema    string = `((ftp|tcp|udp|wss?|https?):\/\/)`
	URLUsername  string = `(\S+(:\S*)?@)`
	URLPath      string = `((\/|\?|#)[^\s]*)`
	URLPort      string = `(:(\d{1,5}))`
	URLIP        string = `([1-9]\d?|1\d\d|2[01]\d|22[0-3])(\.(1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.([0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))`
	URLSubdomain string = `((www\.)|([a-zA-Z0-9]([-\.][a-zA-Z0-9]+)*))`
	URL          string = `^` + URLSchema + `?` + URLUsername + `?` + `((` + URLIP + `|(\[` + IP + `\])|(([a-zA-Z0-9]([a-zA-Z0-9-]+)?[a-zA-Z0-9]([-\.][a-zA-Z0-9]+)*)|(` + URLSubdomain + `?))?(([a-zA-Z\x{00a1}-\x{ffff}0-9]+-?-?)*[a-zA-Z\x{00a1}-\x{ffff}0-9]+)(?:\.([a-zA-Z\x{00a1}-\x{ffff}]{1,}))?))` + URLPort + `?` + URLPath + `?$`
)

Variables

View Source
var (
	DefaultLimit = int(10)
	MinLimit     = int(1)
	MaxLimit     = int(500)
	LimitParam   = "page_size"
	DefaultPage  = int(1)
	PageParam    = "page"
)
View Source
var Config *configType
View Source
var InteractiveSetup bool
View Source
var (
	OrderParam = "order_by"
)
View Source
var Secrets bool
View Source
var Uni *ut.UniversalTranslator

use a single instance , it caches struct info

View Source
var Version = "0.1 alpha2"

Version is for hold the system version globally

Functions

func AuthFailed

func AuthFailed(c *gin.Context)

func CredentialStructLevelValidation added in v0.0.2

func CredentialStructLevelValidation(sl validator.StructLevel)

TODO: openstack,azure,gce,

func FindTensor

func FindTensor() string

func GenerateCookieSecrets

func GenerateCookieSecrets()

func GetAPIInfo

func GetAPIInfo(c *gin.Context)

func GetAPIVersion

func GetAPIVersion(c *gin.Context)

func GetIdParam

func GetIdParam(name string, c *gin.Context) (string, error)

GetIdParam is to Get ObjectID url parameter If the parameter is not an ObjectId it will terminate the request

func GetIntParam

func GetIntParam(name string, c *gin.Context) (int, error)

func GetPing

func GetPing(c *gin.Context)

func GetU64IntParam

func GetU64IntParam(name string, c *gin.Context) (uint64, error)

func GetValidationErrors added in v0.0.2

func GetValidationErrors(err error) string

func IsCredentialKind added in v0.0.2

func IsCredentialKind(fl validator.FieldLevel) bool

func IsDNSName added in v0.0.2

func IsDNSName(fl validator.FieldLevel) bool

IsDNSName will validate the given string as a DNS name

func IsHost added in v0.0.2

func IsHost(fl validator.FieldLevel) bool

IsHost checks if the string is a valid IP (both v4 and v6) or a valid DNS name

func IsIP added in v0.0.2

func IsIP(fl validator.FieldLevel) bool

IsIP checks if a string is either IP version 4 or 6.

func IsJobType added in v0.0.2

func IsJobType(fl validator.FieldLevel) bool

func IsScmType added in v0.0.2

func IsScmType(fl validator.FieldLevel) bool

func NaProperty added in v0.0.2

func NaProperty(fl validator.FieldLevel) bool

fail all

func ProjectStructLevelValidation added in v0.0.2

func ProjectStructLevelValidation(sl validator.StructLevel)

func ValidateEmail

func ValidateEmail(email string) bool

Types

type MongoDBConfig

type MongoDBConfig struct {
	Hosts      []string `yaml:"hosts"`
	Username   string   `yaml:"user"`
	Password   string   `yaml:"pass"`
	DbName     string   `yaml:"name"`
	ReplicaSet string   `yaml:"replica_set"`
}

type Pagination

type Pagination struct {
	// contains filtered or unexported fields
}

func NewPagination

func NewPagination(c *gin.Context, n int) *Pagination

func (*Pagination) End

func (p *Pagination) End() int

for slices

func (*Pagination) HasPage

func (p *Pagination) HasPage() bool

func (*Pagination) Limit

func (p *Pagination) Limit() int

func (*Pagination) NextPage

func (p *Pagination) NextPage() interface{}

func (*Pagination) Offset

func (p *Pagination) Offset() int

func (*Pagination) Page

func (p *Pagination) Page() int

func (*Pagination) PreviousPage

func (p *Pagination) PreviousPage() interface{}

func (*Pagination) Skip

func (p *Pagination) Skip() int

for slices

type QueryParser

type QueryParser struct {
	// contains filtered or unexported fields
}

func NewQueryParser

func NewQueryParser(c *gin.Context) QueryParser

func (*QueryParser) IContains

func (p *QueryParser) IContains(s []string) bson.M

func (*QueryParser) Match

func (p *QueryParser) Match(s []string) bson.M

func (*QueryParser) OrderBy

func (p *QueryParser) OrderBy() string

type SpaceValidator

type SpaceValidator struct {
	// contains filtered or unexported fields
}

func (*SpaceValidator) ValidateStruct

func (v *SpaceValidator) ValidateStruct(obj interface{}) error

Directories

Path Synopsis
Package uniuri generates random strings good for use in URIs to identify unique objects.
Package uniuri generates random strings good for use in URIs to identify unique objects.

Jump to

Keyboard shortcuts

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