Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support non-x86 architecture #35

Merged
merged 1 commit into from
Jun 17, 2024
Merged
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
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
Loading