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 ¶
func GetStrValueOfAnyType(value interface{}) string
GetStrValueOfAnyType return string format of any value, for map, need to convert to json
func IsContainIllegalChar ¶
IsContainIllegalChar ...
func ParseEndpoint ¶
ParseEndpoint parses endpoint to a URL
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 SafeCastString ¶
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 ¶
ValidateRepo validates whether a repo name 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.