Skip to content

Commit

Permalink
Add configurable user agent prefix flag for mount-s3
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Carl Jones <[email protected]>
  • Loading branch information
dannycjones committed Oct 9, 2023
1 parent 16efe55 commit 5e8f983
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mountpoint-s3/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ struct CliArgs {
)]
pub allow_other: bool,

#[clap(
long,
help = "Configure a string to be prepended to the 'User-Agent' HTTP request header for all S3 requests",
value_name = "PREFIX",
help_heading = CLIENT_OPTIONS_HEADER
)]
pub user_agent_prefix: Option<String>,

#[clap(
long,
help = "Maximum throughput in Gbps [default: auto-detected on EC2 instances, 10 Gbps elsewhere]",
Expand Down Expand Up @@ -420,11 +428,17 @@ fn mount(args: CliArgs) -> anyhow::Result<FuseSession> {
S3ClientAuthConfig::Default
};

let user_agent_prefix = if let Some(custom_prefix) = args.user_agent_prefix {
format!("{} mountpoint-s3/{}", custom_prefix, build_info::FULL_VERSION)
} else {
format!("mountpoint-s3/{}", build_info::FULL_VERSION)
};

let mut client_config = S3ClientConfig::new()
.auth_config(auth_config)
.throughput_target_gbps(throughput_target_gbps)
.part_size(args.part_size as usize)
.user_agent_prefix(&format!("mountpoint-s3/{}", build_info::FULL_VERSION));
.user_agent_prefix(&user_agent_prefix);
if args.requester_pays {
client_config = client_config.request_payer("requester");
}
Expand Down

0 comments on commit 5e8f983

Please sign in to comment.