models

package
v0.0.0-...-b8fd4ec Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2014 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_SYMBLE         = "@"
	ORGANIZATION_SYMBLE = "#"
	REPOSITORY_SYMBLE   = "$"
	IMAGE_SYMBLE        = "&"
	TEMPLATE_SYMBLE     = "*"
	JOB_SYMBLE          = "!"
)
View Source
const (
	ORG_MEMBER = "M"
	ORG_OWNER  = "O"
)

Variables

View Source
var (
	LedisDB *ledis.DB
)

Functions

func GetObjectKey

func GetObjectKey(object string, id string) string

获取对象存储的 Key

func GetServerKeys

func GetServerKeys(object string) string

获取服务器全局存储的 Key 值

func InitDb

func InitDb()

InitDb initializes the database.

func InitSession

func InitSession()

func Log

func Log(object, json string) error

Types

type Image

type Image struct {
	ImageId    string //
	JSON       string //
	Ancestry   string //
	Checksum   string //
	Payload    string //
	URL        string //
	Backend    string //
	Path       string //文件在服务器的存储路径
	Sign       string //
	Size       int64  //
	Uploaded   bool   //
	Checksumed bool   //
	Encrypted  bool   //是否加密
	Created    int64  //
	Updated    int64  //
}

func (*Image) Get

func (image *Image) Get(imageId, sign string) (bool, []byte, error)

func (*Image) GetAncestry

func (image *Image) GetAncestry(imageId, sign string, uploaded, checksumed bool) ([]byte, error)

func (*Image) GetChecksum

func (image *Image) GetChecksum(imageId, sign string, uploaded, checksumed bool) (string, error)

func (*Image) GetJSON

func (image *Image) GetJSON(imageId, sign string, uploaded, checksumed bool) ([]byte, error)

func (*Image) GetPath

func (image *Image) GetPath(imageId, sign string, uploaded, checksumed bool) (string, error)

func (*Image) GetPushed

func (image *Image) GetPushed(imageId, sign string, uploaded, checksumed bool) (bool, error)

func (*Image) GetSize

func (image *Image) GetSize(imageId, sign string, uploaded, checksumed bool) (int64, error)

func (*Image) PutAncestry

func (image *Image) PutAncestry(imageId, sign string) error

从 JSON 数据中解析查找是否存在 parent 的数据。 如果存在 parent 数据,根据 imageId 和 sign 查找 parent 的记录。 把当前 imageId 加入到 数组中在 Marshal 后保存在 Ancestry 中。 如果不存在 parent 数据,则认为当前 imageId 是 root 节点。

func (*Image) PutChecksum

func (image *Image) PutChecksum(imageId, sign, checksum string) error

func (*Image) PutChecksumed

func (image *Image) PutChecksumed(imageId, sign string, checksumed bool) error

func (*Image) PutJSON

func (image *Image) PutJSON(imageId, sign, json string) error

func (*Image) PutPath

func (image *Image) PutPath(imageId, sign, path string) error

func (*Image) PutPayload

func (image *Image) PutPayload(imageId, sign, payload string) error

func (*Image) PutSize

func (image *Image) PutSize(imageId, sign string, size int64) error

func (*Image) PutUploaded

func (image *Image) PutUploaded(imageId, sign string, uploaded bool) error

func (*Image) Save

func (image *Image) Save(key []byte) error

type Job

type Job struct {
	User         string //
	Organization string //如果是 Organization ,存 Organization 的 ID
	Template     string //运行的模板和 tag
	Name         string //任务名称,为扩展 docker 命令准备。
	Title        string //任务名称,高级版本
	YAML         string //YAML 格式运行定义
	Description  string //描述
	Engine       string //运行 Template 的云服务器方面接口信息
	Created      int64  //
	Updated      int64  //
}

type Organization

type Organization struct {
	Owner        string //用户的 Key,每个组织都由用户创建,Owner 默认是拥有所有 Repository 的读写权限
	Name         string //
	Description  string //保存 Markdown 格式
	Repositories string //
	Privileges   string //
	Users        string //
	Created      int64  //
	Updated      int64  //
}

func (*Organization) AddPrivilege

func (org *Organization) AddPrivilege(name, user, repository string) error

为用户@镜像仓库添加读写权限

func (*Organization) AddRepository

func (org *Organization) AddRepository(name, repository, key string) error

向组织添加镜像仓库

func (*Organization) AddUser

func (org *Organization) AddUser(name, user, member string) error

向组织添加用户,member 参数的值为 OWNER/MEMBER 两种

func (*Organization) Has

func (org *Organization) Has(name string) (bool, []byte, error)

在全局 org 存储的的 Hash 中查询到 org 的 key,然后根据 key 再使用 Exists 方法查询是否存在数据

func (*Organization) Put

func (org *Organization) Put(user, name, description string) error

创建用户数据,如果存在返回错误信息。

func (*Organization) RemovePrivilege

func (org *Organization) RemovePrivilege(name, user, repository string) error

为用户@镜像仓库移除读写权限

func (*Organization) RemoveRepository

func (org *Organization) RemoveRepository(name, repository string) error

从组织移除镜像仓库

func (*Organization) RemoveUser

func (org *Organization) RemoveUser(name, user string) error

从组织移除用户

func (*Organization) Save

func (org *Organization) Save(key []byte) error

循环 Org 的所有 Property ,保存数据

type Repository

type Repository struct {
	Username     string //即用户名或 Organization 的 Name
	Repository   string //仓库名
	Organization string //如果是 Organization ,存 Organization 的 Key
	Description  string //保存 Markdown 格式
	JSON         string //Docker 客户端上传的 Images 信息,JSON 格式。
	Data         string //包含的 Image 信息集合,由 Image 的 ID 组成。
	Dockerfile   string //生产 Repository 的 Dockerfile 文件内容
	Agent        string //docker 命令产生的 agent 信息
	Links        string //保存 JSON 的信息,保存官方库的 Link,产生 repository 库的 Git 库地址
	Size         int64  //仓库所有 Image 的大小 byte
	Uploaded     bool   //上传完成标志
	Checksum     string //
	Checksumed   bool   //Checksum 检查标志
	Labels       string //用户设定的标签,和库的 Tag 是不一样
	Tags         string //
	Icon         string //
	Sign         string //
	Privated     bool   //私有 Repository
	Clear        string //对 Repository 进行了杀毒,杀毒的结果和 status 等信息以 JSON 格式保存
	Cleared      bool   //对 Repository 是否进行了杀毒处理
	Encrypted    bool   //是否加密
	Created      int64  //
	Updated      int64  //
}

func (*Repository) Get

func (repo *Repository) Get(username, repository, organization, sign string) (bool, []byte, error)

func (*Repository) GetJSON

func (repo *Repository) GetJSON(username, repository, organization, sign string, uploaded, checksumed bool) ([]byte, error)

func (*Repository) GetTags

func (repo *Repository) GetTags(username, repository, organization, sign string, uploaded, checksumed bool) ([]byte, error)

func (*Repository) Has

func (repo *Repository) Has(key string) (bool, error)

根据 Repository 的 key 判断是否存在 Repository 数据

func (*Repository) PutAgent

func (repo *Repository) PutAgent(username, repository, organization, sign, agent string) error

func (*Repository) PutChecksumed

func (repo *Repository) PutChecksumed(username, repository, organization, sign string, checksumed bool) error

func (*Repository) PutJSON

func (repo *Repository) PutJSON(username, repository, organization, sign, json string) error

func (*Repository) PutSize

func (repo *Repository) PutSize(username, repository, organization, sign string) error

func (*Repository) PutTag

func (repo *Repository) PutTag(username, repository, organization, sign, tag, imageId string) error

func (*Repository) PutUploaded

func (repo *Repository) PutUploaded(username, repository, organization, sign string, uploaded bool) error

func (*Repository) Save

func (repo *Repository) Save(key []byte) error

type Tag

type Tag struct {
	Name    string //
	ImageId string //
	Sign    string //
}

type Template

type Template struct {
	User         string //
	Organization string //如果是 Organization ,存 Organization 的 ID
	Name         string //模板名,为 docker 扩展 template 命令使用,docker tempalte docker.cn/docker/wordpress 运行 docker 用户的 wordpress 模板
	Tag          string //模板和 docker 使用相同的标签方案,user+name+tag 在数据表中唯一。
	Title        string //模板名称
	Description  string //Markdown
	Repositories string //模板使用的 repository 集合,使用 docker.cn/docker/golang 这样的全路径,多个 repository 之间 ; 分隔
	YAML         string // yaml 格式模板定义
	Links        string //保存 JSON 的信息,产生 template 库的 Git 库地址
	Size         int64  //使用的所有 repository 的 size 总和
	Labels       string //用户设定的标签,和库的 Tag 是不一样
	Icon         string //
	Privated     bool   //私有模板
	Created      int64  //
	Updated      int64  //
}

type User

type User struct {
	Username      string //
	Password      string //
	Repositories  string //用户的所有 Respository
	Organizations string //用户所属的所有组织
	Email         string //Email 可以更换,全局唯一
	Fullname      string //
	Company       string //
	Location      string //
	Mobile        string //
	URL           string //
	Gravatar      string //如果是邮件地址使用 gravatar.org 的 API 显示头像,如果是上传的用户显示头像的地址。
	Created       int64  //
	Updated       int64  //
}

func (*User) AddOrganization

func (user *User) AddOrganization(username, org, member string) error

向用户添加 Organization 数据 member 的值为: ORG_MEMBER 或 ORG_OWNER

func (*User) AddRepository

func (user *User) AddRepository(username, repository, key string) error

用户创建镜像仓库后,在 user 的 Repositories 字段保存相应的记录 repository 字段是 Repository 的全局 Key

func (*User) Get

func (user *User) Get(username, passwd string) (bool, error)

根据用户名和密码获取用户

func (*User) Has

func (user *User) Has(username string) (bool, []byte, error)

在全局 user 存储的的 Hash 中查询到 user 的 key,然后根据 key 再使用 Exists 方法查询是否存在数据

func (*User) Put

func (user *User) Put(username string, passwd string, email string) error

创建用户数据,如果存在返回错误信息。

func (*User) RemoveOrganization

func (user *User) RemoveOrganization(username, org string) error

从用户中删除 Organization 数据

func (*User) RemoveRepository

func (user *User) RemoveRepository(username, repository string) error

用户删除镜像仓库后,在 user 的 Repositories 中删除相应的记录

func (*User) ResetPasswd

func (user *User) ResetPasswd(username, password string) error

重置用户的密码

func (*User) Save

func (user *User) Save(key []byte) error

循环 User 的所有 Property ,保存数据

Jump to

Keyboard shortcuts

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