Unify Godoc formatting, fix various typos

Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
This commit is contained in:
Vojtech Vitek (V-Teq)
2014-09-02 12:00:28 +02:00
parent 7b44f88c2b
commit 59f58cd043
58 changed files with 241 additions and 243 deletions

View File

@@ -31,8 +31,7 @@ import (
"github.com/golang/glog"
)
// Codec defines methods for serializing and deserializing API
// objects.
// Codec defines methods for serializing and deserializing API objects.
type Codec interface {
Encode(obj interface{}) (data []byte, err error)
Decode(data []byte) (interface{}, error)
@@ -117,7 +116,7 @@ func InstallSupport(mux mux) {
mux.HandleFunc("/", handleIndex)
}
// RecoverPanics wraps an http Handler to recover and log panics
// RecoverPanics wraps an http Handler to recover and log panics.
func RecoverPanics(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
defer func() {
@@ -142,12 +141,12 @@ func RecoverPanics(handler http.Handler) http.Handler {
})
}
// handleVersionReq writes the server's version information.
// handleVersion writes the server's version information.
func handleVersion(w http.ResponseWriter, req *http.Request) {
writeRawJSON(http.StatusOK, version.Get(), w)
}
// writeJSON renders an object as JSON to the response
// writeJSON renders an object as JSON to the response.
func writeJSON(statusCode int, codec Codec, object interface{}, w http.ResponseWriter) {
output, err := codec.Encode(object)
if err != nil {
@@ -159,7 +158,7 @@ func writeJSON(statusCode int, codec Codec, object interface{}, w http.ResponseW
w.Write(output)
}
// errorJSON renders an error to the response
// errorJSON renders an error to the response.
func errorJSON(err error, codec Codec, w http.ResponseWriter) {
status := errToAPIStatus(err)
writeJSON(status.Code, codec, status, w)
@@ -193,7 +192,7 @@ func readBody(req *http.Request) ([]byte, error) {
return ioutil.ReadAll(req.Body)
}
// splitPath returns the segments for a URL path
// splitPath returns the segments for a URL path.
func splitPath(path string) []string {
path = strings.Trim(path, "/")
if path == "" {

View File

@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Package apiserver contains the code that provides a RESTful api service
// Package apiserver contains the code that provides a RESTful api service.
package apiserver

View File

@@ -25,7 +25,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
)
// apiServerError is an error intended for consumption by a REST API server
// apiServerError is an error intended for consumption by a REST API server.
type apiServerError struct {
api.Status
}
@@ -49,7 +49,7 @@ func NewNotFoundErr(kind, name string) error {
}}
}
// NewAlreadyExistsErr returns an error indicating the item requested exists by that identifier
// NewAlreadyExistsErr returns an error indicating the item requested exists by that identifier.
func NewAlreadyExistsErr(kind, name string) error {
return &apiServerError{api.Status{
Status: api.StatusFailure,
@@ -77,7 +77,7 @@ func NewConflictErr(kind, name string, err error) error {
}}
}
// NewInvalidError returns an error indicating the item is invalid and cannot be processed.
// NewInvalidErr returns an error indicating the item is invalid and cannot be processed.
func NewInvalidErr(kind, name string, errs errors.ErrorList) error {
causes := make([]api.StatusCause, 0, len(errs))
for i := range errs {
@@ -102,7 +102,7 @@ func NewInvalidErr(kind, name string, errs errors.ErrorList) error {
}}
}
// IsNotFound returns true if the specified error was created by NewNotFoundErr
// IsNotFound returns true if the specified error was created by NewNotFoundErr.
func IsNotFound(err error) bool {
return reasonForError(err) == api.StatusReasonNotFound
}
@@ -112,12 +112,12 @@ func IsAlreadyExists(err error) bool {
return reasonForError(err) == api.StatusReasonAlreadyExists
}
// IsConflict determines if the err is an error which indicates the provided update conflicts
// IsConflict determines if the err is an error which indicates the provided update conflicts.
func IsConflict(err error) bool {
return reasonForError(err) == api.StatusReasonConflict
}
// IsInvalid determines if the err is an error which indicates the provided resource is not valid
// IsInvalid determines if the err is an error which indicates the provided resource is not valid.
func IsInvalid(err error) bool {
return reasonForError(err) == api.StatusReasonInvalid
}
@@ -154,13 +154,13 @@ func errToAPIStatus(err error) *api.Status {
}
}
// notFound renders a simple not found error
// notFound renders a simple not found error.
func notFound(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "Not Found: %#v", req.RequestURI)
}
// badGatewayError renders a simple bad gateway error
// badGatewayError renders a simple bad gateway error.
func badGatewayError(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusBadGateway)
fmt.Fprintf(w, "Bad Gateway: %#v", req.RequestURI)

View File

@@ -21,7 +21,7 @@ import (
"net/http"
)
// handleIndex is the root index page for Kubernetes
// handleIndex is the root index page for Kubernetes.
func handleIndex(w http.ResponseWriter, req *http.Request) {
if req.URL.Path != "/" && req.URL.Path != "/index.html" {
notFound(w, req)

View File

@@ -21,7 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
)
// RESTStorage is a generic interface for RESTful storage services
// RESTStorage is a generic interface for RESTful storage services.
// Resources which are exported to the RESTful API of apiserver need to implement this interface.
type RESTStorage interface {
// New returns an empty object that can be used with Create and Update after request data has been put into it.
@@ -56,7 +56,7 @@ type ResourceWatcher interface {
Watch(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
}
// Redirectors know how to return a remote resource's location.
// Redirector know how to return a remote resource's location.
type Redirector interface {
// ResourceLocation should return the remote location of the given resource, or an error.
ResourceLocation(id string) (remoteLocation string, err error)

View File

@@ -102,14 +102,14 @@ func (ops *Operations) NewOperation(from <-chan interface{}) *Operation {
return op
}
// Inserts op into the ops map.
// insert inserts op into the ops map.
func (ops *Operations) insert(op *Operation) {
ops.lock.Lock()
defer ops.lock.Unlock()
ops.ops[op.ID] = op
}
// List operations for an API client.
// List lists operations for an API client.
func (ops *Operations) List() api.ServerOpList {
ops.lock.Lock()
defer ops.lock.Unlock()
@@ -126,14 +126,14 @@ func (ops *Operations) List() api.ServerOpList {
return ol
}
// Get returns the operation with the given ID, or nil
// Get returns the operation with the given ID, or nil.
func (ops *Operations) Get(id string) *Operation {
ops.lock.Lock()
defer ops.lock.Unlock()
return ops.ops[id]
}
// Garbage collect operations that have finished longer than maxAge ago.
// expire garbage collect operations that have finished longer than maxAge ago.
func (ops *Operations) expire(maxAge time.Duration) {
ops.lock.Lock()
defer ops.lock.Unlock()
@@ -147,7 +147,7 @@ func (ops *Operations) expire(maxAge time.Duration) {
ops.ops = keep
}
// Waits forever for the operation to complete; call via go when
// wait waits forever for the operation to complete; call via go when
// the operation is created. Sets op.finished when the operation
// does complete, and closes the notify channel, in case there
// are any WaitFor() calls in progress.
@@ -173,7 +173,7 @@ func (op *Operation) WaitFor(timeout time.Duration) {
}
}
// Returns true if this operation finished before limitTime.
// expired returns true if this operation finished before limitTime.
func (op *Operation) expired(limitTime time.Time) bool {
op.lock.Lock()
defer op.lock.Unlock()

View File

@@ -157,7 +157,7 @@ func (h *RESTHandler) handleRESTStorage(parts []string, req *http.Request, w htt
}
}
// createOperation creates an operation to process a channel response
// createOperation creates an operation to process a channel response.
func (h *RESTHandler) createOperation(out <-chan interface{}, sync bool, timeout time.Duration) *Operation {
op := h.ops.NewOperation(out)
if sync {

View File

@@ -51,7 +51,7 @@ func getWatchParams(query url.Values) (label, field labels.Selector, resourceVer
return label, field, resourceVersion
}
// handleWatch processes a watch request
// ServeHTTP processes watch requests.
func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
parts := splitPath(req.URL.Path)
if len(parts) < 1 || req.Method != "GET" {