Skip to content

Commit 77a733d

Browse files
galovicsDjelibeybi
authored andcommitted
feat: support non-x86 architecture
Reviewed-by: Avi Miller <[email protected]>
1 parent b18d83d commit 77a733d

File tree

7 files changed

+82
-11
lines changed

7 files changed

+82
-11
lines changed

.github/workflows/test-configure-kubectl-oke-action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ on:
99
- main
1010
workflow_dispatch:
1111

12+
concurrency:
13+
group: ${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
1216
permissions:
1317
contents: read
1418

1519
jobs:
1620
test-action-home-region:
17-
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os:
25+
- ubuntu-latest
26+
- macos-latest
27+
runs-on: ${{ matrix.os }}
1828
name: Sanity test the action in the tenancy home region
1929
env:
2030
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Configure Kubectl
48-
uses: oracle-actions/configure-kubectl-oke@v1.4.0
48+
uses: oracle-actions/configure-kubectl-oke@v1.5.0
4949
id: test-configure-kubectl-oke-action
5050
with:
5151
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
@@ -72,7 +72,7 @@ jobs:
7272
7373
steps:
7474
- name: Configure Kubectl
75-
uses: oracle-actions/configure-kubectl-oke@v1.4.0
75+
uses: oracle-actions/configure-kubectl-oke@v1.5.0
7676
id: test-configure-kubectl-oke-action
7777
with:
7878
cluster: ${{ secrets.OKE_CLUSTER_OCID }}

dist/index.js

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@oracle-actions/configure-kubectl-oke",
33
"description": "GitHub Action to install and configure Kubectl for the specified Oracle Engine for Kubernetes (OKE) cluster",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"author": {
66
"name": "Oracle Cloud Infrastructure",
77
"email": "[email protected]"

src/main.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,40 @@ import * as tc from "@actions/tool-cache"
1414
import * as ce from "oci-containerengine"
1515
import { Region, SimpleAuthenticationDetailsProvider, getStringFromResponseBody } from "oci-common"
1616

17+
const mapArch = (arch: string): string => {
18+
const mappings = {
19+
x32: "386",
20+
x64: "amd64",
21+
arm: "arm64",
22+
arm64: "arm64"
23+
}
24+
return mappings[arch as keyof typeof mappings]
25+
}
26+
27+
const mapOS = (osPlatform: string): string => {
28+
const mappings = {
29+
darwin: "darwin",
30+
win32: "windows",
31+
linux: "linux"
32+
}
33+
return mappings[osPlatform as keyof typeof mappings]
34+
}
35+
36+
const getArch = (): string => {
37+
return mapArch(os.arch())
38+
}
39+
40+
const getPlatform = (): string => {
41+
return mapOS(os.platform())
42+
}
43+
44+
const getDownloadURL = (version: string): string => {
45+
const arch = getArch()
46+
const platform = getPlatform()
47+
const fileSuffix = platform === "windows" ? ".exe" : ""
48+
return `https://dl.k8s.io/release/${version}/bin/${platform}/${arch}/kubectl${fileSuffix}`
49+
}
50+
1751
/**
1852
* This function checks the local tools-cache before installing
1953
* kubectl from upstream.
@@ -25,9 +59,7 @@ async function getKubectl(version: string): Promise<string> {
2559
let cachedKubectl = tc.find("kubectl", version)
2660

2761
if (!cachedKubectl) {
28-
const kubectl = await tc.downloadTool(
29-
`https://storage.googleapis.com/kubernetes-release/release/${version}/bin/linux/amd64/kubectl`
30-
)
62+
const kubectl = await tc.downloadTool(getDownloadURL(version))
3163
cachedKubectl = await tc.cacheFile(kubectl, "kubectl", "kubectl", version)
3264
}
3365

0 commit comments

Comments
 (0)