func NewClientWithFileSystem(config Config, fileSystem FileSystem) (*Client, error) {
	base, err := config.BasePath()
	if err != nil {
		return nil, errors.Trace(err)
	}

	infoPath, err := base.Join("info")
	if err != nil {
		return nil, errors.Annotate(err, "constructing info path")
	}

	findPath, err := base.Join("find")
	if err != nil {
		return nil, errors.Annotate(err, "constructing find path")
	}

	refreshPath, err := base.Join("refresh")
	if err != nil {
		return nil, errors.Annotate(err, "constructing refresh path")
	}

	resourcesPath, err := base.Join("resources")
	if err != nil {
		return nil, errors.Annotate(err, "constructing resources path")
	}

	config.Logger.Tracef("NewClient to %q", config.URL)

	apiRequester := NewAPIRequester(config.Transport, config.Logger)
	apiRequestLogger := NewAPIRequesterLogger(apiRequester, config.Logger)
	restClient := NewHTTPRESTClient(apiRequestLogger, config.Headers)

	return &Client{
		url:           base.String(),
		infoClient:    NewInfoClient(infoPath, restClient, config.Logger),
		findClient:    NewFindClient(findPath, restClient, config.Logger),
		refreshClient: NewRefreshClient(refreshPath, restClient, config.Logger),
		// download client doesn't require a path here, as the download could
		// be from any server in theory. That information is found from the
		// refresh response.
		downloadClient:  NewDownloadClient(config.Transport, fileSystem, config.Logger),
		resourcesClient: NewResourcesClient(resourcesPath, restClient, config.Logger),
		logger:          config.Logger,
	}, nil
}
// NewClientWithFileSystem creates a new charmHub client from the supplied
// configuration and a file system.
NewClientWithFileSystem creates a new charmHub client from the supplied
configuration and a file system.
// NewClientWithFileSystem creates a new charmHub client from the supplied // configuration and a file system .
func NewClientWithFileSystem(config Config, fileSystem FileSystem) (*Client, error) {
	base, err := config.BasePath()
	if err != nil {
		return nil, errors.Trace(err)
	}
	infoPath, err := base.Join("info")
	if err != nil {
		return nil, errors.Annotate(err, "constructing info path")
	}
	findPath, err := base.Join("find")
	if err != nil {
		return nil, errors.Annotate(err, "constructing find path")
	}
	refreshPath, err := base.Join("refresh")
	if err != nil {
		return nil, errors.Annotate(err, "constructing refresh path")
	}
	resourcesPath, err := base.Join("resources")
	if err != nil {
		return nil, errors.Annotate(err, "constructing resources path")
	}
	config.Logger.Tracef("NewClient to %q", config.URL)
	apiRequester := NewAPIRequester(config.Transport, config.Logger)
	apiRequestLogger := NewAPIRequesterLogger(apiRequester, config.Logger)
	restClient := NewHTTPRESTClient(apiRequestLogger, config.Headers)
	return &Client{
		url:           base.String(),
		infoClient:    NewInfoClient(infoPath, restClient, config.Logger),
		findClient:    NewFindClient(findPath, restClient, config.Logger),
		refreshClient: NewRefreshClient(refreshPath, restClient, config.Logger),
		downloadClient:  NewDownloadClient(config.Transport, fileSystem, config.Logger),
		resourcesClient: NewResourcesClient(resourcesPath, restClient, config.Logger),
		logger:          config.Logger,
	}, nil
}
func NewClientWithFileSystem ( config Config , fileSystem FileSystem ) ( * Client , error ) { base , err := config . BasePath ( ) if err != nil { return nil , errors . Trace ( err ) } infoPath , err := base . Join ( " " ) if err != nil { return nil , errors . Annotate ( err , " " ) } findPath , err := base . Join ( " " ) if err != nil { return nil , errors . Annotate ( err , " " ) } refreshPath , err := base . Join ( " " ) if err != nil { return nil , errors . Annotate ( err , " " ) } resourcesPath , err := base . Join ( " " ) if err != nil { return nil , errors . Annotate ( err , " " ) } config . Logger . Tracef ( " " , config . URL ) apiRequester := NewAPIRequester ( config . Transport , config . Logger ) apiRequestLogger := NewAPIRequesterLogger ( apiRequester , config . Logger ) restClient := NewHTTPRESTClient ( apiRequestLogger , config . Headers ) return & Client { url : base . String ( ) , infoClient : NewInfoClient ( infoPath , restClient , config . Logger ) , findClient : NewFindClient ( findPath , restClient , config . Logger ) , refreshClient : NewRefreshClient ( refreshPath , restClient , config . Logger ) , downloadClient : NewDownloadClient ( config . Transport , fileSystem , config . Logger ) , resourcesClient : NewResourcesClient ( resourcesPath , restClient , config . Logger ) , logger : config . Logger , } , nil }
NewClientWithFileSystem creates a new charmHub client from the supplied
configuration and a file system.
NewClientWithFileSystem creates a new charmHub client from the supplied configuration and a file system .
// download client doesn't require a path here, as the download could // be from any server in theory. That information is found from the // refresh response.