From 4d9e3a9aa901aa1c82ae6b9619aa7c0ebb599019 Mon Sep 17 00:00:00 2001 From: Jakub Hadvig Date: Wed, 9 Apr 2025 13:12:01 +0200 Subject: [PATCH 1/2] CONSOLE-4523: Add rhel8 and rhel9 oc binaries for Linux OS in CLI downloads --- .../deployments/downloads-deployment.yaml | 13 +++++-- .../controllers/clidownloads/controller.go | 12 +++++-- .../clidownloads/controller_test.go | 36 +++++++++++++++++-- test/e2e/downloads_test.go | 1 + 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/bindata/assets/deployments/downloads-deployment.yaml b/bindata/assets/deployments/downloads-deployment.yaml index 428865a65f..525570aef7 100644 --- a/bindata/assets/deployments/downloads-deployment.yaml +++ b/bindata/assets/deployments/downloads-deployment.yaml @@ -126,19 +126,26 @@ spec: for arch, operating_system, path in [ ('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc'), + ('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc.rhel8'), + ('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc.rhel9'), ('amd64', 'mac', '/usr/share/openshift/mac/oc'), ('amd64', 'windows', '/usr/share/openshift/windows/oc.exe'), ('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc'), + ('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc.rhel8'), + ('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc.rhel9'), ('arm64', 'mac', '/usr/share/openshift/mac_arm64/oc'), ('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc'), + ('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc.rhel8'), + ('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc.rhel9'), ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc'), + ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel8'), + ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel9'), ]: basename = os.path.basename(path) target_path = os.path.join(arch, operating_system, basename) - os.mkdir(os.path.join(arch, operating_system)) + os.makedirs(os.path.join(arch, operating_system), exist_ok=True) os.symlink(path, target_path) - base_root, _ = os.path.splitext(basename) - archive_path_root = os.path.join(arch, operating_system, base_root) + archive_path_root = os.path.join(arch, operating_system, basename) with tarfile.open('{}.tar'.format(archive_path_root), 'w') as tar: tar.add(path, basename) with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip: diff --git a/pkg/console/controllers/clidownloads/controller.go b/pkg/console/controllers/clidownloads/controller.go index 6bf0eea8c2..aed9f810d3 100644 --- a/pkg/console/controllers/clidownloads/controller.go +++ b/pkg/console/controllers/clidownloads/controller.go @@ -177,12 +177,20 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso archType string }{ {"Linux for x86_64", "amd64/linux", "oc.tar"}, + {"Linux for x86_64 - RHEL 8", "amd64/linux", "oc.rhel8.tar"}, + {"Linux for x86_64 - RHEL 9", "amd64/linux", "oc.rhel9.tar"}, {"Mac for x86_64", "amd64/mac", "oc.zip"}, - {"Windows for x86_64", "amd64/windows", "oc.zip"}, + {"Windows for x86_64", "amd64/windows", "oc.exe.zip"}, {"Linux for ARM 64", "arm64/linux", "oc.tar"}, + {"Linux for ARM 64 - RHEL 8", "arm64/linux", "oc.rhel8.tar"}, + {"Linux for ARM 64 - RHEL 9", "arm64/linux", "oc.rhel9.tar"}, {"Mac for ARM 64", "arm64/mac", "oc.zip"}, {"Linux for IBM Power, little endian", "ppc64le/linux", "oc.tar"}, + {"Linux for IBM Power, little endian - RHEL 8", "ppc64le/linux", "oc.rhel8.tar"}, + {"Linux for IBM Power, little endian - RHEL 9", "ppc64le/linux", "oc.rhel9.tar"}, {"Linux for IBM Z", "s390x/linux", "oc.tar"}, + {"Linux for IBM Z - RHEL 8", "s390x/linux", "oc.rhel8.tar"}, + {"Linux for IBM Z - RHEL 9", "s390x/linux", "oc.rhel9.tar"}, } links := []v1.CLIDownloadLink{} @@ -205,7 +213,7 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso Spec: v1.ConsoleCLIDownloadSpec{ Description: `With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal. -The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. +The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. You can download oc using the following links. `, DisplayName: "oc - OpenShift Command Line Interface (CLI)", Links: links, diff --git a/pkg/console/controllers/clidownloads/controller_test.go b/pkg/console/controllers/clidownloads/controller_test.go index b67751aba3..f17ef8bafe 100644 --- a/pkg/console/controllers/clidownloads/controller_test.go +++ b/pkg/console/controllers/clidownloads/controller_test.go @@ -116,7 +116,7 @@ func TestPlatformBasedOCConsoleCLIDownloads(t *testing.T) { Spec: v1.ConsoleCLIDownloadSpec{ Description: `With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal. -The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. +The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features. You can download oc using the following links. `, DisplayName: "oc - OpenShift Command Line Interface (CLI)", Links: []v1.CLIDownloadLink{ @@ -124,18 +124,34 @@ The oc binary offers the same capabilities as the kubectl binary, but it is furt Href: "https://www.example.com/amd64/linux/oc.tar", Text: "Download oc for Linux for x86_64", }, + { + Href: "https://www.example.com/amd64/linux/oc.rhel8.tar", + Text: "Download oc for Linux for x86_64 - RHEL 8", + }, + { + Href: "https://www.example.com/amd64/linux/oc.rhel9.tar", + Text: "Download oc for Linux for x86_64 - RHEL 9", + }, { Href: "https://www.example.com/amd64/mac/oc.zip", Text: "Download oc for Mac for x86_64", }, { - Href: "https://www.example.com/amd64/windows/oc.zip", + Href: "https://www.example.com/amd64/windows/oc.exe.zip", Text: "Download oc for Windows for x86_64", }, { Href: "https://www.example.com/arm64/linux/oc.tar", Text: "Download oc for Linux for ARM 64", }, + { + Href: "https://www.example.com/arm64/linux/oc.rhel8.tar", + Text: "Download oc for Linux for ARM 64 - RHEL 8", + }, + { + Href: "https://www.example.com/arm64/linux/oc.rhel9.tar", + Text: "Download oc for Linux for ARM 64 - RHEL 9", + }, { Href: "https://www.example.com/arm64/mac/oc.zip", Text: "Download oc for Mac for ARM 64", @@ -144,10 +160,26 @@ The oc binary offers the same capabilities as the kubectl binary, but it is furt Href: "https://www.example.com/ppc64le/linux/oc.tar", Text: "Download oc for Linux for IBM Power, little endian", }, + { + Href: "https://www.example.com/ppc64le/linux/oc.rhel8.tar", + Text: "Download oc for Linux for IBM Power, little endian - RHEL 8", + }, + { + Href: "https://www.example.com/ppc64le/linux/oc.rhel9.tar", + Text: "Download oc for Linux for IBM Power, little endian - RHEL 9", + }, { Href: "https://www.example.com/s390x/linux/oc.tar", Text: "Download oc for Linux for IBM Z", }, + { + Href: "https://www.example.com/s390x/linux/oc.rhel8.tar", + Text: "Download oc for Linux for IBM Z - RHEL 8", + }, + { + Href: "https://www.example.com/s390x/linux/oc.rhel9.tar", + Text: "Download oc for Linux for IBM Z - RHEL 9", + }, { Href: "https://www.example.com/oc-license", Text: "LICENSE", diff --git a/test/e2e/downloads_test.go b/test/e2e/downloads_test.go index 78e30d0aea..7d74676a94 100644 --- a/test/e2e/downloads_test.go +++ b/test/e2e/downloads_test.go @@ -42,6 +42,7 @@ func TestDownloadsEndpoint(t *testing.T) { req := getRequest(t, link.Href) client := getInsecureClient() resp, err := client.Do(req) + t.Logf("Requesting %s at %s\n", link.Text, link.Href) if err != nil { t.Fatalf("http error getting %s at %s: %s", link.Text, link.Href, err) From b5f83c4bbc98d7f884721930467c67ef6be145d8 Mon Sep 17 00:00:00 2001 From: Krish Agarwal Date: Fri, 19 Dec 2025 16:21:15 +0530 Subject: [PATCH 2/2] Added checks for missing RHEL8/9 binaries --- .../deployments/downloads-deployment.yaml | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/bindata/assets/deployments/downloads-deployment.yaml b/bindata/assets/deployments/downloads-deployment.yaml index 525570aef7..54f93fcdd1 100644 --- a/bindata/assets/deployments/downloads-deployment.yaml +++ b/bindata/assets/deployments/downloads-deployment.yaml @@ -141,20 +141,27 @@ spec: ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel8'), ('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc.rhel9'), ]: + if not os.path.exists(path): + print('Skipping {} (not found)'.format(path)) + continue basename = os.path.basename(path) target_path = os.path.join(arch, operating_system, basename) os.makedirs(os.path.join(arch, operating_system), exist_ok=True) - os.symlink(path, target_path) - archive_path_root = os.path.join(arch, operating_system, basename) - with tarfile.open('{}.tar'.format(archive_path_root), 'w') as tar: - tar.add(path, basename) - with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip: - zip.write(path, basename) - content.append( - 'oc ({1} {2}) (tar zip)'.format( - target_path, arch, operating_system, archive_path_root + try: + os.symlink(path, target_path) + archive_path_root = os.path.join(arch, operating_system, basename) + with tarfile.open('{}.tar'.format(archive_path_root), 'w') as tar: + tar.add(path, basename) + with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip: + zip.write(path, basename) + content.append( + 'oc ({1} {2}) (tar zip)'.format( + target_path, arch, operating_system, archive_path_root + ) ) - ) + except (OSError, FileNotFoundError) as e: + print('Error processing {}: {}, skipping'.format(path, e)) + continue for root, directories, filenames in os.walk(temp_dir): root_link = os.path.relpath(temp_dir, os.path.join(root, 'child')).replace(os.path.sep, '/')