storage

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: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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

func NewLocalRepo(path string, proto string, nr string) (LocalRepo, error)

NewLocalRepo gets repo by a proto, a local storage path and a url nr : "namespace/repository" or just 'namespace'

func NewLocalRepoWithKM

func NewLocalRepoWithKM(path string, proto, nr string, kmURL string) (LocalRepo, error)

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) Delete

func (r LocalRepo) Delete(name string) error

Delete removes an application from a repository

func (LocalRepo) Get

func (r LocalRepo) Get(name string) ([]byte, error)

Get gets the data of an application

func (LocalRepo) GetMeta

func (r LocalRepo) GetMeta() ([]byte, error)

GetMeta gets the meta data of a repository

func (LocalRepo) GetMetaFile

func (r LocalRepo) GetMetaFile() string

GetMetaFile gets the meta data file url of repository

func (LocalRepo) GetMetaSignFile

func (r LocalRepo) GetMetaSignFile() string

GetMetaSignFile gets the meta signature file url of repository

func (LocalRepo) GetPublicKeyFile

func (r LocalRepo) GetPublicKeyFile() string

GetPublicKeyFile gets the public key file url of repository

func (LocalRepo) GetTopDir

func (r LocalRepo) GetTopDir() string

GetTopDir gets the top directory of a repository

func (LocalRepo) List

func (r LocalRepo) List() ([]string, error)

List lists the applications inside a repository

func (LocalRepo) Put

func (r LocalRepo) Put(name string, content []byte, method utils.EncryptMethod) (string, error)

Put adds an application to a repository

func (*LocalRepo) SetKM

func (r *LocalRepo) SetKM(kmURL string) error

SetKM sets the keymanager

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

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

Jump to

Keyboard shortcuts

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