Skip to content

Commit

Permalink
feat: move more tools away from asdf (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Nov 24, 2024
1 parent 26a144b commit 7480254
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 129 deletions.
70 changes: 35 additions & 35 deletions docs/registry.md

Large diffs are not rendered by default.

122 changes: 84 additions & 38 deletions registry.toml

Large diffs are not rendered by default.

24 changes: 2 additions & 22 deletions remaining-asdf-plugins.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
asdf:pitch-io/asdf-babashka
asdf:boatkit-io/asdf-balena-cli
asdf:pcrockett/asdf-bashly
asdf:vhdirk/asdf-bat-extras
asdf:johnlayton/asdf-batect
asdf:timgluz/asdf-bats
asdf:rajatvig/asdf-bazel
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:benthosdev/benthos-asdf
asdf:virtualroot/asdf-bfs
asdf:vixus0/asdf-bitwarden
asdf:asdf-community/asdf-bitwarden-secrets-manager
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:bpkg/asdf-bpkg
asdf:Ibotta/asdf-brig
asdf:joschi/asdf-btrace
asdf:johnlayton/asdf-buildpack
asdf:jonathanmorley/asdf-bundler

asdf:FeryET/asdf-calendarsync
asdf:barmac/asdf-camunda-modeler
asdf:mise-plugins/asdf-cargo-make
Expand Down Expand Up @@ -58,10 +44,10 @@ asdf:s3than/asdf-coredns
asdf:jiahuili430/asdf-coursier
asdf:dmpe/asdf-crane
asdf:sqtran/asdf-crc
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:joke/asdf-crossplane-cli
asdf:asdf-community/asdf-crystal
asdf:xeedio/asdf-cyclonedx

asdf:MontakOleg/asdf-danger-js
asdf:asdf-community/asdf-dapr-cli
asdf:PatOConnor43/asdf-dart
Expand Down Expand Up @@ -172,7 +158,6 @@ asdf:comdotlinux/asdf-ki
asdf:joke/asdf-kn
asdf:susurri/asdf-koka
asdf:asdf-community/asdf-kotlin
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:asdf-community/asdf-kpack-cli
asdf:nlamirault/asdf-kpt
asdf:ohkrab/asdf-krab
Expand Down Expand Up @@ -245,7 +230,6 @@ asdf:sqtran/asdf-oc
asdf:asdf-community/asdf-ocaml
asdf:yasn77/asdf-oci
asdf:jtakakura/asdf-odin
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:jtakakura/asdf-onyx
asdf:asdf-community/asdf-opam
asdf:zekker6/asdf-faas-cli
Expand All @@ -266,7 +250,6 @@ asdf:asdf-community/asdf-php
asdf:kogeletey/asdf-pipelight
asdf:mise-plugins/mise-pipenv
asdf:yozachar/asdf-pipx
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:tvon/asdf-podman
asdf:mise-plugins/mise-poetry
asdf:knu/asdf-postgis
Expand All @@ -275,7 +258,6 @@ asdf:dex4er/asdf-powerline-go
asdf:daveneeley/asdf-powershell-core
asdf:asdf-community/asdf-promtool
asdf:dylanrayboss/asdf-protoc-gen-connect-go
asdf:pbr0ck3r/asdf-protoc-gen-go-grpc
asdf:pbr0ck3r/asdf-protoc-gen-grpc-web
asdf:pbr0ck3r/asdf-protoc-gen-js
asdf:augustobmoura/asdf-protonge
Expand Down Expand Up @@ -346,7 +328,6 @@ asdf:younke/asdf-swiftgen
asdf:klundberg/asdf-swiftlint
asdf:mracos/asdf-swiprolog
asdf:nwillc/syncher
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:johnhamelink/asdf-tekton-cli
asdf:MaloPolese/asdf-teleport-community
asdf:highb/asdf-teleport-ent
Expand All @@ -366,7 +347,6 @@ asdf:Dabolus/asdf-traefik
asdf:virtualstaticvoid/asdf-tsuru
asdf:asdf-community/asdf-tuist
asdf:ORCID/asdf-transifex
asdf:vmware-tanzu/tanzu-plug-in-for-asdf
asdf:susurri/asdf-unison
asdf:ORCID/asdf-upt
asdf:jimmidyson/asdf-upx
Expand Down
42 changes: 28 additions & 14 deletions src/aqua/aqua_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::config::SETTINGS;
use crate::duration::DAILY;
use crate::git::Git;
use crate::{dirs, file, hashmap, http};
use eyre::Result;
use eyre::{ContextCompat, Result};
use indexmap::IndexSet;
use itertools::Itertools;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -61,6 +61,7 @@ pub struct AquaPackage {
pub files: Vec<AquaFile>,
pub replacements: HashMap<String, String>,
pub version_prefix: Option<String>,
pub version_filter: Option<String>,
pub checksum: Option<AquaChecksum>,
pub slsa_provenance: Option<AquaSlsaProvenance>,
overrides: Vec<AquaOverride>,
Expand Down Expand Up @@ -165,31 +166,44 @@ impl AquaRegistry {
Ok(Self { path, repo_exists })
}

pub fn package(&self, id: &str) -> Result<Option<AquaPackage>> {
pub fn package(&self, id: &str) -> Result<AquaPackage> {
let path_id = id.split('/').join(std::path::MAIN_SEPARATOR_STR);
let path = self.path.join("pkgs").join(&path_id).join("registry.yaml");
if !self.repo_exists {
let registry: RegistryYaml = if !self.repo_exists {
if let Some(registry) = AQUA_STANDARD_REGISTRY_FILES.get(id) {
let registry: RegistryYaml = serde_yaml::from_str(registry)?;
return Ok(registry.packages.into_iter().next());
serde_yaml::from_str(registry)?
} else if !path.exists() || file::modified_duration(&path)? > DAILY {
let url: Url =
format!("https://mise-versions.jdx.dev/aqua-registry/{path_id}/registry.yaml")
.parse()?;
http::HTTP_FETCH.download_file(url, &path, None)?;
serde_yaml::from_reader(file::open(&path)?)?
} else {
serde_yaml::from_reader(file::open(&path)?)?
}
} else {
serde_yaml::from_reader(file::open(&path)?)?
};
let mut pkg = registry
.packages
.into_iter()
.next()
.wrap_err(format!("no package found for {id} in {path:?}"))?;
if let Some(filter) = &pkg.version_filter {
if let Some(filter) = filter.strip_prefix("Version startsWith") {
pkg.version_prefix = Some(
pkg.version_prefix
.unwrap_or(filter.trim().trim_matches('"').to_string()),
);
} else {
warn!("unsupported version filter: {filter}");
}
}
let f = file::open(&path)?;
let registry: RegistryYaml = serde_yaml::from_reader(f)?;
Ok(registry.packages.into_iter().next())
Ok(pkg)
}

pub fn package_with_version(&self, id: &str, v: &str) -> Result<Option<AquaPackage>> {
if let Some(pkg) = self.package(id)? {
Ok(Some(pkg.with_version(v)))
} else {
Ok(None)
}
pub fn package_with_version(&self, id: &str, v: &str) -> Result<AquaPackage> {
Ok(self.package(id)?.with_version(v))
}
}

Expand Down
25 changes: 7 additions & 18 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ impl Backend for AquaBackend {
fn _list_remote_versions(&self) -> eyre::Result<Vec<String>> {
self.remote_version_cache
.get_or_try_init(|| {
if let Some(pkg) = AQUA_REGISTRY.package(&self.id)? {
if !pkg.repo_owner.is_empty() && !pkg.repo_name.is_empty() {
Ok(
github::list_releases(&format!(
"{}/{}",
pkg.repo_owner, pkg.repo_name
))?
let pkg = AQUA_REGISTRY.package(&self.id)?;
if !pkg.repo_owner.is_empty() && !pkg.repo_name.is_empty() {
Ok(
github::list_releases(&format!("{}/{}", pkg.repo_owner, pkg.repo_name))?
.into_iter()
.filter_map(|r| {
let mut v = r.tag_name.as_str();
Expand All @@ -64,11 +61,7 @@ impl Backend for AquaBackend {
})
.rev()
.collect_vec(),
)
} else {
warn!("no aqua registry found for {}", self.ba);
Ok(vec![])
}
)
} else {
warn!("no aqua registry found for {}", self.ba);
Ok(vec![])
Expand All @@ -83,9 +76,7 @@ impl Backend for AquaBackend {
mut tv: ToolVersion,
) -> eyre::Result<ToolVersion> {
let mut v = format!("v{}", tv.version);
let pkg = AQUA_REGISTRY
.package_with_version(&self.id, &v)?
.wrap_err_with(|| format!("no aqua registry found for {}", self.id))?;
let pkg = AQUA_REGISTRY.package_with_version(&self.id, &v)?;
if let Some(prefix) = &pkg.version_prefix {
v = format!("{}{}", prefix, v);
}
Expand All @@ -110,9 +101,7 @@ impl Backend for AquaBackend {
}

fn list_bin_paths(&self, tv: &ToolVersion) -> Result<Vec<PathBuf>> {
let pkg = AQUA_REGISTRY
.package_with_version(&self.id, &tv.version)?
.wrap_err_with(|| format!("no aqua registry found for {}", self.ba))?;
let pkg = AQUA_REGISTRY.package_with_version(&self.id, &tv.version)?;

let srcs = self.srcs(&pkg, tv)?;
if srcs.is_empty() {
Expand Down
9 changes: 7 additions & 2 deletions src/cli/test_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::tera::{get_tera, BASE_CONTEXT};
use crate::toolset::{InstallOptions, ToolsetBuilder};
use crate::ui::time;
use crate::{dirs, env, file};
use eyre::{eyre, Result};
use eyre::{bail, eyre, Result};
use std::path::PathBuf;

/// Test a tool installs and executes
Expand Down Expand Up @@ -43,6 +43,7 @@ impl TestTool {
"---".to_string(),
"---".to_string(),
])?;
let mut found = self.all;
for (i, (short, rt)) in REGISTRY.iter().enumerate() {
if *env::TEST_TRANCHE_COUNT > 0 && (i % *env::TEST_TRANCHE_COUNT) != *env::TEST_TRANCHE
{
Expand All @@ -53,6 +54,7 @@ impl TestTool {
if t.short != tool.short {
continue;
}
found = true;
tool = t.clone();
}
if self.all && rt.short != *short {
Expand Down Expand Up @@ -87,8 +89,11 @@ impl TestTool {
}
};
}
if !found {
bail!("{} not found", self.tool.unwrap().short);
}
if !errored.is_empty() {
return Err(eyre!("tools failed: {}", errored.join(", ")));
bail!("tools failed: {}", errored.join(", "));
}
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub fn ensure_checksum(
"md5" => file_hash_prog::<Md5>(path, pr)?,
_ => bail!("Unknown checksum algorithm: {}", algo),
};
let checksum = checksum.to_lowercase();
if actual != checksum {
bail!("Checksum mismatch for file {}:\nExpected: {algo}:{checksum}\nActual: {algo}:{actual}",
display_path(path));
Expand Down

0 comments on commit 7480254

Please sign in to comment.