func createArtifactoryDetails(c *cli.Context, includeConfig bool) (*config.ArtifactoryDetails, error) { if includeConfig { details, err := offerConfig(c) if err != nil { return nil, err } if details != nil { return details, nil } } details := new(config.ArtifactoryDetails) details.Url = c.String("url") details.ApiKey = c.String("apikey") details.User = c.String("user") details.Password = c.String("password") details.SshKeyPath = c.String("ssh-key-path") if includeConfig { confDetails, err := commands.GetConfig() if err != nil { return nil, err } if details.Url == "" { details.Url = confDetails.Url } if !isAuthMethodSet(details) { if details.ApiKey == "" { details.ApiKey = confDetails.ApiKey } if details.User == "" { details.User = confDetails.User } if details.Password == "" { details.Password = confDetails.Password } if details.SshKeyPath == "" { details.SshKeyPath = confDetails.SshKeyPath } } } details.Url = cliutils.AddTrailingSlashIfNeeded(details.Url) return details, nil }
func encryptPassword(details *config.ArtifactoryDetails) (*config.ArtifactoryDetails, error) { if details.Password == "" { return details, nil } log.Info("\nEncrypting password...") response, encPassword, err := utils.GetEncryptedPasswordFromArtifactory(details) if err != nil { return nil, err } switch response.StatusCode { case 409: message := "\nYour Artifactory server is not configured to encrypt passwords.\n" + "You may use \"art config --enc-password=false\"" err = cliutils.CheckError(errors.New(message)) case 200: details.Password = encPassword log.Info("Done encrypting password.") default: err = cliutils.CheckError(errors.New("\nArtifactory response: " + response.Status)) } return details, err }