diff --git a/registry/oc.toml b/registry/oc.toml index d256e04bc4..cc836f3632 100644 --- a/registry/oc.toml +++ b/registry/oc.toml @@ -1,3 +1,32 @@ -backends = ["conda:openshift-cli", "asdf:mise-plugins/mise-oc"] description = "OpenShift Client CLI (oc)" +os = ["linux", "macos", "windows"] test = { cmd = "oc version --client", expected = "{{version}}" } + +[[backends]] +full = "http:oc" + +[backends.options] +bin = "oc" +version_list_url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/" +version_regex = 'href="(\d+\.\d+\.\d+)/"' + +[backends.options.platforms.linux-x64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-client-linux-{{ version }}.tar.gz" + +[backends.options.platforms.linux-arm64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-client-linux-arm64-{{ version }}.tar.gz" + +[backends.options.platforms.macos-x64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-client-mac-{{ version }}.tar.gz" + +[backends.options.platforms.macos-arm64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-client-mac-arm64-{{ version }}.tar.gz" + +[backends.options.platforms.windows-x64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-client-windows-{{ version }}.zip" + +[[backends]] +full = "conda:openshift-cli" + +[[backends]] +full = "asdf:mise-plugins/mise-oc" diff --git a/registry/openshift-install.toml b/registry/openshift-install.toml new file mode 100644 index 0000000000..479055a9e1 --- /dev/null +++ b/registry/openshift-install.toml @@ -0,0 +1,23 @@ +description = "OpenShift installer for deploying OpenShift clusters" +os = ["linux", "macos"] +test = { cmd = "openshift-install version", expected = "{{version}}" } + +[[backends]] +full = "http:openshift-install" + +[backends.options] +bin = "openshift-install" +version_list_url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/" +version_regex = 'href="(\d+\.\d+\.\d+)/"' + +[backends.options.platforms.linux-x64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-install-linux-{{ version }}.tar.gz" + +[backends.options.platforms.linux-arm64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-install-linux-arm64-{{ version }}.tar.gz" + +[backends.options.platforms.macos-x64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-install-mac-{{ version }}.tar.gz" + +[backends.options.platforms.macos-arm64] +url = "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{{ version }}/openshift-install-mac-arm64-{{ version }}.tar.gz" diff --git a/src/backend/version_list.rs b/src/backend/version_list.rs index 1f855f8e31..1fd6e0758c 100644 --- a/src/backend/version_list.rs +++ b/src/backend/version_list.rs @@ -27,9 +27,16 @@ pub async fn fetch_versions( ) -> Result> { use crate::http::HTTP; - // Fetch the content - let response = HTTP.get_text(version_list_url).await?; - let content = response.trim(); + let content = if version_regex.is_some() { + // When a regex is provided, the caller expects to parse arbitrary + // content (including HTML directory listings), so bypass the HTML rejection + // in get_text. + let resp = HTTP.get_async(version_list_url).await?; + resp.text().await? + } else { + HTTP.get_text(version_list_url).await? + }; + let content = content.trim(); // Parse versions based on format parse_version_list(content, version_regex, version_json_path, version_expr) @@ -88,9 +95,13 @@ pub fn parse_version_list( } } - // If no versions extracted yet, treat as line-separated or single version - // This provides fallback for all cases including failed JSON parsing - if versions.is_empty() { + // If no versions extracted yet and no explicit extraction method was provided, + // treat as line-separated or single version. + // When version_regex or version_expr is set, zero matches means the content + // didn't contain the expected data — don't fall through to line-splitting + // which would emit garbage (e.g. raw HTML lines as "versions"). + let explicit_method = version_regex.is_some() || version_expr.is_some(); + if versions.is_empty() && !explicit_method { for line in trimmed.lines() { let line = line.trim(); // Skip empty lines and comments