Skip to content

Commit

Permalink
feat: support non-x86 architecture
Browse files Browse the repository at this point in the history
Reviewed-by: Avi Miller <[email protected]>
  • Loading branch information
galovics authored and Djelibeybi committed Jun 17, 2024
1 parent b18d83d commit 77a733d
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 11 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/test-configure-kubectl-oke-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ on:
- main
workflow_dispatch:

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test-action-home-region:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
name: Sanity test the action in the tenancy home region
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

steps:
- name: Configure Kubectl
uses: oracle-actions/configure-kubectl-oke@v1.4.0
uses: oracle-actions/configure-kubectl-oke@v1.5.0
id: test-configure-kubectl-oke-action
with:
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
Expand All @@ -72,7 +72,7 @@ jobs:
steps:
- name: Configure Kubectl
uses: oracle-actions/configure-kubectl-oke@v1.4.0
uses: oracle-actions/configure-kubectl-oke@v1.5.0
id: test-configure-kubectl-oke-action
with:
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
Expand Down
31 changes: 30 additions & 1 deletion dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oracle-actions/configure-kubectl-oke",
"description": "GitHub Action to install and configure Kubectl for the specified Oracle Engine for Kubernetes (OKE) cluster",
"version": "1.4.0",
"version": "1.5.0",
"author": {
"name": "Oracle Cloud Infrastructure",
"email": "[email protected]"
Expand Down
38 changes: 35 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,40 @@ import * as tc from "@actions/tool-cache"
import * as ce from "oci-containerengine"
import { Region, SimpleAuthenticationDetailsProvider, getStringFromResponseBody } from "oci-common"

const mapArch = (arch: string): string => {
const mappings = {
x32: "386",
x64: "amd64",
arm: "arm64",
arm64: "arm64"
}
return mappings[arch as keyof typeof mappings]
}

const mapOS = (osPlatform: string): string => {
const mappings = {
darwin: "darwin",
win32: "windows",
linux: "linux"
}
return mappings[osPlatform as keyof typeof mappings]
}

const getArch = (): string => {
return mapArch(os.arch())
}

const getPlatform = (): string => {
return mapOS(os.platform())
}

const getDownloadURL = (version: string): string => {
const arch = getArch()
const platform = getPlatform()
const fileSuffix = platform === "windows" ? ".exe" : ""
return `https://dl.k8s.io/release/${version}/bin/${platform}/${arch}/kubectl${fileSuffix}`
}

/**
* This function checks the local tools-cache before installing
* kubectl from upstream.
Expand All @@ -25,9 +59,7 @@ async function getKubectl(version: string): Promise<string> {
let cachedKubectl = tc.find("kubectl", version)

if (!cachedKubectl) {
const kubectl = await tc.downloadTool(
`https://storage.googleapis.com/kubernetes-release/release/${version}/bin/linux/amd64/kubectl`
)
const kubectl = await tc.downloadTool(getDownloadURL(version))
cachedKubectl = await tc.cacheFile(kubectl, "kubectl", "kubectl", version)
}

Expand Down

0 comments on commit 77a733d

Please sign in to comment.