Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a token as parameter for publish, yank, owner. #4668

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/bin/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use cargo::util::{CliResult, Config};
#[derive(Deserialize)]
pub struct Options {
arg_crate: Option<String>,
flag_token: Option<String>,
flag_add: Option<Vec<String>>,
flag_remove: Option<Vec<String>>,
flag_index: Option<String>,
Expand All @@ -30,7 +29,6 @@ Options:
-r, --remove LOGIN Name of a user or team to remove as an owner
-l, --list List owners of a crate
--index INDEX Registry index to modify owners for
--token TOKEN API token to use when authenticating
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
Expand All @@ -56,7 +54,6 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {
&options.flag_z)?;
let opts = ops::OwnersOptions {
krate: options.arg_crate,
token: options.flag_token,
index: options.flag_index,
to_add: options.flag_add,
to_remove: options.flag_remove,
Expand Down
4 changes: 0 additions & 4 deletions src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
pub struct Options {
flag_index: Option<String>,
flag_host: Option<String>, // TODO: Deprecated, remove
flag_token: Option<String>,
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: u32,
Expand All @@ -33,7 +32,6 @@ Options:
-h, --help Print this message
--index INDEX Registry index to upload the package to
--host HOST DEPRECATED, renamed to '--index'
--token TOKEN Token to use when uploading
--no-verify Don't verify package tarball before publish
--allow-dirty Allow publishing with a dirty source directory
--target TRIPLE Build for the target triple
Expand All @@ -58,7 +56,6 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {
&options.flag_z)?;

let Options {
flag_token: token,
flag_index: index,
flag_host: host, // TODO: Deprecated, remove
flag_manifest_path,
Expand Down Expand Up @@ -91,7 +88,6 @@ about this warning.";
let ws = Workspace::new(&root, config)?;
ops::publish(&ws, &ops::PublishOpts {
config: config,
token: token,
index:
if host.clone().is_none() || host.clone().unwrap().is_empty() { index }
else { config.shell().warn(&msg)?; host }, // TODO: Deprecated, remove
Expand Down
3 changes: 0 additions & 3 deletions src/bin/yank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use cargo::util::{CliResult, Config};
#[derive(Deserialize)]
pub struct Options {
arg_crate: Option<String>,
flag_token: Option<String>,
flag_vers: Option<String>,
flag_index: Option<String>,
flag_verbose: u32,
Expand All @@ -28,7 +27,6 @@ Options:
--vers VERSION The version to yank or un-yank
--undo Undo a yank, putting a version back into the index
--index INDEX Registry index to yank from
--token TOKEN API token to use when authenticating
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
Expand All @@ -55,7 +53,6 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {
ops::yank(config,
options.arg_crate,
options.flag_vers,
options.flag_token,
options.flag_index,
options.flag_undo)?;
Ok(())
Expand Down
15 changes: 4 additions & 11 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub struct RegistryConfig {

pub struct PublishOpts<'cfg> {
pub config: &'cfg Config,
pub token: Option<String>,
pub index: Option<String>,
pub verify: bool,
pub allow_dirty: bool,
Expand All @@ -50,7 +49,6 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
}

let (mut registry, reg_id) = registry(opts.config,
opts.token.clone(),
opts.index.clone())?;
verify_dependencies(pkg, &reg_id)?;

Expand Down Expand Up @@ -196,14 +194,12 @@ pub fn registry_configuration(config: &Config) -> CargoResult<RegistryConfig> {
}

pub fn registry(config: &Config,
token: Option<String>,
index: Option<String>) -> CargoResult<(Registry, SourceId)> {
// Parse all configuration options
let RegistryConfig {
token: token_config,
token,
index: _index_config,
} = registry_configuration(config)?;
let token = token.or(token_config);
let sid = match index {
Some(index) => SourceId::for_registry(&index.to_url()?)?,
None => SourceId::crates_io(config)?,
Expand Down Expand Up @@ -306,7 +302,6 @@ pub fn registry_login(config: &Config, token: String) -> CargoResult<()> {

pub struct OwnersOptions {
pub krate: Option<String>,
pub token: Option<String>,
pub index: Option<String>,
pub to_add: Option<Vec<String>>,
pub to_remove: Option<Vec<String>>,
Expand All @@ -323,8 +318,7 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> {
}
};

let (mut registry, _) = registry(config, opts.token.clone(),
opts.index.clone())?;
let (mut registry, _) = registry(config, opts.index.clone())?;

if let Some(ref v) = opts.to_add {
let v = v.iter().map(|s| &s[..]).collect::<Vec<_>>();
Expand Down Expand Up @@ -365,7 +359,6 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> {
pub fn yank(config: &Config,
krate: Option<String>,
version: Option<String>,
token: Option<String>,
index: Option<String>,
undo: bool) -> CargoResult<()> {
let name = match krate {
Expand All @@ -381,7 +374,7 @@ pub fn yank(config: &Config,
None => bail!("a version must be specified to yank")
};

let (mut registry, _) = registry(config, token, index)?;
let (mut registry, _) = registry(config, index)?;

if undo {
config.shell().status("Unyank", format!("{}:{}", name, version))?;
Expand Down Expand Up @@ -410,7 +403,7 @@ pub fn search(query: &str,
}
}

let (mut registry, _) = registry(config, None, index)?;
let (mut registry, _) = registry(config, index)?;
let (crates, total_crates) = registry.search(query, limit).map_err(|e| {
CargoError::from(format!("failed to retrieve search results from the registry: {}", e))
})?;
Expand Down