github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/utils/pip/config.go (about)

     1  package pip
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/jfrog/jfrog-cli-go/artifactory/utils"
     6  
     7  	"github.com/jfrog/jfrog-client-go/utils/errorutils"
     8  	"github.com/jfrog/jfrog-client-go/utils/log"
     9  )
    10  
    11  func GetPipConfiguration() (*utils.RepositoryConfig, error) {
    12  	// Get configuration file path.
    13  	confFilePath, exists, err := utils.GetProjectConfFilePath(utils.Pip)
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  	if !exists {
    18  		return nil, errorutils.CheckError(fmt.Errorf("Pip Project configuration does not exist."))
    19  	}
    20  	// Read config file.
    21  	log.Debug("Preparing to read the config file", confFilePath)
    22  	vConfig, err := utils.ReadConfigFile(confFilePath, utils.YAML)
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  	return utils.GetRepoConfigByPrefix(confFilePath, utils.ProjectConfigResolverPrefix, vConfig)
    27  }