Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertMapToStruct(object interface{}, values interface{}) error
- func Encrypt(content string, salt string) string
- func GenerateRandomString() string
- func GetStrValueOfAnyType(value interface{}) string
- func IsContainIllegalChar(s string, illegalChar []string) bool
- func IsIllegalLength(s string, min int, max int) bool
- func ParseEndpoint(endpoint string) (*url.URL, error)
- func ParseOfftime(offtime int64) (hour, minite, second int)
- func ParseProjectIDOrName(value interface{}) (int64, string, error)
- func ParseRepository(repository string) (project, rest string)
- func ParseTimeStamp(timestamp string) (*time.Time, error)
- func ReversibleDecrypt(str, key string) (string, error)
- func ReversibleEncrypt(str, key string) (string, error)
- func SafeCastBool(value interface{}) bool
- func SafeCastFloat64(value interface{}) float64
- func SafeCastInt(value interface{}) int
- func SafeCastString(value interface{}) string
- func TestTCPConn(addr string, timeout, interval int) error
- func TrimLower(str string) string
- func ValidateRepo(repo string) bool
- func ValidateTag(tag string) bool
- type Link
- type Links
- type TimeMarker
Constants ¶
const (
// EncryptHeaderV1 ...
EncryptHeaderV1 = "<enc-v1>"
)
Variables ¶
var RepoRegexp = regexp.MustCompile(fmt.Sprintf("^%s(/%s)*$", nameComponent, nameComponent))
RepoRegexp is regular expression to match repo name, for example, 'busybox', 'stage/busybox'
var TagRegexp = regexp.MustCompile(`^[\w][\w.-]{0,127}$`)
TagRegexp is regular expression to match image tags, for example, 'v1.0'
Functions ¶
func ConvertMapToStruct ¶
func ConvertMapToStruct(object interface{}, values interface{}) error
ConvertMapToStruct is used to fill the specified struct with map.
func GenerateRandomString ¶
func GenerateRandomString() string
GenerateRandomString generates a random string
func GetStrValueOfAnyType ¶ added in v1.8.0
func GetStrValueOfAnyType(value interface{}) string
GetStrValueOfAnyType return string format of any value, for map, need to convert to json
func IsContainIllegalChar ¶ added in v1.8.0
IsContainIllegalChar ...
func IsIllegalLength ¶ added in v1.8.0
IsIllegalLength ...
func ParseEndpoint ¶
ParseEndpoint parses endpoint to a URL
func ParseOfftime ¶ added in v1.6.0
ParseOfftime ...
func ParseProjectIDOrName ¶
ParseProjectIDOrName parses value to ID(int64) or name(string)
func ParseRepository ¶
ParseRepository splits a repository into two parts: project and rest
func ParseTimeStamp ¶
ParseTimeStamp parse timestamp to time
func ReversibleDecrypt ¶
ReversibleDecrypt decrypts the str with aes/base64 or base 64 depending on "header"
func ReversibleEncrypt ¶
ReversibleEncrypt encrypts the str with aes/base64
func SafeCastFloat64 ¶ added in v1.5.2
func SafeCastFloat64(value interface{}) float64
SafeCastFloat64 --
func SafeCastString ¶ added in v1.5.2
func SafeCastString(value interface{}) string
SafeCastString -- cast a object to string saftely
func TestTCPConn ¶
TestTCPConn tests TCP connection timeout: the total time before returning if something is wrong with the connection, in second interval: the interval time for retring after failure, in second
func ValidateRepo ¶ added in v1.7.1
ValidateRepo validates whether a repo name is valid.
func ValidateTag ¶ added in v1.7.1
ValidateTag validates whether a tag is valid.
Types ¶
type TimeMarker ¶
TimeMarker is used to control an action not to be taken frequently within the interval
func (*TimeMarker) Check ¶
func (t *TimeMarker) Check() bool
Check returns true if the current time is after the mark by this marker, and the caction the mark guards and be taken.
func (*TimeMarker) Mark ¶
func (t *TimeMarker) Mark()
Mark tries to mark a future time, which is after the duration of interval from the time it's called.
func (*TimeMarker) Next ¶
func (t *TimeMarker) Next() time.Time
Next returns the time of the next mark.