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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ opt-level = 3

[dependencies]
base64 = "0.22"
bzip2 = "0.4"
calm_io = "0.1"
chrono = { version = "0.4", default-features = false, features = [
"std",
Expand Down
328 changes: 164 additions & 164 deletions docs/registry.md

Large diffs are not rendered by default.

328 changes: 164 additions & 164 deletions registry.toml

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions src/aqua/aqua_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct AquaPackage {
pub supported_envs: Vec<String>,
pub files: Vec<AquaFile>,
pub replacements: HashMap<String, String>,
pub version_prefix: Option<String>,
overrides: Vec<AquaOverride>,
version_constraint: String,
version_overrides: Vec<AquaPackage>,
Expand Down Expand Up @@ -158,17 +159,26 @@ impl AquaPackage {
"tar.gz"
} else if asset.ends_with(".tar.xz") {
"tar.xz"
} else if asset.ends_with(".tar.bz2") {
"tar.bz2"
} else if asset.ends_with(".gz") {
"gz"
} else if asset.ends_with(".xz") {
"xz"
} else if asset.ends_with(".bz2") {
"bz2"
} else if asset.ends_with(".zip") {
"zip"
} else {
"raw"
}
} else {
&self.format
match self.format.as_str() {
"tgz" => "tar.gz",
"txz" => "tar.xz",
"tbz2" => "tar.bz2",
format => format,
}
}
}

Expand Down Expand Up @@ -208,6 +218,8 @@ impl AquaPackage {
let mut ctx = hashmap! {
"Version".to_string() => replace(v),
"OS".to_string() => replace(os),
"GOOS".to_string() => replace(os),
"GOARCH".to_string() => replace(arch),
"Arch".to_string() => replace(arch),
"Format".to_string() => replace(&self.format),
};
Expand All @@ -218,9 +230,24 @@ impl AquaPackage {

impl AquaFile {
pub fn src(&self, pkg: &AquaPackage, v: &str) -> Option<String> {
let asset = pkg.asset(v);
let asset = asset.strip_suffix(".tar.gz").unwrap_or(&asset);
let asset = asset.strip_suffix(".tar.xz").unwrap_or(asset);
let asset = asset.strip_suffix(".tar.bz2").unwrap_or(asset);
let asset = asset.strip_suffix(".gz").unwrap_or(asset);
let asset = asset.strip_suffix(".xz").unwrap_or(asset);
let asset = asset.strip_suffix(".bz2").unwrap_or(asset);
let asset = asset.strip_suffix(".zip").unwrap_or(asset);
let asset = asset.strip_suffix(".tar").unwrap_or(asset);
let asset = asset.strip_suffix(".tgz").unwrap_or(asset);
let asset = asset.strip_suffix(".txz").unwrap_or(asset);
let asset = asset.strip_suffix(".tbz2").unwrap_or(asset);
let ctx = hashmap! {
"AssetWithoutExt".to_string() => asset.to_string(),
};
self.src
.as_ref()
.map(|src| pkg.parse_aqua_str(src, v, &Default::default()))
.map(|src| pkg.parse_aqua_str(src, v, &ctx))
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/aqua/aqua_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ fn parse(mut code: &str, ctx: &Context) -> String {
ops.push(Box::new(|s: &str| s.trim_start_matches('v').to_string()));
}
let mut val = if let Some(key) = code.strip_prefix(".") {
ctx.get(key).unwrap().clone()
if let Some(val) = ctx.get(key) {
val.to_string()
} else {
warn!("unable to find key in context: {key}");
"<ERR>".to_string()
}
} else if code.starts_with('"') && code.ends_with('"') {
// TODO: handle quotes in the middle of code
code[1..code.len() - 1].to_string()
Expand Down
23 changes: 17 additions & 6 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ impl Backend for AquaBackend {
))?
.into_iter()
.map(|r| {
r.tag_name
.strip_prefix('v')
.unwrap_or(&r.tag_name)
.to_string()
let mut v = r.tag_name.strip_prefix('v').unwrap_or(&r.tag_name);
if let Some(prefix) = &pkg.version_prefix {
v = v.strip_prefix(prefix).unwrap_or(v);
}
v.to_string()
})
.rev()
.collect_vec(),
Expand All @@ -72,12 +73,15 @@ impl Backend for AquaBackend {
let pkg = AQUA_REGISTRY
.package_with_version(&self.id, &v)?
.wrap_err_with(|| format!("no aqua registry found for {}", self.id))?;
if let Some(prefix) = &pkg.version_prefix {
v = format!("{}{}", prefix, ctx.tv.version);
}
validate(&pkg)?;
let url = match self.fetch_url(&pkg, &v) {
Ok(url) => url,
Err(_) => {
Err(err) => {
v = ctx.tv.version.to_string();
self.fetch_url(&pkg, &v)?
self.fetch_url(&pkg, &v).map_err(|_| err)?
}
};
let filename = url.split('/').last().unwrap();
Expand All @@ -96,6 +100,11 @@ impl Backend for AquaBackend {
.files
.iter()
.flat_map(|f| {
if let Some(prefix) = &pkg.version_prefix {
return vec![f.src(&pkg, &format!("{}{}", prefix, tv.version))]
.into_iter()
.flatten();
}
vec![
f.src(&pkg, &tv.version),
f.src(&pkg, &format!("v{}", tv.version)),
Expand Down Expand Up @@ -209,6 +218,8 @@ impl AquaBackend {
file::untar_gz(&tarball_path, &install_path)?;
} else if format == "tar.xz" {
file::untar_xz(&tarball_path, &install_path)?;
} else if format == "tar.bz2" {
file::untar_bz2(&tarball_path, &install_path)?;
} else if format == "zip" {
file::unzip(&tarball_path, &install_path)?;
} else if format == "gz" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ToolRequestSet {
),
),
],
BackendArg("jq" -> "asdf:mise-plugins/asdf-jq"): [
BackendArg("jq" -> "aqua:jqlang/jq"): [
Prefix {
backend: BackendArg("jq" -> "asdf:mise-plugins/asdf-jq"),
backend: BackendArg("jq" -> "aqua:jqlang/jq"),
prefix: "1.6",
options: {},
source: MiseToml(
Expand Down Expand Up @@ -91,7 +91,7 @@ ToolRequestSet {
],
},
sources: {
BackendArg("jq" -> "asdf:mise-plugins/asdf-jq"): MiseToml(
BackendArg("jq" -> "aqua:jqlang/jq"): MiseToml(
"~/fixtures/.mise.toml",
),
BackendArg("node" -> "core:node"): MiseToml(
Expand Down
12 changes: 12 additions & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,18 @@ pub fn untar_xz(archive: &Path, dest: &Path) -> Result<()> {
})
}

pub fn untar_bz2(archive: &Path, dest: &Path) -> Result<()> {
// TODO: show progress
debug!("tar -xf {} -C {}", archive.display(), dest.display());
let f = File::open(archive)?;
let tar = bzip2::read::BzDecoder::new(f);
Archive::new(tar).unpack(dest).wrap_err_with(|| {
let archive = display_path(archive);
let dest = display_path(dest);
format!("failed to extract tar: {archive} to {dest}")
})
}

pub fn unzip(archive: &Path, dest: &Path) -> Result<()> {
// TODO: show progress
debug!("unzip {} -d {}", archive.display(), dest.display());
Expand Down
80 changes: 80 additions & 0 deletions tasks/aqua-tester.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
alias m @mise
m registry | grep -v '(core|ubi|aqua|vfox):' | awk '{print $1}'> tmp/missing_asdf_tools
rm -f tmp/pairs
for tool in (cat tmp/missing_asdf_tools)
set -l aqua (cat ../mise-versions/docs/aqua-registry/all | grep "/$tool\$")
if not test -z "$aqua"
echo "$tool aqua:$aqua"
echo "$tool aqua:$aqua" >> tmp/pairs
end
end
for tool in (cat tmp/pairs | gsort -R)
set -l tool (string split " " $tool)
if test -f "tmp/$tool[1]"
continue
end
if test "$tool[1]" = "borg"
continue
end
if test "$tool[1]" = "jiq"
continue
end
if test "$tool[1]" = "eza"
continue
end
if test "$tool[1]" = "gitsign"
continue
end
if test "$tool[1]" = "terraform-lsp"
continue
end
if test "$tool[1]" = "istioctl"
continue
end
set -l cmd "m x $tool[2] -- $tool[1] -v"
echo $cmd
set -l output (m x $tool[2] -- $tool[1] -v)
set -l cmd_status $status
if test "$cmd_status" = "0"
echo OK
rm -f "tmp/$tool[1]"
echo "AQUA: $tool[2]" > "tmp/$tool[1]"
echo "COMMAND: $cmd" >> "tmp/$tool[1]"
echo "OUTPUT: $output" >> "tmp/$tool[1]"
else
set -l cmd "m x $tool[2] -- $tool[1] --version"
echo $cmd
set -l output (m x $tool[2] -- $tool[1] --version)
set -l cmd_status $status
if test "$cmd_status" = "0"
echo OK
rm -f "tmp/$tool[1]"
echo "AQUA: $tool[2]" > "tmp/$tool[1]"
echo "COMMAND: $cmd" >> "tmp/$tool[1]"
echo "OUTPUT: $output" >> "tmp/$tool[1]"
else
if test "$tool[1]" = "odo"
continue
end
if test "$tool[1]" = "iamlive"
continue
end
if test "$tool[1]" = "tridentctl"
continue
end
set -l cmd "m x $tool[2] -- $tool[1] version"
echo $cmd
set -l output (m x $tool[2] -- $tool[1] version)
set -l cmd_status $status
if test "$cmd_status" = "0"
echo OK
rm -f "tmp/$tool[1]"
echo "AQUA: $tool[2]" > "tmp/$tool[1]"
echo "COMMAND: $cmd" >> "tmp/$tool[1]"
echo "OUTPUT: $output" >> "tmp/$tool[1]"
else
echo FAIL $cmd_status
end
end
end
end