Skip to content

Commit

Permalink
Unify Godoc formatting, fix various typos
Browse files Browse the repository at this point in the history
Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
  • Loading branch information
VojtechVitek committed Sep 2, 2014
1 parent 7b44f88 commit 59f58cd
Show file tree
Hide file tree
Showing 58 changed files with 241 additions and 243 deletions.
6 changes: 3 additions & 3 deletions pkg/api/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import (
)

// codec defines methods for serializing and deserializing API
// objects
// objects.
type codec interface {
Encode(obj interface{}) (data []byte, err error)
Decode(data []byte) (interface{}, error)
DecodeInto(data []byte, obj interface{}) error
}

// resourceVersioner provides methods for setting and retrieving
// the resource version from an API object
// the resource version from an API object.
type resourceVersioner interface {
SetResourceVersion(obj interface{}, version uint64) error
ResourceVersion(obj interface{}) (uint64, error)
Expand Down Expand Up @@ -187,7 +187,7 @@ func Encode(obj interface{}) (data []byte, err error) {
return conversionScheme.Encode(obj)
}

// Ensures that obj is a pointer of some sort. Returns a reflect.Value of the
// enforcePtr ensures that obj is a pointer of some sort. Returns a reflect.Value of the
// dereferenced pointer, ensuring that it is settable/addressable.
// Returns an error if this is not possible.
func enforcePtr(obj interface{}) (reflect.Value, error) {
Expand Down
14 changes: 7 additions & 7 deletions pkg/api/jsonbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"reflect"
)

// NewJSONBaseVersioner returns a resourceVersioner that can set or retrieve
// ResourceVersion on objects derived from JSONBase.
// NewJSONBaseResourceVersioner returns a resourceVersioner that can set or
// retrieve ResourceVersion on objects derived from JSONBase.
func NewJSONBaseResourceVersioner() resourceVersioner {
return &jsonBaseResourceVersioner{}
}
Expand All @@ -46,7 +46,7 @@ func (v jsonBaseResourceVersioner) SetResourceVersion(obj interface{}, version u
return nil
}

// JSONBase lets you work with a JSONBase from any of the versioned or
// JSONBaseInterface lets you work with a JSONBase from any of the versioned or
// internal APIObjects.
type JSONBaseInterface interface {
ID() string
Expand Down Expand Up @@ -98,9 +98,9 @@ func (g genericJSONBase) SetResourceVersion(version uint64) {
*g.resourceVersion = version
}

// fieldPtr puts the address address of fieldName, which must be a member of v,
// into dest, which must be an address of a variable to which this field's address
// can be assigned.
// fieldPtr puts the address of fieldName, which must be a member of v,
// into dest, which must be an address of a variable to which this field's
// address can be assigned.
func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
field := v.FieldByName(fieldName)
if !field.IsValid() {
Expand All @@ -123,7 +123,7 @@ func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
return fmt.Errorf("Couldn't assign/convert %v to %v", field.Type(), v.Type())
}

// newGenericJSONBase makes a new generic JSONBase from v, which must be an
// newGenericJSONBase creates a new generic JSONBase from v, which must be an
// addressable/setable reflect.Value having the same fields as api.JSONBase.
// Returns an error if this isn't the case.
func newGenericJSONBase(v reflect.Value) (genericJSONBase, error) {
Expand Down
34 changes: 17 additions & 17 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ type VolumeSource struct {
EmptyDirectory *EmptyDirectory `yaml:"emptyDir" json:"emptyDir"`
}

// Bare host directory volume.
// HostDirectory represents bare host directory volume.
type HostDirectory struct {
Path string `yaml:"path" json:"path"`
}

type EmptyDirectory struct{}

// Port represents a network port in a single container
// Port represents a network port in a single container.
type Port struct {
// Optional: If specified, this must be a DNS_LABEL. Each named port
// in a pod must have a unique name.
Expand All @@ -109,7 +109,7 @@ type Port struct {
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
}

// VolumeMount describes a mounting of a Volume within a container
// VolumeMount describes a mounting of a Volume within a container.
type VolumeMount struct {
// Required: This must match the Name of a Volume [above].
Name string `yaml:"name" json:"name"`
Expand All @@ -119,7 +119,7 @@ type VolumeMount struct {
MountPath string `yaml:"mountPath,omitempty" json:"mountPath,omitempty"`
}

// EnvVar represents an environment variable present in a Container
// EnvVar represents an environment variable present in a Container.
type EnvVar struct {
// Required: This must be a C_IDENTIFIER.
Name string `yaml:"name" json:"name"`
Expand All @@ -137,7 +137,7 @@ type HTTPGetProbe struct {
Host string `yaml:"host,omitempty" json:"host,omitempty"`
}

// TCPSocketProbe describes a liveness probe based on opening a socket
// TCPSocketProbe describes a liveness probe based on opening a socket.
type TCPSocketProbe struct {
// Required: Port to connect to.
Port util.IntOrString `yaml:"port,omitempty" json:"port,omitempty"`
Expand All @@ -148,7 +148,7 @@ type ExecProbe struct {
// Command is the command line to execute inside the container, the working directory for the
// command is root ('/') in the container's filesystem. The command is simply exec'd, it is
// not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use
// a shell, you need to explicitly call out to that shell
// a shell, you need to explicitly call out to that shell.
Command []string `yaml:"command,omitempty" json:"command,omitempty"`
}

Expand Down Expand Up @@ -187,7 +187,7 @@ type Container struct {
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
}

// Event is the representation of an event logged to etcd backends
// Event is the representation of an event logged to etcd backends.
type Event struct {
Event string `json:"event,omitempty"`
Manifest *ContainerManifest `json:"manifest,omitempty"`
Expand All @@ -197,7 +197,7 @@ type Event struct {

// The below types are used by kube_client and api_server.

// JSONBase is shared by all objects sent to, or returned from the client
// JSONBase is shared by all objects sent to, or returned from the client.
type JSONBase struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Expand Down Expand Up @@ -238,7 +238,7 @@ type RestartPolicy struct {
Type RestartPolicyType `yaml:"type,omitempty" json:"type,omitempty"`
}

// PodState is the state of a pod, used as either input (desired state) or output (current state)
// PodState is the state of a pod, used as either input (desired state) or output (current state).
type PodState struct {
Manifest ContainerManifest `json:"manifest,omitempty" yaml:"manifest,omitempty"`
Status PodStatus `json:"status,omitempty" yaml:"status,omitempty"`
Expand All @@ -262,15 +262,15 @@ type PodList struct {
Items []Pod `json:"items" yaml:"items,omitempty"`
}

// Pod is a collection of containers, used as either input (create, update) or as output (list, get)
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
type Pod struct {
JSONBase `json:",inline" yaml:",inline"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
}

// ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get)
// ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get).
type ReplicationControllerState struct {
Replicas int `json:"replicas" yaml:"replicas"`
ReplicaSelector map[string]string `json:"replicaSelector,omitempty" yaml:"replicaSelector,omitempty"`
Expand All @@ -283,20 +283,20 @@ type ReplicationControllerList struct {
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
}

// ReplicationController represents the configuration of a replication controller
// ReplicationController represents the configuration of a replication controller.
type ReplicationController struct {
JSONBase `json:",inline" yaml:",inline"`
DesiredState ReplicationControllerState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
}

// PodTemplate holds the information used for creating pods
// PodTemplate holds the information used for creating pods.
type PodTemplate struct {
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
}

// ServiceList holds a list of services
// ServiceList holds a list of services.
type ServiceList struct {
JSONBase `json:",inline" yaml:",inline"`
Items []Service `json:"items" yaml:"items"`
Expand Down Expand Up @@ -421,7 +421,7 @@ const (
// Status code 202
StatusReasonWorking StatusReason = "working"

// ResourceTypeNotFound means one or more resources required for this operation
// StatusReasonNotFound means one or more resources required for this operation
// could not be found.
// Details (optional):
// "kind" string - the kind attribute of the missing resource
Expand All @@ -438,14 +438,14 @@ const (
// Status code 409
StatusReasonAlreadyExists StatusReason = "already_exists"

// ResourceTypeConflict means the requested update operation cannot be completed
// StatusReasonConflict means the requested update operation cannot be completed
// due to a conflict in the operation. The client may need to alter the request.
// Each resource may define custom details that indicate the nature of the
// conflict.
// Status code 409
StatusReasonConflict StatusReason = "conflict"

// ResourceTypeInvalid means the requested create or update operation cannot be
// StatusReasonInvalid means the requested create or update operation cannot be
// completed due to invalid data provided as part of the request. The client may
// need to alter the request. When set, the client may use the StatusDetails
// message field as a summary of the issues encountered.
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1beta1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta1 is the v1beta1 version of the API
// Package v1beta1 is the v1beta1 version of the API.
package v1beta1
34 changes: 17 additions & 17 deletions pkg/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ type VolumeSource struct {
EmptyDirectory *EmptyDirectory `yaml:"emptyDir" json:"emptyDir"`
}

// Bare host directory volume.
// HostDirectory represents bare host directory volume.
type HostDirectory struct {
Path string `yaml:"path" json:"path"`
}

type EmptyDirectory struct{}

// Port represents a network port in a single container
// Port represents a network port in a single container.
type Port struct {
// Optional: If specified, this must be a DNS_LABEL. Each named port
// in a pod must have a unique name.
Expand All @@ -109,7 +109,7 @@ type Port struct {
HostIP string `yaml:"hostIP,omitempty" json:"hostIP,omitempty"`
}

// VolumeMount describes a mounting of a Volume within a container
// VolumeMount describes a mounting of a Volume within a container.
type VolumeMount struct {
// Required: This must match the Name of a Volume [above].
Name string `yaml:"name" json:"name"`
Expand All @@ -125,7 +125,7 @@ type VolumeMount struct {
MountType string `yaml:"mountType,omitempty" json:"mountType,omitempty"`
}

// EnvVar represents an environment variable present in a Container
// EnvVar represents an environment variable present in a Container.
type EnvVar struct {
// Required: This must be a C_IDENTIFIER.
// Exactly one of the following must be set. If both are set, prefer Name.
Expand All @@ -146,7 +146,7 @@ type HTTPGetProbe struct {
Host string `yaml:"host,omitempty" json:"host,omitempty"`
}

// TCPSocketProbe describes a liveness probe based on opening a socket
// TCPSocketProbe describes a liveness probe based on opening a socket.
type TCPSocketProbe struct {
// Required: Port to connect to.
Port util.IntOrString `yaml:"port,omitempty" json:"port,omitempty"`
Expand Down Expand Up @@ -197,7 +197,7 @@ type Container struct {
LivenessProbe *LivenessProbe `yaml:"livenessProbe,omitempty" json:"livenessProbe,omitempty"`
}

// Event is the representation of an event logged to etcd backends
// Event is the representation of an event logged to etcd backends.
type Event struct {
Event string `json:"event,omitempty"`
Manifest *ContainerManifest `json:"manifest,omitempty"`
Expand All @@ -207,7 +207,7 @@ type Event struct {

// The below types are used by kube_client and api_server.

// JSONBase is shared by all objects sent to, or returned from the client
// JSONBase is shared by all objects sent to, or returned from the client.
type JSONBase struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Expand Down Expand Up @@ -248,7 +248,7 @@ type RestartPolicy struct {
Type RestartPolicyType `yaml:"type,omitempty" json:"type,omitempty"`
}

// PodState is the state of a pod, used as either input (desired state) or output (current state)
// PodState is the state of a pod, used as either input (desired state) or output (current state).
type PodState struct {
Manifest ContainerManifest `json:"manifest,omitempty" yaml:"manifest,omitempty"`
Status PodStatus `json:"status,omitempty" yaml:"status,omitempty"`
Expand All @@ -272,15 +272,15 @@ type PodList struct {
Items []Pod `json:"items" yaml:"items,omitempty"`
}

// Pod is a collection of containers, used as either input (create, update) or as output (list, get)
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
type Pod struct {
JSONBase `json:",inline" yaml:",inline"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
CurrentState PodState `json:"currentState,omitempty" yaml:"currentState,omitempty"`
}

// ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get)
// ReplicationControllerState is the state of a replication controller, either input (create, update) or as output (list, get).
type ReplicationControllerState struct {
Replicas int `json:"replicas" yaml:"replicas"`
ReplicaSelector map[string]string `json:"replicaSelector,omitempty" yaml:"replicaSelector,omitempty"`
Expand All @@ -293,20 +293,20 @@ type ReplicationControllerList struct {
Items []ReplicationController `json:"items,omitempty" yaml:"items,omitempty"`
}

// ReplicationController represents the configuration of a replication controller
// ReplicationController represents the configuration of a replication controller.
type ReplicationController struct {
JSONBase `json:",inline" yaml:",inline"`
DesiredState ReplicationControllerState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
}

// PodTemplate holds the information used for creating pods
// PodTemplate holds the information used for creating pods.
type PodTemplate struct {
DesiredState PodState `json:"desiredState,omitempty" yaml:"desiredState,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
}

// ServiceList holds a list of services
// ServiceList holds a list of services.
type ServiceList struct {
JSONBase `json:",inline" yaml:",inline"`
Items []Service `json:"items" yaml:"items"`
Expand Down Expand Up @@ -369,9 +369,9 @@ type Status struct {
JSONBase `json:",inline" yaml:",inline"`
// One of: "success", "failure", "working" (for operations not yet completed)
Status string `json:"status,omitempty" yaml:"status,omitempty"`
// A human readable description of the status of this operation.
// A human-readable description of the status of this operation.
Message string `json:"message,omitempty" yaml:"message,omitempty"`
// A machine readable description of why this operation is in the
// A machine-readable description of why this operation is in the
// "failure" or "working" status. If this value is empty there
// is no information available. A Reason clarifies an HTTP status
// code but does not override it.
Expand Down Expand Up @@ -434,7 +434,7 @@ const (
// Status code 202
StatusReasonWorking StatusReason = "working"

// ResourceTypeNotFound means one or more resources required for this operation
// StatusReasonNotFound means one or more resources required for this operation
// could not be found.
// Details (optional):
// "kind" string - the kind attribute of the missing resource
Expand All @@ -451,7 +451,7 @@ const (
// Status code 409
StatusReasonAlreadyExists StatusReason = "alreadyExists"

// ResourceTypeConflict means the requested update operation cannot be completed
// StatusReasonConflict means the requested update operation cannot be completed
// due to a conflict in the operation. The client may need to alter the request.
// Each resource may define custom details that indicate the nature of the
// conflict.
Expand Down
5 changes: 3 additions & 2 deletions pkg/api/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ func AccumulateUniquePorts(containers []Container, accumulator map[int]bool, ext
return allErrs
}

// Checks for colliding Port.HostPort values across a slice of containers.
// checkHostPortConflicts checks for colliding Port.HostPort values across
// a slice of containers.
func checkHostPortConflicts(containers []Container) errs.ErrorList {
allPorts := map[int]bool{}
return AccumulateUniquePorts(containers, allPorts, func(p *Port) int { return p.HostPort })
Expand Down Expand Up @@ -245,7 +246,7 @@ func ValidatePodState(podState *PodState) errs.ErrorList {
return allErrs
}

// Pod tests if required fields in the pod are set.
// ValidatePod tests if required fields in the pod are set.
func ValidatePod(pod *Pod) errs.ErrorList {
allErrs := errs.ErrorList{}
if len(pod.ID) == 0 {
Expand Down
Loading

0 comments on commit 59f58cd

Please sign in to comment.