コード例 #1
0
ファイル: config.go プロジェクト: JFrogDev/jfrog-cli-go
func Config(details, defaultDetails *config.ArtifactoryDetails, interactive,
	shouldEncPassword bool) (*config.ArtifactoryDetails, error) {

	if details == nil {
		details = new(config.ArtifactoryDetails)
	}
	var err error
	if interactive {
		if defaultDetails == nil {
			defaultDetails, err = config.ReadArtifactoryConf()
			if err != nil {
				return nil, err
			}
		}
		if details.Url == "" {
			ioutils.ScanFromConsole("Artifactory URL", &details.Url, defaultDetails.Url)
		}
		if strings.Index(details.Url, "ssh://") == 0 || strings.Index(details.Url, "SSH://") == 0 {
			err = readSshKeyPathFromConsole(details, defaultDetails)
			if err != nil {
				return nil, err
			}
		} else {
			if details.ApiKey == "" && details.Password == "" {
				ioutils.ScanFromConsole("API key (leave empty for basic authentication)", &details.ApiKey, "")
			}
			if details.ApiKey == "" {
				ioutils.ReadCredentialsFromConsole(details, defaultDetails)
			}
		}
	}
	err = checkSingleAuthMethod(details)
	if err != nil {
		return nil, err
	}

	details.Url = cliutils.AddTrailingSlashIfNeeded(details.Url)
	if shouldEncPassword {
		details, err = encryptPassword(details)
		if err != nil {
			return nil, err
		}
	}
	config.SaveArtifactoryConf(details)
	return details, nil
}
コード例 #2
0
ファイル: config.go プロジェクト: JFrogDev/jfrog-cli-go
func ShowConfig() error {
	details, err := config.ReadArtifactoryConf()
	if err != nil {
		return err
	}
	if details.Url != "" {
		fmt.Println("Url: " + details.Url)
	}
	if details.ApiKey != "" {
		fmt.Println("API key: " + details.ApiKey)
	}
	if details.User != "" {
		fmt.Println("User: "******"" {
		fmt.Println("Password: ***")
	}
	if details.SshKeyPath != "" {
		fmt.Println("SSH key file path: " + details.SshKeyPath)
	}
	return nil
}
コード例 #3
0
ファイル: config.go プロジェクト: JFrogDev/jfrog-cli-go
func GetConfig() (*config.ArtifactoryDetails, error) {
	return config.ReadArtifactoryConf()
}