// NewCompletion creates a Completion which calls a function upon Complete().
// 'cancel' is called if the associated operation fails for any reason.
431220
func NewCompletion(cancel context.CancelFunc, callback func(err error)) *Completion {
	return &Completion{
		cancel:    cancel,
		completed: make(chan struct{}),
		callback:  callback,
	}
}
619116
func (s *ReindexService) WaitForCompletion(waitForCompletion bool) *ReindexService {
	s.waitForCompletion = &waitForCompletion
	return s
}
475389
func (o *CancelBuildOptions) Complete(f kcmdutil.Factory, cmd *cobra.Command, args []string) error {
	if len(args) == 0 {
		return fmt.Errorf("build or a buildconfig name is required")
	}

	o.ReportError = func(err error) {
		o.HasError = true
		fmt.Fprintf(o.ErrOut, "error: %s\n", err.Error())
	}

	var err error
	o.PrinterCancel, err = printers.NewTypeSetter(scheme.Scheme).
		WrapToPrinter(&printers.NamePrinter{Operation: "cancelled"}, nil)
	if err != nil {
		return err
	}
	o.PrinterRestart, err = printers.NewTypeSetter(scheme.Scheme).
		WrapToPrinter(&printers.NamePrinter{Operation: "restarted"}, nil)
	if err != nil {
		return err
	}
	o.PrinterCancelInProgress, err = printers.NewTypeSetter(scheme.Scheme).
		WrapToPrinter(&printers.NamePrinter{Operation: "marked for cancellation, waiting to be cancelled"}, nil)
	if err != nil {
		return err
	}

	if o.timeout.Seconds() == 0 {
		o.timeout = 30 * time.Second
	}

	o.Namespace, _, err = f.ToRawKubeConfigLoader().Namespace()
	if err != nil {
		return err
	}

	config, err := f.ToRESTConfig()
	if err != nil {
		return err
	}

	o.Client, err = buildtv1client.NewForConfig(config)
	if err != nil {
		return err
	}

	internalclient, err := buildclientset.NewForConfig(config)
	if err != nil {
		return err
	}

	o.BuildLister = buildclientinternal.NewClientBuildLister(internalclient.BuildV1())
	o.BuildClient = o.Client.Builds(o.Namespace)
	o.Mapper, err = f.ToRESTMapper()
	if err != nil {
		return err
	}

	for _, item := range args {
		resource, name, err := cmdutil.ResolveResource(build.Resource("builds"), item, o.Mapper)
		if err != nil {
			return err
		}

		switch resource {
		case build.Resource("buildconfigs"):
			list, err := buildutil.BuildConfigBuilds(o.BuildLister, o.Namespace, name, nil)
			if err != nil {
				return err
			}
			for _, b := range list {
				o.BuildNames = append(o.BuildNames, b.Name)
			}
		case build.Resource("builds"):
			o.BuildNames = append(o.BuildNames, strings.TrimSpace(name))
		default:
			return fmt.Errorf("invalid resource provided: %v", resource)
		}
	}

	return nil
}
333335
func (blockID BlockID) IsComplete() bool {
	return len(blockID.Hash) == tmhash.Size &&
		blockID.PartsHeader.Total > 0 &&
		len(blockID.PartsHeader.Hash) == tmhash.Size
}
889367
func (s *RemindersService) Complete(reminder string) *RemindersCompleteCall {
	var call RemindersCompleteCall
	call.service = s
	call.reminder = reminder
	return &call
}
51139
func OnActivityCompleted(activityName string, deciders ...Decider) Decider {
	return OnActivityEvents(activityName, []string{
		swf.EventTypeActivityTaskCompleted,
	}, deciders...)
}
1824
func Complete(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "complete", Listener: listener}
}
384365
func (p *testSuiteDataParser) MarksCompletion(line string) bool {
	return p.suiteConclusionPattern.MatchString(line)
}
1037100
func (t *ActivatedTask) Finish(resultJSON string, expire ...time.Time) {
	req := &dm.FinishAttemptReq{
		Auth: t.Auth,
		Data: dm.NewJsonResult(resultJSON),
	}
	switch len(expire) {
	case 0:
	case 1:
		req.Data.Expiration = googlepb.NewTimestamp(expire[0])
	default:
		panic("may only specify 0 or 1 expire values")
	}

	_, err := t.s.FinishAttempt(t.c, req)
	panicIf(err)
}
751680
func (s *TasksListService) WaitForCompletion(waitForCompletion bool) *TasksListService {
	s.waitForCompletion = &waitForCompletion
	return s
}
893227
func NewCompleteVersion(s string) (*CompleteVersion, error) {
	var err error
	epoch := 0
	rel := Version("")

	// handle possible epoch
	versions := strings.Split(s, ":")
	if len(versions) > 2 {
		return nil, fmt.Errorf("invalid version format: %s", s)
	}

	if len(versions) > 1 {
		epoch, err = strconv.Atoi(versions[0])
		if err != nil {
			return nil, err
		}
	}

	// handle possible rel
	versions = strings.Split(versions[len(versions)-1], "-")
	if len(versions) > 2 {
		return nil, fmt.Errorf("invalid version format: %s", s)
	}

	if len(versions) > 1 {
		rel = Version(versions[1])
	}

	// finally check that the actual version is valid
	if validPkgver(versions[0]) {
		return &CompleteVersion{
			Version: Version(versions[0]),
			Epoch:   uint8(epoch),
			Pkgrel:  rel,
		}, nil
	}

	return nil, fmt.Errorf("invalid version format: %s", s)
}
316868
func (s *SnapshotCreateService) WaitForCompletion(waitForCompletion bool) *SnapshotCreateService {
	s.waitForCompletion = &waitForCompletion
	return s
}
1268073
func (e *edge) isComplete() bool {
	return e.err != nil || e.result != nil
}
63799
func (s *JobDescription) SetCompleted(v bool) *JobDescription {
	s.Completed = &v
	return s
}
448132
func (ctrl *Controller) Finish() {
	ctrl.T.Helper()

	ctrl.mu.Lock()
	defer ctrl.mu.Unlock()

	if ctrl.finished {
		ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.")
	}
	ctrl.finished = true

	// If we're currently panicking, probably because this is a deferred call,
	// pass through the panic.
	if err := recover(); err != nil {
		panic(err)
	}

	// Check that all remaining expected calls are satisfied.
	failures := ctrl.expectedCalls.Failures()
	for _, call := range failures {
		ctrl.T.Errorf("missing call(s) to %v", call)
	}
	if len(failures) != 0 {
		ctrl.T.Fatalf("aborting test due to missing call(s)")
	}
}
615870
func IsIncomplete(err error) bool {
	perr, ok := err.(ParseError)
	return ok && perr.Incomplete
}
149870
func IsNotImplemented(err error) bool {
	_, ok := getImplementer(err).(ErrNotImplemented)
	return ok
}