git.delta.rocks / jrsonnet / refs/commits / b0625df8861d

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2022-09-02parent: #7a2e42e.patch.diff
in: trunk

1 file changed

modifiedcmds/install-secrets/src/main.rsdiffbeforeafterboth
1use age::Decryptor;1use age::Decryptor;
2use anyhow::{anyhow, bail, Context, Result};2use anyhow::{anyhow, bail, Context, Result};
3use clap::Parser;3use clap::Parser;
4use log::{error, warn};4use log::error;
5use nix::fcntl::{renameat2, RenameFlags};
6use nix::sys::stat::Mode;5use nix::sys::stat::Mode;
7use nix::unistd::{chown, Group, User};6use nix::unistd::{chown, Group, User};
8use serde::{Deserialize, Deserializer};7use serde::{Deserialize, Deserializer};
9use std::fs::{self, DirBuilder, File};8use std::fs::{self, File};
10use std::io::{self, Cursor, Read, Write};9use std::io::{self, Cursor, Read, Write};
11use std::iter;10use std::iter;
12use std::os::unix::prelude::PermissionsExt;11use std::os::unix::prelude::PermissionsExt;
13use std::str::from_utf8;12use std::str::from_utf8;
14use std::{13use std::{collections::HashMap, path::PathBuf};
15 collections::HashMap,
16 os::unix::fs::DirBuilderExt,
17 path::{Path, PathBuf},
18};
1914
20#[derive(Parser)]15#[derive(Parser)]
60fn init_secret(identity: &age::ssh::Identity, value: DataItem) -> Result<()> {55fn init_secret(identity: &age::ssh::Identity, value: DataItem) -> Result<()> {
61 if let Some(public) = &value.public {56 if let Some(public) = &value.public {
62 let mut hashed = File::create(&value.public_path)?;57 let mut hashed = File::create(&value.public_path)?;
63 let mut stable_dir = value.stable_public_path.parent().expect("not root");58 let stable_dir = value.stable_public_path.parent().expect("not root");
64 let mut stable_temp =59 let mut stable_temp =
65 tempfile::NamedTempFile::new_in(stable_dir).context("failed to create tempfile")?;60 tempfile::NamedTempFile::new_in(stable_dir).context("failed to create tempfile")?;
66 hashed.write_all(public.as_bytes())?;61 hashed.write_all(public.as_bytes())?;
91 .context("failed to get group")?86 .context("failed to get group")?
92 .ok_or_else(|| anyhow!("group not found"))?;87 .ok_or_else(|| anyhow!("group not found"))?;
9388
94 let mut stable_dir = value.stable_secret_path.parent().expect("not root");89 let stable_dir = value.stable_secret_path.parent().expect("not root");
95 let mut stable_temp =90 let mut stable_temp =
96 tempfile::NamedTempFile::new_in(stable_dir).context("failed to create tempfile")?;91 tempfile::NamedTempFile::new_in(stable_dir).context("failed to create tempfile")?;
97 let mut hashed = File::create(&value.secret_path)?;92 let mut hashed = File::create(&value.secret_path)?;