Documentation
¶
Index ¶
- Variables
- func RegisterStorage(name string, f UpdateServiceStorage) error
- type LocalRepo
- func (r LocalRepo) Delete(name string) error
- func (r LocalRepo) Get(name string) ([]byte, error)
- func (r LocalRepo) GetMeta() ([]byte, error)
- func (r LocalRepo) GetMetaFile() string
- func (r LocalRepo) GetMetaSignFile() string
- func (r LocalRepo) GetPublicKeyFile() string
- func (r LocalRepo) GetTopDir() string
- func (r LocalRepo) List() ([]string, error)
- func (r LocalRepo) Put(name string, content []byte, method utils.EncryptMethod) (string, error)
- func (r *LocalRepo) SetKM(kmURL string) error
- type UpdateServiceStorage
- type UpdateServiceStorageLocal
- func (ussl *UpdateServiceStorageLocal) Delete(proto string, key string) error
- func (ussl *UpdateServiceStorageLocal) Get(proto string, key string) ([]byte, error)
- func (ussl *UpdateServiceStorageLocal) GetMeta(proto string, key string) ([]byte, error)
- func (ussl *UpdateServiceStorageLocal) GetMetaSign(proto string, key string) ([]byte, error)
- func (ussl *UpdateServiceStorageLocal) GetPublicKey(proto string, key string) ([]byte, error)
- func (ussl *UpdateServiceStorageLocal) List(proto string, key string) ([]string, error)
- func (ussl *UpdateServiceStorageLocal) New(uri string, km string) (UpdateServiceStorage, error)
- func (ussl *UpdateServiceStorageLocal) Put(proto string, key string, content []byte, method utils.EncryptMethod) (string, error)
- func (ussl *UpdateServiceStorageLocal) String() string
- func (ussl *UpdateServiceStorageLocal) Supported(uri string) bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorInvalidLocalLocalRepo occurs when a local url is invalid ErrorInvalidLocalLocalRepo = errors.New("Invalid local url") // ErrorEmptyLocalRepo occurs when a repo is empty ErrorEmptyLocalRepo = errors.New("LocalRepo is empty") // ErrorAppNotExist occurs when an app is not exist ErrorAppNotExist = errors.New("App is not exist") )
var ( // ErrorsUSSNotSupported occurs if a type is not supported ErrorsUSSNotSupported = errors.New("storage type is not supported") )
Functions ¶
func RegisterStorage ¶
func RegisterStorage(name string, f UpdateServiceStorage) error
RegisterStorage provides a way to dynamically register an implementation of a storage type.
If RegisterStorage is called twice with the same name if 'storage type' is nil, or if the name is blank, it panics.
Types ¶
type LocalRepo ¶
type LocalRepo struct {
Proto string
Path string
Namespace string
LocalRepository string
// contains filtered or unexported fields
}
LocalRepo reprensents a local repository
if LocalRepo is {
Proto: "protoA/VersionB",
Path: "/data",
Namespace: "containerops",
LocalRepository: "official",
}
add assume there are 'osX/archY/appA' and 'osX/archY/appB' files.
The local structure will be: /data
|_ protoA
|_ VersionB
|_ containerops
|_ official
| |_ meta.json
| |_ meta.sig
| |
| |_ target
| |_ hashOfappA
| |_ hashOfappB
|
|_ pub_key.pem
func NewLocalRepo ¶
NewLocalRepo gets repo by a proto, a local storage path and a url nr : "namespace/repository" or just 'namespace'
func NewLocalRepoWithKM ¶
NewLocalRepoWithKM gets repo by a proto, a local storage path, a url and
a keymanager url
nr : "namespace/repository" kmURL: nil means using the km repository defined in configuration
func (LocalRepo) GetMetaFile ¶
GetMetaFile gets the meta data file url of repository
func (LocalRepo) GetMetaSignFile ¶
GetMetaSignFile gets the meta signature file url of repository
func (LocalRepo) GetPublicKeyFile ¶
GetPublicKeyFile gets the public key file url of repository
type UpdateServiceStorage ¶
type UpdateServiceStorage interface {
// `url` is the database address or local directory (/tmp/cache)
// `km` is the key manager address
New(url string, km string) (UpdateServiceStorage, error)
// get the 'url' set by 'New'
String() string
Supported(url string) bool
// `protocal` is the supported protocals like 'app/v1, docker/v1'
// key: namespace/repository/appname
Get(protocal, key string) ([]byte, error)
// key: namespace/repository
GetMeta(protocal, key string) ([]byte, error)
// key: namespace/repository
GetMetaSign(protocal, key string) ([]byte, error)
// key: namespace
// We don't provide GetPrivateKeyFile since we don't save it on the storage server
GetPublicKey(protocal, key string) ([]byte, error)
// key: namespace/repository/appname
Put(protocal, key string, data []byte, method utils.EncryptMethod) (string, error)
// key: namespace/repository/appname
Delete(protocal, key string) error
// key: namespace/repository
List(protocal, key string) ([]string, error)
}
UpdateServiceStorage represents the storage interface
func NewUpdateServiceStorage ¶
func NewUpdateServiceStorage(url string, km string) (UpdateServiceStorage, error)
NewUpdateServiceStorage creates a storage interface by a url
type UpdateServiceStorageLocal ¶
type UpdateServiceStorageLocal struct {
Path string
// contains filtered or unexported fields
}
UpdateServiceStorageLocal is the local file implementation of storage service
func (*UpdateServiceStorageLocal) Delete ¶
func (ussl *UpdateServiceStorageLocal) Delete(proto string, key string) error
Delete removes a file by a key. Key is "namespace/repositoryi/os/arch/appname"
func (*UpdateServiceStorageLocal) Get ¶
func (ussl *UpdateServiceStorageLocal) Get(proto string, key string) ([]byte, error)
Get the data of an input key. Key is "namespace/repository/os/arch/appname"
func (*UpdateServiceStorageLocal) GetMeta ¶
func (ussl *UpdateServiceStorageLocal) GetMeta(proto string, key string) ([]byte, error)
GetMeta gets the metadata of an input key. Key is "namespace/repository"
func (*UpdateServiceStorageLocal) GetMetaSign ¶
func (ussl *UpdateServiceStorageLocal) GetMetaSign(proto string, key string) ([]byte, error)
GetMetaSign gets the meta signature data. Key is "namespace/repository"
func (*UpdateServiceStorageLocal) GetPublicKey ¶
func (ussl *UpdateServiceStorageLocal) GetPublicKey(proto string, key string) ([]byte, error)
GetPublicKey gets the public key data. Key is "namespace"
func (*UpdateServiceStorageLocal) List ¶
func (ussl *UpdateServiceStorageLocal) List(proto string, key string) ([]string, error)
List lists the content of a key. Key is "namespace/repository"
func (*UpdateServiceStorageLocal) New ¶
func (ussl *UpdateServiceStorageLocal) New(uri string, km string) (UpdateServiceStorage, error)
New creates an UpdateServceStorage interface with a local implmentation
func (*UpdateServiceStorageLocal) Put ¶
func (ussl *UpdateServiceStorageLocal) Put(proto string, key string, content []byte, method utils.EncryptMethod) (string, error)
Put adds a file with a key. Key is "namespace/repository/os/arch/appname"
func (*UpdateServiceStorageLocal) String ¶
func (ussl *UpdateServiceStorageLocal) String() string
String returns 'Path'
func (*UpdateServiceStorageLocal) Supported ¶
func (ussl *UpdateServiceStorageLocal) Supported(uri string) bool
Supported checks if a uri is a local path