Skip to content
Closed
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
54 changes: 29 additions & 25 deletions manifests/07-downloads-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
- '-c'
- |
cat <<EOF >>/tmp/serve.py
import BaseHTTPServer, os, re, signal, SimpleHTTPServer, socket, sys, tarfile, tempfile, threading, time, zipfile
import BaseHTTPServer, errno, os, re, signal, SimpleHTTPServer, socket, sys, tarfile, tempfile, threading, time, zipfile

signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0))

Expand All @@ -85,32 +85,36 @@ spec:
temp_dir = tempfile.mkdtemp()
print('serving from {}'.format(temp_dir))
os.chdir(temp_dir)
for arch in ['amd64']:
for arch in ['amd64', 'arm64', 'ppc64le', 's390x']:
Comment thread
benjaminapetersen marked this conversation as resolved.
os.mkdir(arch)
for operating_system in ['linux', 'mac', 'windows']:
os.mkdir(os.path.join(arch, operating_system))
for arch in ['arm64', 'ppc64le', 's390x']:
os.mkdir(arch)
for operating_system in ['linux']:
os.mkdir(os.path.join(arch, operating_system))
for operating_system in ['linux', 'darwin', 'windows']:
os_path = os.path.join(arch, operating_system)
try:
os.mkdir(os_path)
except OSError as error:
if error.errno != errno.EEXIST:
raise
basename = 'oc'
Comment thread
benjaminapetersen marked this conversation as resolved.
if operating_system == 'windows':
basename += '.exe'
target_path = os.path.join(os_path, basename)
source_path = os.path.join('/usr', 'share', 'openshift', '{}_{}'.format(operating_system, arch), executable)
try:
os.stat(source_path)
except OSError as error:
print('skipping {}/{}: {}'.format(arch, operating_system, error))
continue
os.symlink(source_path, target_path)
source_path = os.path.realpath(source_path)
base_root, _ = os.path.splitext(basename)
archive_path_root = os.path.join(arch, operating_system, base_root)
with tarfile.open('{}.tar'.format(archive_path_root), 'w') as tar:
tar.add(source_path, basename)
with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip:
zip.write(source_path, basename)

for arch, operating_system, path in [
('amd64', 'linux', '/usr/share/openshift/linux_amd64/oc'),
('amd64', 'mac', '/usr/share/openshift/mac/oc'),
('amd64', 'windows', '/usr/share/openshift/windows/oc.exe'),
('arm64', 'linux', '/usr/share/openshift/linux_arm64/oc'),
('ppc64le', 'linux', '/usr/share/openshift/linux_ppc64le/oc'),
('s390x', 'linux', '/usr/share/openshift/linux_s390x/oc'),
]:
basename = os.path.basename(path)
target_path = os.path.join(arch, operating_system, basename)
os.symlink(path, target_path)
base_root, _ = os.path.splitext(basename)
archive_path_root = os.path.join(arch, operating_system, base_root)
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)
# backwards compat for old clients. Too bad we can't 301 them...
os.symlink(os.path.join(arch, 'darwin'), os.path.join(arch, 'mac'))

# Create socket
addr = ('', 8080)
Expand Down
2 changes: 1 addition & 1 deletion pkg/console/controllers/clidownloads/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func PlatformBasedOCConsoleCLIDownloads(host, cliDownloadsName string) *v1.Conso
{"Linux for ARM 64", "arm64/linux", "oc.tar"},
{"Linux for IBM Power, little endian", "ppc64le/linux", "oc.tar"},
{"Linux for IBM Z", "s390x/linux", "oc.tar"},
{"Mac", "amd64/mac", "oc.zip"},
{"Mac", "amd64/darwin", "oc.zip"},
{"Windows 64-bit", "amd64/windows", "oc.zip"},
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/console/controllers/clidownloads/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func TestGetPlatformURL(t *testing.T) {
name: "Test assembling mac specific URL",
args: args{
baseURL: "https://www.example.com/amd64",
platform: "mac",
platform: "darwin",
archiveType: "oc.zip",
},
want: "https://www.example.com/amd64/mac/oc.zip",
want: "https://www.example.com/amd64/darwin/oc.zip",
},
{
name: "Test assembling windows 64-bit specific URL",
Expand Down Expand Up @@ -128,7 +128,7 @@ The oc binary offers the same capabilities as the kubectl binary, but it is furt
Text: "Download oc for Linux for IBM Z",
},
{
Href: "https://www.example.com/amd64/mac/oc.zip",
Href: "https://www.example.com/amd64/darwin/oc.zip",
Text: "Download oc for Mac",
},
{
Expand Down