change iff to if and only if to improve annotation readability

This commit is contained in:
liguangbo 2015-09-15 10:25:13 +08:00
parent db128ac0f7
commit 4df68f03a3
20 changed files with 44 additions and 42 deletions

View File

@ -42,8 +42,8 @@ func PodMemLimit(pod *api.Pod) MegaBytes {
}
// limitPodResource sets the given default resource limit for each container that
// does not limit the given resource yet. limitPodResource returns true iff at least one
// container had no limit for that resource.
// does not limit the given resource yet. limitPodResource returns true if and only if
// at least one container had no limit for that resource.
func limitPodResource(pod *api.Pod, resourceName api.ResourceName, defaultLimit resource.Quantity) bool {
unlimited := false
for j := range pod.Spec.Containers {
@ -79,16 +79,16 @@ func unlimitedCountainerNum(pod *api.Pod, resourceName api.ResourceName) int {
}
// limitPodCPU sets DefaultContainerCPUs for the CPU limit of each container that
// does not limit its CPU resource yet. limitPodCPU returns true iff at least one
// container had no CPU limit set.
// does not limit its CPU resource yet. limitPodCPU returns true if and only if
// at least one container had no CPU limit set.
func LimitPodCPU(pod *api.Pod, defaultLimit CPUShares) bool {
defaultCPUQuantity := resource.NewMilliQuantity(int64(float64(defaultLimit)*1000.0), resource.DecimalSI)
return limitPodResource(pod, api.ResourceCPU, *defaultCPUQuantity)
}
// limitPodMem sets DefaultContainerMem for the memory limit of each container that
// does not limit its memory resource yet. limitPodMem returns true iff at least one
// container had no memory limit set.
// does not limit its memory resource yet. limitPodMem returns true if and only if
// at least one container had no memory limit set.
func LimitPodMem(pod *api.Pod, defaultLimit MegaBytes) bool {
defaultMemQuantity := resource.NewQuantity(int64(float64(defaultLimit)*1024.0*1024.0), resource.BinarySI)
return limitPodResource(pod, api.ResourceMemory, *defaultMemQuantity)

View File

@ -37,8 +37,8 @@ function generate_version() {
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser. (e.g. TODO(andronat):... || TODO:...) iff
// are on one line! For multiple line or blocks that you want to ignore use ---.
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh

View File

@ -27,8 +27,8 @@ import (
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser. (e.g. TODO(andronat):... || TODO:...) iff
// are on one line! For multiple line or blocks that you want to ignore use ---.
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored and not exported to the SwaggerAPI.
//
// The aforementioned methods can be generated by hack/update-generated-swagger-docs.sh

View File

@ -20,8 +20,8 @@ package v1
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser. (e.g. TODO(andronat):... || TODO:...) iff
// are on one line! For multiple line or blocks that you want to ignore use ---.
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh

View File

@ -20,8 +20,8 @@ package v1
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser. (e.g. TODO(andronat):... || TODO:...) iff
// are on one line! For multiple line or blocks that you want to ignore use ---.
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh

View File

@ -73,7 +73,7 @@ func (c *ExpirationCache) getTimestampedEntry(key string) (*timestampedEntry, bo
return nil, false
}
// getOrExpire retrieves the object from the timestampedEntry iff it hasn't
// getOrExpire retrieves the object from the timestampedEntry if and only if it hasn't
// already expired. It kicks-off a go routine to delete expired objects from
// the store and sets exists=false.
func (c *ExpirationCache) getOrExpire(key string) (interface{}, bool) {

View File

@ -249,7 +249,8 @@ func (s *StoreToDaemonSetLister) List() (dss []experimental.DaemonSet, err error
return dss, nil
}
// GetPodDaemonSets returns a list of daemon sets managing a pod. Returns an error iff no matching daemon sets are found.
// GetPodDaemonSets returns a list of daemon sets managing a pod.
// Returns an error if and only if no matching daemon sets are found.
func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []experimental.DaemonSet, err error) {
var selector labels.Selector
var daemonSet experimental.DaemonSet

View File

@ -21,8 +21,8 @@ import (
"k8s.io/kubernetes/pkg/util/wait"
)
// ControllerHasDesiredReplicas returns a condition that will be true iff the desired replica count
// for a controller's ReplicaSelector equals the Replicas count.
// ControllerHasDesiredReplicas returns a condition that will be true if and only if
// the desired replica count for a controller's ReplicaSelector equals the Replicas count.
func ControllerHasDesiredReplicas(c Interface, controller *api.ReplicationController) wait.ConditionFunc {
// If we're given a controller where the status lags the spec, it either means that the controller is stale,

View File

@ -508,7 +508,7 @@ func DefaultServerURL(host, prefix, version string, defaultTLS bool) (*url.URL,
return hostURL, nil
}
// IsConfigTransportTLS returns true iff the provided config will result in a protected
// IsConfigTransportTLS returns true if and only if the provided config will result in a protected
// connection to the server when it is passed to client.New() or client.RESTClientFor().
// Use to determine when to send credentials over the wire.
//

View File

@ -1413,7 +1413,7 @@ func isEqualIPPermission(l, r *ec2.IPPermission, compareGroupUserIDs bool) bool
}
// Makes sure the security group includes the specified permissions
// Returns true iff changes were made
// Returns true if and only if changes were made
// The security group must already exist
func (s *AWSCloud) ensureSecurityGroupIngress(securityGroupId string, addPermissions []*ec2.IPPermission) (bool, error) {
group, err := s.findSecurityGroup(securityGroupId)
@ -1467,7 +1467,7 @@ func (s *AWSCloud) ensureSecurityGroupIngress(securityGroupId string, addPermiss
}
// Makes sure the security group no longer includes the specified permissions
// Returns true iff changes were made
// Returns true if and only if changes were made
// If the security group no longer exists, will return (false, nil)
func (s *AWSCloud) removeSecurityGroupIngress(securityGroupId string, removePermissions []*ec2.IPPermission) (bool, error) {
group, err := s.findSecurityGroup(securityGroupId)

View File

@ -44,7 +44,8 @@ type Scheme struct {
// deep copy behavior.
cloner *Cloner
// Indent will cause the JSON output from Encode to be indented, iff it is true.
// Indent will cause the JSON output from Encode to be indented,
// if and only if it is true.
Indent bool
// InternalVersion is the default internal version. It is recommended that

View File

@ -92,8 +92,8 @@ func (s *sourceFile) extractFromPath() error {
return nil
}
// Get as many pod configs as we can from a directory. Return an error iff something
// prevented us from reading anything at all. Do not return an error if only some files
// Get as many pod configs as we can from a directory. Return an error if and only if something
// prevented us from reading anything at all. Do not return an error if only some files
// were problematic.
func (s *sourceFile) extractFromDir(name string) ([]*api.Pod, error) {
dirents, err := filepath.Glob(filepath.Join(name, "[^.]*"))

View File

@ -1532,7 +1532,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
// Structure keeping information on changes that need to happen for a pod. The semantics is as follows:
// - startInfraContainer is true if new Infra Containers have to be started and old one (if running) killed.
// Additionally if it is true then containersToKeep have to be empty
// - infraContainerId have to be set iff startInfraContainer is false. It stores dockerID of running Infra Container
// - infraContainerId have to be set if and only if startInfraContainer is false. It stores dockerID of running Infra Container
// - containersToStart keeps indices of Specs of containers that have to be started.
// - containersToKeep stores mapping from dockerIDs of running containers to indices of their Specs for containers that
// should be kept running. If startInfraContainer is false then it contains an entry for infraContainerId (mapped to -1).

View File

@ -47,7 +47,7 @@ func (s *SelectionPredicate) Matches(obj runtime.Object) (bool, error) {
return s.Label.Matches(labels) && s.Field.Matches(fields), nil
}
// MatchesSingle will return (name, true) iff s.Field matches on the object's
// MatchesSingle will return (name, true) if and only if s.Field matches on the object's
// name.
func (s *SelectionPredicate) MatchesSingle() (string, bool) {
// TODO: should be namespace.name

View File

@ -150,8 +150,8 @@ func (r *BindingREST) Create(ctx api.Context, obj runtime.Object) (out runtime.O
return
}
// setPodHostAndAnnotations sets the given pod's host to 'machine' iff it was previously 'oldMachine' and merges
// the provided annotations with those of the pod.
// setPodHostAndAnnotations sets the given pod's host to 'machine' if and only if it was
// previously 'oldMachine' and merges the provided annotations with those of the pod.
// Returns the current state of the pod, or an error.
func (r *BindingREST) setPodHostAndAnnotations(ctx api.Context, podID, oldMachine, machine string, annotations map[string]string) (finalPod *api.Pod, err error) {
podKey, err := r.store.KeyFunc(ctx, podID)

View File

@ -29,27 +29,27 @@ import (
"github.com/golang/glog"
)
// IsEtcdNotFound returns true iff err is an etcd not found error.
// IsEtcdNotFound returns true if and only if err is an etcd not found error.
func IsEtcdNotFound(err error) bool {
return isEtcdErrorNum(err, tools.EtcdErrorCodeNotFound)
}
// IsEtcdNodeExist returns true iff err is an etcd node already exist error.
// IsEtcdNodeExist returns true if and only if err is an etcd node already exist error.
func IsEtcdNodeExist(err error) bool {
return isEtcdErrorNum(err, tools.EtcdErrorCodeNodeExist)
}
// IsEtcdTestFailed returns true iff err is an etcd write conflict.
// IsEtcdTestFailed returns true if and only if err is an etcd write conflict.
func IsEtcdTestFailed(err error) bool {
return isEtcdErrorNum(err, tools.EtcdErrorCodeTestFailed)
}
// IsEtcdWatchStoppedByUser returns true iff err is a client triggered stop.
// IsEtcdWatchStoppedByUser returns true if and only if err is a client triggered stop.
func IsEtcdWatchStoppedByUser(err error) bool {
return goetcd.ErrWatchStoppedByUser == err
}
// isEtcdErrorNum returns true iff err is an etcd error, whose errorCode matches errorCode
// isEtcdErrorNum returns true if and only if err is an etcd error, whose errorCode matches errorCode
func isEtcdErrorNum(err error, errorCode int) bool {
etcdError, ok := err.(*goetcd.EtcdError)
return ok && etcdError != nil && etcdError.ErrorCode == errorCode

View File

@ -55,7 +55,7 @@ type ResponseMeta struct {
}
// FilterFunc is a predicate which takes an API object and returns true
// iff the object should remain in the set.
// if and only if the object should remain in the set.
type FilterFunc func(obj runtime.Object) bool
// Everything is a FilterFunc which accepts all objects.

View File

@ -46,7 +46,7 @@ func (at *AtomicValue) Load() interface{} {
// for some quantity.
type HighWaterMark int64
// Check returns true iff 'current' is the highest value ever seen.
// Check returns true if and only if 'current' is the highest value ever seen.
func (hwm *HighWaterMark) Check(current int64) bool {
for {
old := atomic.LoadInt64((*int64)(hwm))

View File

@ -61,13 +61,13 @@ func (s String) Delete(items ...string) {
}
}
// Has returns true iff item is contained in the set.
// Has returns true if and only if item is contained in the set.
func (s String) Has(item string) bool {
_, contained := s[item]
return contained
}
// HasAll returns true iff all items are contained in the set.
// HasAll returns true if and only if all items are contained in the set.
func (s String) HasAll(items ...string) bool {
for _, item := range items {
if !s.Has(item) {
@ -121,7 +121,7 @@ func (s1 String) Union(s2 String) String {
return result
}
// IsSuperset returns true iff s1 is a superset of s2.
// IsSuperset returns true if and only if s1 is a superset of s2.
func (s1 String) IsSuperset(s2 String) bool {
for item := range s2 {
if !s1.Has(item) {
@ -131,7 +131,7 @@ func (s1 String) IsSuperset(s2 String) bool {
return true
}
// Equal returns true iff s1 is equal (as a set) to s2.
// Equal returns true if and only if s1 is equal (as a set) to s2.
// Two sets are equal if their membership is identical.
// (In practice, this means same elements, order doesn't matter)
func (s1 String) Equal(s2 String) bool {

View File

@ -56,7 +56,7 @@ type SystemModeler interface {
ForgetPodByKey(key string)
// For serializing calls to Assume/ForgetPod: imagine you want to add
// a pod iff a bind succeeds, but also remove a pod if it is deleted.
// a pod if and only if a bind succeeds, but also remove a pod if it is deleted.
// TODO: if SystemModeler begins modeling things other than pods, this
// should probably be parameterized or specialized for pods.
LockedAction(f func())
@ -137,8 +137,8 @@ func (s *Scheduler) scheduleOne() {
},
}
// We want to add the pod to the model iff the bind succeeds, but we don't want to race
// with any deletions, which happen asynchronously.
// We want to add the pod to the model if and only if the bind succeeds,
// but we don't want to race with any deletions, which happen asynchronously.
s.config.Modeler.LockedAction(func() {
bindingStart := time.Now()
err := s.config.Binder.Bind(b)