// DefaultSource retrieves the default source.
774667
func (c *Client) DefaultSource(ctx context.Context) (*platform.Source, error) {
	var s *platform.Source

	err := c.db.View(func(tx *bolt.Tx) error {
		// TODO(desa): make this faster by putting the default source in an index.
		srcs, err := c.findSources(ctx, tx, platform.FindOptions{})
		if err != nil {
			return err
		}
		for _, src := range srcs {
			if src.Default {
				s = src
				return nil
			}
		}
		return &platform.Error{
			Code: platform.ENotFound,
			Msg:  "no default source found",
		}
	})

	if err != nil {
		return nil, &platform.Error{
			Op:  getOp(platform.OpDefaultSource),
			Err: err,
		}
	}

	return s, nil
}
1073448
func (item *MultiGetItem) FetchSource(fetchSourceContext *FetchSourceContext) *MultiGetItem {
	item.fsc = fetchSourceContext
	return item
}
802623
func (s *SearchService) FetchSource(fetchSource bool) *SearchService {
	s.searchSource = s.searchSource.FetchSource(fetchSource)
	return s
}
594039
func (s *sourcesImpl) AddSource(source string) {
	s.lock.Lock()
	defer s.lock.Unlock()
	s.sourcesSeen.Insert(source)
}
239101
func (s *SearchService) FetchSourceContext(fetchSourceContext *FetchSourceContext) *SearchService {
	s.searchSource = s.searchSource.FetchSourceContext(fetchSourceContext)
	return s
}
303310
func NewSource(options ...Option) *Source {
	src := &Source{
		records:     make(chan record),
		maxRetries:  3,
		concurrency: 1,
	}

	for _, opt := range options {
		opt(src)
	}
	go src.getRecords()
	return src
}
1052784
func (r *SearchRequest) FetchSourceContext(fsc *FetchSourceContext) *SearchRequest {
	r.searchSource = r.searchSource.FetchSourceContext(fsc)
	return r
}
1264652
func NewLazySource(root containerfs.ContainerFS) (builder.Source, error) {
	return &lazySource{
		root: root,
		sums: make(map[string]string),
	}, nil
}
278062
func BuildSource(s string) *Source {
	var result []string
	var lineBuf bytes.Buffer
	for _, runeValue := range s {
		lineBuf.WriteRune(runeValue)
		if runeValue == '\n' {
			result = append(result, lineBuf.String())
			lineBuf.Reset()
		}
	}
	rest := lineBuf.String()
	// Stuff after last end-of-line (EOF or some more code)
	result = append(result, rest+"\n")
	return &Source{result}
}
1017615
func NewJSONSourceFromFile(f string) (InputSourceContext, error) {
	data, err := loadDataFrom(f)
	if err != nil {
		return nil, err
	}
	return NewJSONSource(data)
}
99041
func (c *Config) StorageDefaultBlockSource() (string, bool) {
	bs := c.asString(StorageDefaultBlockSourceKey)
	return bs, bs != ""
}
138901
func (r ComponentReferences) HasSource() bool {
	return len(r.filter(func(ref ComponentReference) bool { return ref.Input().Uses != nil })) > 0
}
306503
func (e *lxdStorageProvider) VolumeSource(cfg *storage.Config) (storage.VolumeSource, error) {
	return nil, errors.NotSupportedf("volumes")
}
70145
func installSource(src, dst string, edit editFunc) error {
	return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}

		relpath, err := filepath.Rel(src, path)
		if err != nil {
			return fmt.Errorf("failed to get relative path [%s]: %s", path, err)
		}

		dstpath := filepath.Join(dst, relpath)
		switch {
		case info.IsDir():
			// Make sure the directory exists in the target filesystem.
			if err := ensureDirectory(dstpath); err != nil {
				return fmt.Errorf("failed to ensure directory [%s]: %s", dstpath, err)
			}

		case !info.Mode().IsRegular():
			// Skip non-regular files.
			break

		default:
			// Copy the file from source to destination.
			if err := copyFile(path, dstpath, relpath, edit); err != nil {
				return fmt.Errorf("failed to copy file ([%s] => [%s]): %s", path, dstpath, err)
			}
		}

		return nil
	})
}
472428
func DefaultTokenSource(ctx context.Context, scope ...string) (oauth2.TokenSource, error) {
	creds, err := FindDefaultCredentials(ctx, scope...)
	if err != nil {
		return nil, err
	}
	return creds.TokenSource, nil
}
401852
func (fsc *FetchSourceContext) Source() (interface{}, error) {
	if !fsc.fetchSource {
		return false, nil
	}
	if len(fsc.includes) == 0 && len(fsc.excludes) == 0 {
		return true, nil
	}
	src := make(map[string]interface{})
	if len(fsc.includes) > 0 {
		src["includes"] = fsc.includes
	}
	if len(fsc.excludes) > 0 {
		src["excludes"] = fsc.excludes
	}
	return src, nil
}
1320387
func (s *DeleteStatement) DefaultDatabase() string {
	if m, ok := s.Source.(*Measurement); ok {
		return m.Database
	}
	return ""
}