utils

package
v0.0.0-...-b9a05f1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 25 Imported by: 14

Documentation

Index

Constants

View Source
const (
	EncryptRSA          = "rsa"
	EncryptNone         = "none"
	EncryptNotSupported = "not-supported"
)

Variables

View Source
var (
	ErrorsNoDockerClient = errors.New("No docker client detected")
)

Functions

func Contain

func Contain(obj interface{}, target interface{}) (bool, error)

Containe checks if a target item exists in the list/map

func DecodeBasicAuth

func DecodeBasicAuth(authorization string) (username string, password string, err error)

DecodeBasicAuth decode a base64 string into a username and a password

func EncodeBasicAuth

func EncodeBasicAuth(username string, password string) string

EncodeBasicAuth encode username and password into a base64 string

func GenerateRSAKeyPair

func GenerateRSAKeyPair(bits int) ([]byte, []byte, error)

GenerateRSAKeyPair generate a private key and a public key

func GetFileSize

func GetFileSize(path string) (int64, error)

func IsDirExist

func IsDirExist(path string) bool

IsDirExist checks if a path is an existed dir

func IsFileExist

func IsFileExist(filename string) bool

IsFileExist checks if a file url is an exist file

func IsImageCached

func IsImageCached(imageName string) (bool, error)

func MD5

func MD5(key string) string

MD5 generates a md value of a key automaticly

func PullImage

func PullImage(imageName string) error

func RSADecrypt

func RSADecrypt(keyBytes []byte, contentBytes []byte) ([]byte, error)

RSADecrypt decrypts content by a private key

func RSAEncrypt

func RSAEncrypt(keyBytes []byte, contentBytes []byte) ([]byte, error)

RSAEncrypt encrypts a content by a public key

func SHA256Sign

func SHA256Sign(keyBytes []byte, contentBytes []byte) ([]byte, error)

SHA256Sign signs a content by a private key

func SHA256Verify

func SHA256Verify(keyBytes []byte, contentBytes []byte, signBytes []byte) error

SHA256Verify verifies if a content is valid by a signed data an a public key

func StartContainer

func StartContainer(config container.Config, hostConfig container.HostConfig, containerName string) error

StartContainer start and create a container

func TokenMarshal

func TokenMarshal(v interface{}, key string) ([]byte, error)

TokenMarshal encrypts data in `v`

func TokenUnmarshal

func TokenUnmarshal(token string, key string, v interface{}) error

TokenUnmarshal decryptes a token and save the original data to `v`.

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword verifies if a password is valid

Types

type EncryptMethod

type EncryptMethod string

func NewEncryptMethod

func NewEncryptMethod(method string) EncryptMethod

type Meta

type Meta struct {
	Items   []MetaItem
	Updated time.Time
}

Meta represents the meta info of a repository

func (Meta) Before

func (a Meta) Before(b Meta) bool

type MetaItem

type MetaItem struct {
	Name   string
	Hash   string
	Method EncryptMethod

	Created time.Time
	Expired time.Time
}

MetaItem represents the meta information of a repository app/vm/image

func GenerateMetaItem

func GenerateMetaItem(file string, contentByte []byte) (meta MetaItem)

GenerateMetaItem generates a meta data by a file name and file content

func (MetaItem) Compare

func (a MetaItem) Compare(b MetaItem) int

Compare checks if two meta is the same

func (MetaItem) GetCreated

func (a MetaItem) GetCreated() time.Time

GetCreated returns the created time of an application

func (MetaItem) GetEncryption

func (a MetaItem) GetEncryption() EncryptMethod

func (MetaItem) GetExpired

func (a MetaItem) GetExpired() time.Time

GetExpired get the expired time of an application

func (MetaItem) GetHash

func (a MetaItem) GetHash() string

GetHash get the hash string of a file

func (MetaItem) IsExpired

func (a MetaItem) IsExpired() bool

IsExpired tells if an application is expired

func (*MetaItem) SetCreated

func (a *MetaItem) SetCreated(t time.Time)

SetCreated set the created time of an application

func (*MetaItem) SetEncryption

func (a *MetaItem) SetEncryption(method EncryptMethod)

func (*MetaItem) SetExpired

func (a *MetaItem) SetExpired(t time.Time)

SetExpired set the expired time of an application

Jump to

Keyboard shortcuts

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