Documentation ¶
Index ¶
- Constants
- Variables
- func GetObjectKey(object string, id string) string
- func GetServerKeys(object string) string
- func InitDb()
- func InitSession()
- func Log(object, json string) error
- type Image
- func (image *Image) Get(imageId, sign string) (bool, []byte, error)
- func (image *Image) GetAncestry(imageId, sign string, uploaded, checksumed bool) ([]byte, error)
- func (image *Image) GetChecksum(imageId, sign string, uploaded, checksumed bool) (string, error)
- func (image *Image) GetJSON(imageId, sign string, uploaded, checksumed bool) ([]byte, error)
- func (image *Image) GetPath(imageId, sign string, uploaded, checksumed bool) (string, error)
- func (image *Image) GetPushed(imageId, sign string, uploaded, checksumed bool) (bool, error)
- func (image *Image) GetSize(imageId, sign string, uploaded, checksumed bool) (int64, error)
- func (image *Image) PutAncestry(imageId, sign string) error
- func (image *Image) PutChecksum(imageId, sign, checksum string) error
- func (image *Image) PutChecksumed(imageId, sign string, checksumed bool) error
- func (image *Image) PutJSON(imageId, sign, json string) error
- func (image *Image) PutPath(imageId, sign, path string) error
- func (image *Image) PutPayload(imageId, sign, payload string) error
- func (image *Image) PutSize(imageId, sign string, size int64) error
- func (image *Image) PutUploaded(imageId, sign string, uploaded bool) error
- func (image *Image) Save(key []byte) error
- type Job
- type Organization
- func (org *Organization) AddPrivilege(name, user, repository string) error
- func (org *Organization) AddRepository(name, repository, key string) error
- func (org *Organization) AddUser(name, user, member string) error
- func (org *Organization) Has(name string) (bool, []byte, error)
- func (org *Organization) Put(user, name, description string) error
- func (org *Organization) RemovePrivilege(name, user, repository string) error
- func (org *Organization) RemoveRepository(name, repository string) error
- func (org *Organization) RemoveUser(name, user string) error
- func (org *Organization) Save(key []byte) error
- type Repository
- func (repo *Repository) Get(username, repository, organization, sign string) (bool, []byte, error)
- func (repo *Repository) GetJSON(username, repository, organization, sign string, uploaded, checksumed bool) ([]byte, error)
- func (repo *Repository) GetTags(username, repository, organization, sign string, uploaded, checksumed bool) ([]byte, error)
- func (repo *Repository) Has(key string) (bool, error)
- func (repo *Repository) PutAgent(username, repository, organization, sign, agent string) error
- func (repo *Repository) PutChecksumed(username, repository, organization, sign string, checksumed bool) error
- func (repo *Repository) PutJSON(username, repository, organization, sign, json string) error
- func (repo *Repository) PutSize(username, repository, organization, sign string) error
- func (repo *Repository) PutTag(username, repository, organization, sign, tag, imageId string) error
- func (repo *Repository) PutUploaded(username, repository, organization, sign string, uploaded bool) error
- func (repo *Repository) Save(key []byte) error
- type Tag
- type Template
- type User
- func (user *User) AddOrganization(username, org, member string) error
- func (user *User) AddRepository(username, repository, key string) error
- func (user *User) Get(username, passwd string) (bool, error)
- func (user *User) Has(username string) (bool, []byte, error)
- func (user *User) Put(username string, passwd string, email string) error
- func (user *User) RemoveOrganization(username, org string) error
- func (user *User) RemoveRepository(username, repository string) error
- func (user *User) ResetPasswd(username, password string) error
- func (user *User) Save(key []byte) error
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 InitSession ¶
func InitSession()
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) GetAncestry ¶
func (*Image) GetChecksum ¶
func (*Image) PutAncestry ¶
从 JSON 数据中解析查找是否存在 parent 的数据。 如果存在 parent 数据,根据 imageId 和 sign 查找 parent 的记录。 把当前 imageId 加入到 数组中在 Marshal 后保存在 Ancestry 中。 如果不存在 parent 数据,则认为当前 imageId 是 root 节点。
func (*Image) PutChecksum ¶
func (*Image) PutChecksumed ¶
func (*Image) PutPayload ¶
func (*Image) PutUploaded ¶
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 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 ¶
向用户添加 Organization 数据 member 的值为: ORG_MEMBER 或 ORG_OWNER
func (*User) AddRepository ¶
用户创建镜像仓库后,在 user 的 Repositories 字段保存相应的记录 repository 字段是 Repository 的全局 Key
func (*User) RemoveOrganization ¶
从用户中删除 Organization 数据
func (*User) RemoveRepository ¶
用户删除镜像仓库后,在 user 的 Repositories 中删除相应的记录
Click to show internal directories.
Click to hide internal directories.