Skip to content

Commit

Permalink
bump to master
Browse files Browse the repository at this point in the history
  • Loading branch information
vieux committed Jun 5, 2013
2 parents b6825f9 + 04050c4 commit c906239
Show file tree
Hide file tree
Showing 31 changed files with 544 additions and 536 deletions.
72 changes: 36 additions & 36 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
)

const API_VERSION = 1.2
const APIVERSION = 1.2

func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
conn, _, err := w.(http.Hijacker).Hijack()
Expand Down Expand Up @@ -52,7 +52,7 @@ func httpError(w http.ResponseWriter, err error) {
}
}

func writeJson(w http.ResponseWriter, b []byte) {
func writeJSON(w http.ResponseWriter, b []byte) {
w.Header().Set("Content-Type", "application/json")
w.Write(b)
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reques
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -118,11 +118,11 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque
}
}
if status != "" {
b, err := json.Marshal(&ApiAuth{Status: status})
b, err := json.Marshal(&APIAuth{Status: status})
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}
w.WriteHeader(http.StatusNoContent)
Expand All @@ -135,7 +135,7 @@ func getVersion(srv *Server, version float64, w http.ResponseWriter, r *http.Req
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -164,7 +164,7 @@ func getContainersExport(srv *Server, version float64, w http.ResponseWriter, r
return nil
}

func getImagesJson(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func getImagesJSON(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return err
}
Expand All @@ -183,7 +183,7 @@ func getImagesJson(srv *Server, version float64, w http.ResponseWriter, r *http.
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand All @@ -200,7 +200,7 @@ func getInfo(srv *Server, version float64, w http.ResponseWriter, r *http.Reques
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand All @@ -217,7 +217,7 @@ func getImagesHistory(srv *Server, version float64, w http.ResponseWriter, r *ht
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand All @@ -234,11 +234,11 @@ func getContainersChanges(srv *Server, version float64, w http.ResponseWriter, r
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

func getContainersJson(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := parseForm(r); err != nil {
return err
}
Expand All @@ -258,7 +258,7 @@ func getContainersJson(srv *Server, version float64, w http.ResponseWriter, r *h
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -301,12 +301,12 @@ func postCommit(srv *Server, version float64, w http.ResponseWriter, r *http.Req
if err != nil {
return err
}
b, err := json.Marshal(&ApiId{id})
b, err := json.Marshal(&APIID{id})
if err != nil {
return err
}
w.WriteHeader(http.StatusCreated)
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -360,7 +360,7 @@ func getImagesSearch(srv *Server, version float64, w http.ResponseWriter, r *htt
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand All @@ -379,18 +379,18 @@ func postImagesInsert(srv *Server, version float64, w http.ResponseWriter, r *ht
w.Header().Set("Content-Type", "application/json")
}
sf := utils.NewStreamFormatter(version > 1.0)
imgId, err := srv.ImageInsert(name, url, path, w, sf)
imgID, err := srv.ImageInsert(name, url, path, w, sf)
if err != nil {
if sf.Used() {
w.Write(sf.FormatError(err))
return nil
}
}
b, err := json.Marshal(&ApiId{Id: imgId})
b, err := json.Marshal(&APIID{ID: imgID})
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -440,8 +440,8 @@ func postContainersCreate(srv *Server, version float64, w http.ResponseWriter, r
return err
}

out := &ApiRun{
Id: id,
out := &APIRun{
ID: id,
}
if config.Memory > 0 && !srv.runtime.capabilities.MemoryLimit {
log.Println("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.")
Expand All @@ -456,7 +456,7 @@ func postContainersCreate(srv *Server, version float64, w http.ResponseWriter, r
return err
}
w.WriteHeader(http.StatusCreated)
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -553,11 +553,11 @@ func postContainersWait(srv *Server, version float64, w http.ResponseWriter, r *
if err != nil {
return err
}
b, err := json.Marshal(&ApiWait{StatusCode: status})
b, err := json.Marshal(&APIWait{StatusCode: status})
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -644,7 +644,7 @@ func getContainersByName(srv *Server, version float64, w http.ResponseWriter, r
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand All @@ -662,30 +662,30 @@ func getImagesByName(srv *Server, version float64, w http.ResponseWriter, r *htt
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

func postImagesGetCache(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
apiConfig := &ApiImageConfig{}
apiConfig := &APIImageConfig{}
if err := json.NewDecoder(r.Body).Decode(apiConfig); err != nil {
return err
}

image, err := srv.ImageGetCached(apiConfig.Id, apiConfig.Config)
image, err := srv.ImageGetCached(apiConfig.ID, apiConfig.Config)
if err != nil {
return err
}
if image == nil {
w.WriteHeader(http.StatusNotFound)
return nil
}
apiId := &ApiId{Id: image.Id}
b, err := json.Marshal(apiId)
apiID := &APIID{ID: image.ID}
b, err := json.Marshal(apiID)
if err != nil {
return err
}
writeJson(w, b)
writeJSON(w, b)
return nil
}

Expand Down Expand Up @@ -731,13 +731,13 @@ func ListenAndServe(addr string, srv *Server, logging bool) error {
"/auth": getAuth,
"/version": getVersion,
"/info": getInfo,
"/images/json": getImagesJson,
"/images/json": getImagesJSON,
"/images/viz": getImagesViz,
"/images/search": getImagesSearch,
"/images/{name:.*}/history": getImagesHistory,
"/images/{name:.*}/json": getImagesByName,
"/containers/ps": getContainersJson,
"/containers/json": getContainersJson,
"/containers/ps": getContainersJSON,
"/containers/json": getContainersJSON,
"/containers/{name:.*}/export": getContainersExport,
"/containers/{name:.*}/changes": getContainersChanges,
"/containers/{name:.*}/json": getContainersByName,
Expand Down Expand Up @@ -786,9 +786,9 @@ func ListenAndServe(addr string, srv *Server, logging bool) error {
}
version, err := strconv.ParseFloat(mux.Vars(r)["version"], 64)
if err != nil {
version = API_VERSION
version = APIVERSION
}
if version == 0 || version > API_VERSION {
if version == 0 || version > APIVERSION {
w.WriteHeader(http.StatusNotFound)
return
}
Expand Down
36 changes: 18 additions & 18 deletions api_params.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package docker

type ApiHistory struct {
Id string
type APIHistory struct {
ID string `json:"Id"`
Created int64
CreatedBy string `json:",omitempty"`
}

type ApiImages struct {
type APIImages struct {
Repository string `json:",omitempty"`
Tag string `json:",omitempty"`
Id string
ID string `json:"Id"`
Created int64
}

type ApiInfo struct {
type APIInfo struct {
Debug bool
Containers int
Images int
Expand All @@ -23,48 +23,48 @@ type ApiInfo struct {
SwapLimit bool `json:",omitempty"`
}

type ApiContainers struct {
Id string
type APIContainers struct {
ID string `json:"Id"`
Image string
Command string
Created int64
Status string
Ports string
}

type ApiSearch struct {
type APISearch struct {
Name string
Description string
}

type ApiId struct {
Id string
type APIID struct {
ID string `json:"Id"`
}

type ApiRun struct {
Id string
type APIRun struct {
ID string `json:"Id"`
Warnings []string `json:",omitempty"`
}

type ApiPort struct {
type APIPort struct {
Port string
}

type ApiVersion struct {
type APIVersion struct {
Version string
GitCommit string `json:",omitempty"`
GoVersion string `json:",omitempty"`
}

type ApiWait struct {
type APIWait struct {
StatusCode int
}

type ApiAuth struct {
type APIAuth struct {
Status string
}

type ApiImageConfig struct {
Id string
type APIImageConfig struct {
ID string `json:"Id"`
*Config
}
Loading

0 comments on commit c906239

Please sign in to comment.