示例#1
0
func RunMockRegistry() *httptest.Server {
	mu.Lock()
	defer mu.Unlock()

	if testHttpServer != nil {
		return testHttpServer
	}

	r := mux.NewRouter()
	r.HandleFunc("/v1/images/{image_id:[^/]+}/{data_type:json|layer|ancestry}", handlerImage).Methods("GET")
	r.HandleFunc("/v1/repositories/{repository:.+}/tags", handlerTags).Methods("GET")
	r.HandleFunc("/v1/repositories/{repository:.+}/images", handlerImages).Methods("GET")

	testHttpServer = httptest.NewServer(logHandler(r))
	return testHttpServer
}
示例#2
0
func RunMockRegistry() *httptest.Server {
	mu.Lock()
	defer mu.Unlock()

	if testHttpServer != nil {
		return testHttpServer
	}

	r := mux.NewRouter()

	r.HandleFunc("/token", handlerToken).Methods("GET")
	r.HandleFunc("/v2", handlerSupport).Methods("GET")
	r.HandleFunc("/v2/{repo:[^/]+}/{image_name:[^/]+}/manifests/{image_ref:[^/]+}", handlerImageManifest).Methods("GET")
	r.HandleFunc("/v2/{repo:[^/]+}/{image_name:[^/]+}/blobs/{blob_ref:[^/]+}", handlerBlob).Methods("GET")

	testHttpServer = httptest.NewServer(logHandler(r))
	return testHttpServer
}