1pub fn local_guess_curl_ca_bundle() {
2 let ca_file = "/etc/ssl/certs/ca-certificates.crt";
4
5 if std::env::var("CURL_CA_BUNDLE").is_err() && std::path::Path::new(ca_file).exists() {
6 std::env::set_var("CURL_CA_BUNDLE", ca_file);
7 }
8}
9
10#[must_use]
11pub fn gcs_gcloud_is_installed() -> bool {
12 let mut cmd = std::process::Command::new("gcloud");
15 cmd.arg("version")
16 .stdout(std::process::Stdio::null())
17 .stderr(std::process::Stdio::null())
18 .status()
19 .is_ok()
20}
21
22pub fn gcs_authorize_data_access() {
29 if !gcs_gcloud_is_installed() {
31 panic!("gcloud is not installed on the PATH");
32 }
33
34 let output = std::process::Command::new("gcloud")
36 .args(["auth", "application-default", "print-access-token"])
37 .output()
38 .expect("Failed to execute command");
39
40 if !output.status.success() {
41 panic!("{}", String::from_utf8_lossy(&output.stderr));
42 }
43
44 let token = String::from_utf8(output.stdout)
46 .expect("Failed to decode output")
47 .trim_end()
48 .to_string();
49
50 std::env::set_var("GCS_OAUTH_TOKEN", token);
52}