Skip to content

Commit

Permalink
Replace --use-scoped-token with --no-scoped-token
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Nov 6, 2024
1 parent 2d0af28 commit feda177
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/cli/cmd/apply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ pub(crate) struct ApplySubcommand {
#[clap(subcommand)]
system: System,

/// Use a scoped token generated by FlakeHub that allows substituting the given output _only_.
#[clap(long, default_value_t = true)]
use_scoped_token: bool,
/// By default, fh apply exchanges its API token for a tightly scoped token generated by FlakeHub that _only_ allows substituting the given output.
/// Pass --no-scoped-token to use the system's FlakeHub token, and not perform exchanging for a tightly scoped token.
#[clap(long, default_value_t = false)]
no_scoped_token: bool,

#[clap(from_global)]
api_addr: url::Url,
Expand Down Expand Up @@ -86,7 +87,7 @@ impl CommandExecute for ApplySubcommand {
tracing::info!(%output_ref, "Resolving output reference");

let resolved_path =
FlakeHubClient::resolve(self.api_addr.as_ref(), &output_ref, self.use_scoped_token)
FlakeHubClient::resolve(self.api_addr.as_ref(), &output_ref, !self.no_scoped_token)
.await?;

tracing::debug!(
Expand All @@ -99,7 +100,7 @@ impl CommandExecute for ApplySubcommand {

match resolved_path.token {
Some(token) => {
if self.use_scoped_token {
if !self.no_scoped_token {
let mut nix_args = vec![
"copy".to_string(),
"--option".to_string(),
Expand Down Expand Up @@ -168,7 +169,7 @@ impl CommandExecute for ApplySubcommand {
}
}
None => {
if self.use_scoped_token {
if !self.no_scoped_token {
return Err(color_eyre::eyre::eyre!(
"FlakeHub did not return a restricted token!"
));
Expand Down

0 comments on commit feda177

Please sign in to comment.