// NewBytesSource returns a Source implementation that reads from the supplied
// byte slice.
492264
func NewBytesSource(d []byte) Source {
	return func() (io.ReadCloser, error) {
		return ioutil.NopCloser(bytes.NewReader(d)), nil
	}
}
523235
func GetDataSourceByName(c *m.ReqContext) Response {
	query := m.GetDataSourceByNameQuery{Name: c.Params(":name"), OrgId: c.OrgId}

	if err := bus.Dispatch(&query); err != nil {
		if err == m.ErrDataSourceNotFound {
			return Error(404, "Data source not found", nil)
		}
		return Error(500, "Failed to query datasources", err)
	}

	dtos := convertModelToDtos(query.Result)
	dtos.ReadOnly = true
	return JSON(200, &dtos)
}
1114537
func MarshalSource(s chronograf.Source) ([]byte, error) {
	return proto.Marshal(&Source{
		ID:                 int64(s.ID),
		Name:               s.Name,
		Type:               s.Type,
		Username:           s.Username,
		Password:           s.Password,
		SharedSecret:       s.SharedSecret,
		URL:                s.URL,
		MetaURL:            s.MetaURL,
		InsecureSkipVerify: s.InsecureSkipVerify,
		Default:            s.Default,
		Telegraf:           s.Telegraf,
		Organization:       s.Organization,
		Role:               s.Role,
		DefaultRP:          s.DefaultRP,
	})
}
670724
func (mux *Multiplexer) NewBytesConnection(name string) *BytesConnectionStr {
	return &BytesConnectionStr{BytesConnectionFields{multiplexer: mux, name: name}}
}
869842
func NewBytePool() BytePool {
	return BytePool{
		tinySlab:   newByteSlab(tiny, tinyCount),
		smallSlab:  newByteSlab(small, smallCount),
		mediumSlab: newByteSlab(medium, mediumCount),
		largeSlab:  newByteSlab(large, largeCount),
		hugeSlab:   newByteSlab(huge, hugeCount),
	}
}
536096
func New(params *stripe.SourceObjectParams) (*stripe.Source, error) {
	return getC().New(params)
}
958088
func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource {
	return oauth2.ReuseTokenSource(nil, jwtSource{ctx, c})
}
81735
func NewBytes(value []byte, opts BytesOptions) Bytes {
	if opts == nil {
		opts = defaultBytesOptions
	}
	b := &bytesRef{
		opts:  opts,
		value: value,
	}
	b.SetFinalizer(b)
	// NB(r): Tracking objects causes interface allocation
	// so avoid if we are not performing any leak detection.
	if leakDetectionEnabled() {
		b.TrackObject(b.value)
	}
	return b
}
932750
func (mux *Multiplexer) NewBytesManualConnection(name string) *BytesManualConnectionStr {
	return &BytesManualConnectionStr{BytesConnectionFields{multiplexer: mux, name: name}}
}
465520
func NewAPIResourceOptions(ioStreams genericclioptions.IOStreams) *APIResourceOptions {
	return &APIResourceOptions{
		IOStreams:  ioStreams,
		Namespaced: true,
	}
}
654638
func NewURLDataSource(description, baseURL string, hostnameVerification utils.SSLHostnameVerification, priority int, requireSigned bool) DataSource {
	return &urlDataSource{
		description:          description,
		baseURL:              baseURL,
		hostnameVerification: hostnameVerification,
		priority:             priority,
		requireSigned:        requireSigned,
	}
}
205761
func newFileSource(fileType, fileOrPattern string, partitionCount int) *FileSource {

	s := &FileSource{
		PartitionCount: partitionCount,
		FileType:       fileType,
		prefix:         fileType,
	}

	if strings.Contains(fileOrPattern, "://") {
		u, err := url.Parse(fileOrPattern)
		if err != nil {
			log.Printf("Invalid input URL %s", fileOrPattern)
			return nil
		}
		s.fileBaseName = filepath.Base(u.Path)
		u.Path = filepath.Dir(u.Path)
		s.folder = u.String()
		s.Path = fileOrPattern

	} else {
		var err error
		fileOrPattern, err = filepath.Abs(fileOrPattern)
		if err != nil {
			log.Fatalf("file \"%s\" not found: %v", fileOrPattern, err)
		}
		s.folder = filepath.Dir(fileOrPattern)
		s.fileBaseName = filepath.Base(fileOrPattern)
		s.Path = fileOrPattern
	}

	if strings.ContainsAny(s.fileBaseName, "*?") {
		s.hasWildcard = true
	}

	// fmt.Printf("file source: %+v\n", s)

	return s
}
1172971
func NewStorageSimpleStreamsDataSource(description string, storage StorageReader, basePath string, priority int, requireSigned bool) simplestreams.DataSource {
	return &storageSimpleStreamsDataSource{description, basePath, storage, false, priority, requireSigned}
}
765810
func (p *Plugin) NewBytesConnection(name string) *mux.BytesConnectionStr {
	return p.mux.NewBytesConnection(name)
}
1354108
func (f *Function) BuildBytes() ([]byte, error) {
	r, err := f.Build()
	if err != nil {
		return nil, err
	}

	b, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}

	f.Log.Debugf("created build (%s)", humanize.Bytes(uint64(len(b))))
	return b, nil
}
666286
func newDataSourceFunc(baseURL string) func() simplestreams.DataSource {
	return func() simplestreams.DataSource {
		return simplestreams.NewURLSignedDataSource(
			"ubuntu cloud images",
			baseURL,
			imagemetadata.SimplestreamsImagesPublicKey,
			utils.VerifySSLHostnames,
			simplestreams.DEFAULT_CLOUD_DATA,
			true)
	}
}
842352
func NewKvSource(backend store.Backend, addrs []string, options *store.Config, prefix string) (*KvSource, error) {
	kvStore, err := valkeyrie.NewStore(backend, addrs, options)
	return &KvSource{Store: kvStore, Prefix: prefix}, err
}