controllers

package
v0.0.0-...-fca68c0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2014 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Docker Push & Pull

执行 docker push 命令流程:

  1. docker 向 registry 服务器注册 repository: PUT /v1/repositories/<username>/<repository> -> PUTRepository()
  2. 参数是 JSON 格式的 <repository> 所有 image 的 id 列表,按照 image 的构建顺序排列。
  3. 根据 <repository> 的 <tags> 进行循环: 3.1 获取 <image> 的 JSON 文件:GET /v1/images/<image_id>/json -> image.go#GETJSON() 3.2 如果没有此文件或内容返回 404 。 3.3 docker push 认为服务器没有 image 对应的文件,向服务器上传 image 相关文件。 3.3.1 写入 <image> 的 JSON 文件:PUT /v1/images/<image_id>/json -> image.go#PUTJSON() 3.3.2 写入 <image> 的 layer 文件:PUT /v1/images/<image_id>/layer -> image.go#PUTLayer() 3.3.3 写入 <image> 的 checksum 信息:PUT /v1/images/<image_id>/checksum -> image.go#PUTChecksum() 3.4 上传完此 tag 的所有 image 后,向服务器写入 tag 信息:PUT /v1/repositories/(namespace)/(repository)/tags/(tag) -> PUTTag()
  4. 所有 tags 的 image 上传完成后,向服务器发送所有 images 的校验信息,PUT /v1/repositories/(namespace)/(repo_name)/images -> PUTRepositoryImages()

执行 docker pull 命令流程:

  1. docker 访问 registry 服务器 repository 的 images 信息:GET /v1/repositories/<username>/<repository>/images -> GetRepositoryImages()
  2. docker 访问 registry 服务器 repository 的 tags 信息:GET /v1/repositoies/<username>/<repository>/tags -> GetRepositoryTags()
  3. 根据 <repository> 的 <tags> 中 image 信息进行循环: 3.1 获取 <image> 的 Ancestry 信息:GET /v1/images/<image_id>/ancestry -> GetImageAncestry() 3.2 获取 <image> 的 JSON 数据: GET /v1/images/<image_id>/json -> GetImageJson() 3.3 获取 <image> 的 Layer 文件: GET /v1/images/<image_id/layer -> GetImageLayer()

Docker Registry & Login 执行 docker login 命令流程:

  1. docker 向 registry 的服务器进行注册执行:POST /v1/users or /v1/users/ -> POSTUsers()
  2. 创建用户成功返回 201;提交的格式有误、无效的字段等返回 400;已经存在用户了返回 401。
  3. docker login 收到 401 的状态后,进行登录:GET /v1/users or /v1/users/ -> GETUsers()
  4. 在登录时,将用户名和密码进行 SetBasicAuth 处理,放到 HEADER 的 Authorization 中,例如:Authorization: Basic ZnNrOmZzaw==
  5. registry 收到登录的请求,Decode 请求 HEADER 中 Authorization 的部分进行判断。
  6. 用户名和密码正确返回 200;用户名密码错误返回 401;账户未激活返回 403 错误;其它错误返回 417 (Expectation Failed)

注:

Decode HEADER authorization function named decodeAuth in https://github.com/dotcloud/docker/blob/master/registry/auth.go.

更新 Docker Registry User 的属性:

  1. 调用 PUT /v1/users/(username)/ 向服务器更新 User 的 Email 和 Password 属性。
  2. 参数包括 User Email 或 User Password,或两者都包括。
  3. 更新成功返回 204;传递的参数不是有效的 JSON 格式等错误返回 400;认证失败返回 401;用户没有激活返回 403;没有用户现实 404。

注:

HTTP HEADER authorization decode 验证同 docker login 命令。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImageController

type ImageController struct {
	beego.Controller
}

func (*ImageController) GetImageAncestry

func (this *ImageController) GetImageAncestry()

func (*ImageController) GetImageJSON

func (this *ImageController) GetImageJSON()

在 Push 的流程中,docker 客户端会先调用 GET /v1/images/:image_id/json 向服务器检查是否已经存在 JSON 信息。 如果存在了 JSON 信息,docker 客户端就认为是已经存在了 layer 数据,不再向服务器 PUT layer 的 JSON 信息和文件了。 如果不存在 JSON 信息,docker 客户端会先后执行 PUT /v1/images/:image_id/json 和 PUT /v1/images/:image_id/layer 。

func (*ImageController) GetImageLayer

func (this *ImageController) GetImageLayer()

func (*ImageController) Prepare

func (this *ImageController) Prepare()

func (*ImageController) PutChecksum

func (this *ImageController) PutChecksum()

func (*ImageController) PutImageJson

func (this *ImageController) PutImageJson()

向数据库写入 Layer 的 JSON 数据 TODO: 检查 JSON 是否合法

func (*ImageController) PutImageLayer

func (this *ImageController) PutImageLayer()

向本地硬盘写入 Layer 的文件

func (*ImageController) URLMapping

func (i *ImageController) URLMapping()

type MainController

type MainController struct {
	beego.Controller
}

func (*MainController) Get

func (this *MainController) Get()

func (*MainController) Prepare

func (this *MainController) Prepare()

type PingController

type PingController struct {
	beego.Controller
}

func (*PingController) GetPing

func (this *PingController) GetPing()

func (*PingController) Prepare

func (this *PingController) Prepare()

type PingResult

type PingResult struct {
	Result bool
}

type RepositoryController

type RepositoryController struct {
	beego.Controller
}

func (*RepositoryController) GetRepositoryImages

func (this *RepositoryController) GetRepositoryImages()

func (*RepositoryController) GetRepositoryTags

func (this *RepositoryController) GetRepositoryTags()

func (*RepositoryController) Prepare

func (this *RepositoryController) Prepare()

func (*RepositoryController) PutRepository

func (this *RepositoryController) PutRepository()

func (*RepositoryController) PutRepositoryImages

func (this *RepositoryController) PutRepositoryImages()

根据最初上传的 Image 数据和每个 Image 的上传信息确定是否上传成功

func (*RepositoryController) PutTag

func (this *RepositoryController) PutTag()

func (*RepositoryController) URLMapping

func (r *RepositoryController) URLMapping()

type SearchController

type SearchController struct {
	beego.Controller
}

func (*SearchController) GET

func (this *SearchController) GET()

func (*SearchController) Prepare

func (this *SearchController) Prepare()

type StatusController

type StatusController struct {
	beego.Controller
}

func (*StatusController) GET

func (this *StatusController) GET()

func (*StatusController) Prepare

func (this *StatusController) Prepare()

type UsersController

type UsersController struct {
	beego.Controller
}

func (*UsersController) GetUsers

func (this *UsersController) GetUsers()

func (*UsersController) PostUsers

func (this *UsersController) PostUsers()

func (*UsersController) Prepare

func (this *UsersController) Prepare()

Jump to

Keyboard shortcuts

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