// Temporary returns true if the operation that generated the error may succeed
// if retried at a later time.
964847
func (e Error) Temporary() bool {
	return e == LeaderNotAvailable ||
		e == BrokerNotAvailable ||
		e == ReplicaNotAvailable ||
		e == GroupLoadInProgress ||
		e == GroupCoordinatorNotAvailable ||
		e == RebalanceInProgress ||
		e.Timeout()
}
812351
func Retry(n uint, interval time.Duration, fn func() error) (err error) {
	return WithContext(context.Background(), n, interval, fn)
}
916379
func (term Range) Error() error {
	if term.Start.IsZero() || term.End.IsZero() {
		return nil
	}
	// One day only is allowed
	if term.Start.After(term.End) {
		return fmt.Errorf("Start date cannot be after the end date")
	}
	return nil
}
1190245
func Retry(err error, message string, args ...interface{}) error {
	return WrapWithMessage(&RetryError{
		Message: fmt.Sprintf(message, args...),
		Err:     err,
	}, message, args...)
}
318643
func (c *Client) WithTemporary(opt Opt, f func() error) error {
	if opt != nil {
		undo := c.With(opt)
		defer c.With(undo)
	}
	return f()
}
1174856
func (f *Request) Retry(r int) *Request {
	f.retry = r
	return f
}
221852
func await(ctx context.Context, stdout, stderr io.Writer, client api.Server, jobID job.ID, apply bool, verbosity int) error {
	result, err := awaitJob(ctx, client, jobID)
	if err != nil {
		if err == ErrTimeout {
			fmt.Fprintln(stderr, `
We timed out waiting for the result of the operation. This does not
necessarily mean it has failed. You can check the state of the
cluster, or commit logs, to see if there was a result. In general, it
is safe to retry operations.`)
			// because the outcome is unknown, still return the err to indicate an exceptional exit
		}
		return err
	}
	if result.Result != nil {
		update.PrintResults(stdout, result.Result, verbosity)
	}
	if result.Revision != "" {
		fmt.Fprintf(stderr, "Commit pushed:\t%s\n", result.Revision[:7])
	}
	if result.Result == nil {
		fmt.Fprintf(stderr, "Nothing to do\n")
		return nil
	}

	if apply && result.Revision != "" {
		if err := awaitSync(ctx, client, result.Revision); err != nil {
			if err == ErrTimeout {
				fmt.Fprintln(stderr, `
The operation succeeded, but we timed out waiting for the commit to be
applied. This does not necessarily mean there is a problem. Use

    fluxctl sync

to run a sync interactively.`)
				return nil
			}
			return err
		}
		fmt.Fprintf(stderr, "Commit applied:\t%s\n", result.Revision[:7])
	}

	return nil
}
87998
func (td *TempDir) Restore() {
	err := os.RemoveAll(td.dir)
	if err != nil {
		msg := fmt.Sprintf("cannot remove temporary directory %q: %v", td.dir, err)
		td.assert.Fail(msg)
	}
}
592876
func (t *T) TempFileMode(mode os.FileMode) *os.File {
	f, err := ioutilTempFile(t.RootTempDir(), t.Name())
	t.ExpectSuccess(err)
	t.NotEqual(f, nil)
	t.ExpectSuccess(osChmod(f.Name(), mode))
	name := f.Name()
	t.AddFinalizer(func() {
		osRemove(name)
	})
	return f
}
772099
func (s *set) Until(f func(*Term) bool) bool {
	err := s.Iter(func(t *Term) error {
		if f(t) {
			return errStop
		}
		return nil
	})
	return err != nil
}
1162357
func (e ErrorNode) Temporary() bool {
	type temporary interface {
		Temporary() bool
	}

	for err := e.cause; err != nil; {
		if t, ok := err.(temporary); ok {
			return t.Temporary()
		}

		if cause, ok := err.(causer); ok {
			err = cause.Cause()
		} else {
			err = nil
		}
	}
	return false
}
1140150
func ProcessTemplate(t T, templateContent string, value interface{}) string {
	tmp, err := template.New("temporary").Parse(templateContent)
	if err != nil {
		logfatal(t, sfatalf("failed to parse:%v", err))
		return ""
	}
	var buf bytes.Buffer
	err = tmp.Execute(&buf, value)
	if err != nil {
		logfatal(t, sfatalf("failed to execute template:%v", err))
		return ""
	}
	return buf.String()
}
1079692
func TempFile(prefix string) (string, error) {
	tmp, err := TempFileName(prefix)
	if err != nil {
		return "", err
	}
	return filepath.Join(os.TempDir(), tmp), nil
}
1162229
func WriteTmpFile(fs utilfs.Filesystem, path string, data []byte) (tmpPath string, retErr error) {
	dir := filepath.Dir(path)
	prefix := tmptag + filepath.Base(path)

	// create the tmp file
	tmpFile, err := fs.TempFile(dir, prefix)
	if err != nil {
		return "", err
	}
	defer func() {
		// close the file, return the close error only if there haven't been any other errors
		if err := tmpFile.Close(); retErr == nil {
			retErr = err
		}
		// if there was an error writing, syncing, or closing, delete the temporary file and return the error
		if retErr != nil {
			if err := fs.Remove(tmpPath); err != nil {
				retErr = fmt.Errorf("attempted to remove temporary file %q after error %v, but failed due to error: %v", tmpPath, retErr, err)
			}
			tmpPath = ""
		}
	}()

	// Name() will be an absolute path when using utilfs.DefaultFS, because ioutil.TempFile passes
	// an absolute path to os.Open, and we ensure similar behavior in utilfs.FakeFS for testing.
	tmpPath = tmpFile.Name()

	// write data
	if _, err := tmpFile.Write(data); err != nil {
		return tmpPath, err
	}
	// sync file, to ensure it's written in case a hard reset happens
	return tmpPath, tmpFile.Sync()
}
1262652
func (s *AdminCreateUserInput) SetTemporaryPassword(v string) *AdminCreateUserInput {
	s.TemporaryPassword = &v
	return s
}
917483
func (h *MPL115A2Driver) Temperature() (t float32, err error) {
	_, t, err = h.getData()
	return
}
628967
func WithTempDir(t *testing.T) func() {
	cwd, err := os.Getwd()
	if err != nil {
		t.Fatalf("TempDir: %v", err)
	}
	tmpdir, err := ioutil.TempDir("", "")
	if err != nil {
		t.Fatalf("TempDir: %v", err)
	}
	err = os.Chdir(tmpdir)
	if err != nil {
		t.Fatalf("Chdir: %v", err)
	}
	return func() {
		err := os.Chdir(cwd)
		if err != nil {
			t.Fatalf("Chdir: %v", err)
		}
		err = os.RemoveAll(tmpdir)
		if err != nil {
			t.Fatalf("Removing tmpdir: %s", err)
		}
	}
}