Skip to content

Commit

Permalink
fixup: rename flag to --use-scoped-token, default to true
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Oct 8, 2024
1 parent 169001b commit 94f01eb
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/cli/cmd/apply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ pub(crate) struct ApplySubcommand {
#[clap(subcommand)]
system: System,

#[clap(long, default_value_t = false)]
request_restricted_token: bool,
/// Use a scoped token generated by FlakeHub that allows substituting the given output _only_.
#[clap(long, default_value_t = true)]
use_scoped_token: bool,

#[clap(from_global)]
api_addr: url::Url,
Expand Down Expand Up @@ -84,12 +85,9 @@ impl CommandExecute for ApplySubcommand {

tracing::info!("Resolving {}", output_ref);

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

tracing::debug!(
"Successfully resolved reference {} to path {}",
Expand All @@ -100,7 +98,7 @@ impl CommandExecute for ApplySubcommand {
let profile_path = applyer.profile_path();

match resolved_path.token {
Some(token) if self.request_restricted_token => {
Some(token) if self.use_scoped_token => {
let mut nix_args = vec![
"copy".to_string(),
"--from".to_string(),
Expand Down Expand Up @@ -137,12 +135,12 @@ impl CommandExecute for ApplySubcommand {

dir.close()?;
}
None if self.request_restricted_token => {
None if self.use_scoped_token => {
return Err(color_eyre::eyre::eyre!(
"FlakeHub did not return a restricted token!"
));
}
Some(_) if !self.request_restricted_token => {
Some(_) if !self.use_scoped_token => {
tracing::warn!(
"Received a restricted token from FlakeHub, but we didn't request one! Ignoring."
);
Expand Down

0 comments on commit 94f01eb

Please sign in to comment.