Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions vdev/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use anyhow::{Context as _, Result, bail};
use indicatif::{ProgressBar, ProgressStyle};
use log::LevelFilter;

use crate::{config::Config, git, platform, util};
use crate::utils::{self, config::Config, platform};

// Use the `bash` interpreter included as part of the standard `git` install for our default shell
// if nothing is specified in the environment.
Expand Down Expand Up @@ -50,12 +50,12 @@ pub fn set_repo_dir() -> Result<()> {
}

pub fn version() -> Result<String> {
let mut version = util::get_version()?;
let mut version = utils::cargo::get_version()?;

let channel = util::get_channel();
let channel = utils::git::get_channel();

if channel == "release" {
let head = util::git_head()?;
let head = utils::git::git_head()?;
if !head.status.success() {
let error = String::from_utf8_lossy(&head.stderr);
bail!("Error running `git describe`:\n{error}");
Expand All @@ -69,7 +69,7 @@ pub fn version() -> Result<String> {

// extend version for custom builds if not already
} else if channel == "custom" && !version.contains("custom") {
let sha = git::get_git_sha()?;
let sha = utils::git::get_git_sha()?;

// use '.' instead of '-' or '_' to avoid issues with rpm and deb package naming
// format requirements.
Expand Down
6 changes: 3 additions & 3 deletions vdev/src/commands/build/publish_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use chrono::prelude::*;

use crate::{git, util};
use crate::utils::{cargo, git};
use std::env;
use std::fs::OpenOptions;
use std::io::{self, Write};
Expand All @@ -19,14 +19,14 @@ pub struct Cli {}
impl Cli {
pub fn exec(self) -> Result<()> {
// Generate the Vector version and build description.
let version = util::get_version()?;
let version = cargo::get_version()?;

let git_sha = git::get_git_sha()?;
let current_date = Local::now().naive_local().to_string();
let build_desc = format!("{git_sha} {current_date}");

// Figure out what our release channel is.
let channel = util::get_channel();
let channel = git::get_channel();

let mut output_file: Box<dyn Write> = match env::var("GITHUB_OUTPUT") {
Ok(file_name) if !file_name.is_empty() => {
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/build/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::Command;
use anyhow::Result;
use clap::Args;

use crate::{app::CommandExt as _, platform};
use crate::{app::CommandExt as _, utils::platform};

/// Build the `vector` executable.
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/check/component_docs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::git;
use crate::utils::git;
use anyhow::{Ok, Result};

/// Check that component documentation is up-to-date
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/check/component_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env;

use anyhow::Result;

use crate::{app, util::CargoToml};
use crate::{app, utils::cargo::CargoToml};

const CARGO: &str = "cargo";
const BASE_ARGS: [&str; 5] = [
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/check/markdown.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;

use crate::app;
use crate::git::git_ls_files;
use crate::utils::git::git_ls_files;

/// Check that markdown is styled properly
#[derive(clap::Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/check/rust.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use std::ffi::OsString;

use crate::{app, git, util::ChainArgs as _};
use crate::{app, utils::command::ChainArgs as _, utils::git};

/// Check the Rust code for errors
#[derive(clap::Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/check/scripts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;

use crate::{app, git};
use crate::{app, utils::git};

/// Check that shell scripts do not have common mistakes
#[derive(clap::Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/compose_tests/show.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use std::collections::HashSet;

use crate::{environment::Environment, testing::config::ComposeTestConfig};
use crate::{testing::config::ComposeTestConfig, utils::environment::Environment};

use super::active_projects::{find_active_environment, load_active_projects};

Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/config/find.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Args;

use crate::config;
use crate::utils::config;

/// Locate the config file
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/config/set/org.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Args;

use crate::{app, config};
use crate::{app, utils::config};

/// Set the target Datadog org
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/config/set/repo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Args;

use crate::{app, config, platform};
use crate::{app, utils::{config, platform}};

/// Set the path to the Vector repository
#[derive(Args, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions vdev/src/commands/crate_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clap::Args;
use itertools::Itertools as _;
use regex::Regex;

use crate::{app::CommandExt as _, util};
use crate::{app::CommandExt as _, utils};

/// Show information about crates versions pulled in by all dependencies
#[derive(Args, Debug)]
Expand Down Expand Up @@ -46,7 +46,7 @@ impl Cli {
}

let width = versions.keys().map(String::len).max().unwrap_or(0).max(7);
if *util::IS_A_TTY {
if *utils::IS_A_TTY {
println!("{:width$} Version(s)", "Package");
println!("{:width$} ----------", "-------");
}
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use anyhow::Result;
use clap::Args;

use crate::features;
use crate::utils::features;

/// Extract the set of features required to run a given config
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use clap::Args;

use crate::testing::docker::CONTAINER_TOOL;
use crate::{app, config, platform};
use crate::{app, utils::{config, platform}};

/// Show `vdev` command configuration
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/meta/starship.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Args;

use crate::util::CargoToml;
use crate::utils::cargo::CargoToml;

/// Custom Starship prompt plugin
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/release/channel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;

use crate::util::get_channel;
use crate::utils::git::get_channel;

/// Provide the release channel (release/nightly/custom).
/// This command is intended for use only within GitHub build workflows.
Expand Down
4 changes: 2 additions & 2 deletions vdev/src/commands/release/github.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::app::CommandExt as _;
use crate::util;
use crate::utils::cargo;
use anyhow::{anyhow, Ok, Result};
use glob::glob;
use std::process::Command;
Expand All @@ -20,7 +20,7 @@ impl Cli {
.collect::<Result<Vec<_>, _>>()
.map_err(|e| anyhow!("failed to turn path into string: {:?}", e))?;

let version = util::get_version()?;
let version = cargo::get_version()?;
let mut command = Command::new("gh");
command.in_repo();
command.args(
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/release/homebrew.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::git;
use crate::utils::git;
use anyhow::Result;
use hex;
use reqwest;
Expand Down
13 changes: 4 additions & 9 deletions vdev/src/commands/release/prepare.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![allow(clippy::print_stdout)]
#![allow(clippy::print_stderr)]

use crate::git;
use crate::util::run_command;
use crate::utils::{git, paths};
use anyhow::{anyhow, Result};
use reqwest::blocking::Client;
use semver::Version;
Expand All @@ -15,6 +14,7 @@ use std::process::Command;
use std::{env, fs};
use toml::map::Map;
use toml::Value;
use crate::utils::command::run_command;

const ALPINE_PREFIX: &str = "FROM docker.io/alpine:";
const ALPINE_DOCKERFILE: &str = "distribution/docker/alpine/Dockerfile";
Expand Down Expand Up @@ -57,9 +57,8 @@ struct Prepare {

impl Cli {
pub fn exec(self) -> Result<()> {

let repo_root = get_repo_root();
env::set_current_dir(repo_root.clone())?;
let repo_root = paths::find_repo_root()?;
env::set_current_dir(&repo_root)?;

let prepare = Prepare {
new_vector_version: self.version.clone(),
Expand Down Expand Up @@ -389,10 +388,6 @@ impl Prepare {

// FREE FUNCTIONS AFTER THIS LINE

fn get_repo_root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().to_path_buf()
}

fn get_latest_version_from_vector_tags() -> Result<Version> {
let tags = run_command("git tag --list --sort=-v:refname");
let latest_tag = tags
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/release/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use clap::Args;

use crate::app;
use crate::git;
use crate::utils::git;
use itertools::Itertools;

/// Pushes new versions produced by `make release` to the repository
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{path::PathBuf, process::Command};
use anyhow::{bail, Result};
use clap::Args;

use crate::{app::CommandExt as _, features};
use crate::{app::CommandExt as _, utils::features};

/// Run `vector` with the minimum set of features required by the config file
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/status.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Args;

use crate::git;
use crate::utils::git;

/// Show information about the current environment
#[derive(Args, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vdev/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use anyhow::Result;
use clap::Args;
use std::collections::BTreeMap;

use crate::platform;
use crate::testing::runner::get_agent_test_runner;
use crate::utils::platform;

/// Execute tests
#[derive(Args, Debug)]
Expand Down
18 changes: 4 additions & 14 deletions vdev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
)]

#[macro_use]
mod macros;
mod utils;

mod app;
mod commands;
mod config;
mod environment;
mod features;
mod git;
mod platform;
mod testing;
mod util;

use std::env;

use anyhow::Result;
use clap::Parser;
Expand All @@ -28,13 +21,10 @@ fn main() -> Result<()> {
let cli = Cli::parse();

app::set_global_verbosity(cli.verbose.log_level_filter());
app::set_global_config(config::load()?);
app::set_global_config(utils::config::load()?);

let path = if app::config().repo.is_empty() {
env::current_dir()
.expect("Could not determine current directory")
.display()
.to_string()
utils::paths::find_repo_root()?.display().to_string()
} else {
app::config().repo.clone()
};
Expand Down
8 changes: 5 additions & 3 deletions vdev/src/testing/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ use crate::testing::test_runner_dockerfile;
use crate::{
app,
app::CommandExt,
environment::{Environment, extract_present},
testing::{config::RustToolchainConfig, docker::docker_command},
util::IS_A_TTY,
utils::{
self,
environment::{Environment, extract_present},
},
};

pub const ALL_INTEGRATIONS_FEATURE_FLAG: &str = "all-integration-tests";
Expand All @@ -32,7 +34,7 @@ pub fn prepare_build_command(
command.current_dir(app::path());

// If we're attached to a TTY, show fancy progress
if *IS_A_TTY {
if *utils::IS_A_TTY {
command.args(["--progress", "tty"]);
}

Expand Down
7 changes: 5 additions & 2 deletions vdev/src/testing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use itertools::{self, Itertools};
use serde::{Deserialize, Serialize};
use serde_yaml::Value;

use crate::{app, environment::Environment, util};
use crate::{
app,
utils::{environment::Environment, paths},
};

const FILE_NAME: &str = "test.yaml";
const CONFIG_SUBDIR: &str = "config";
Expand Down Expand Up @@ -246,7 +249,7 @@ impl ComposeTestConfig {
} else {
[entry.path().to_str().unwrap(), FILE_NAME].iter().collect()
};
if util::exists(&config_file)? {
if paths::exists(&config_file)? {
let config = Self::parse_file(&config_file)?;
configs.insert(entry.file_name().into_string().unwrap(), config);
}
Expand Down
Loading
Loading