Skip to content

Commit

Permalink
chore: move try catch (#7)
Browse files Browse the repository at this point in the history
* move try catch higher

* formatting

* earlier linting

* screw the linter
  • Loading branch information
nielstenboom authored Nov 21, 2023
1 parent f538f56 commit 466d3ab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
config: packages/k8s/tests/test-kind.yaml
- run: npm install
name: Install dependencies
# - run: npm run format-check
# - name: Check linter
# run: |
# npm run lint
# git diff --exit-code -- ':!packages/k8s/tests/test-kind.yaml'
- run: npm run bootstrap
name: Bootstrap the packages
- run: npm run build-all
name: Build packages
- run: npm run format-check
- name: Check linter
run: |
npm run lint
git diff --exit-code -- ':!packages/k8s/tests/test-kind.yaml'
- name: Run tests
run: npm run test
2 changes: 2 additions & 0 deletions packages/hooklib/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export async function getInputFromStdin(): Promise<HookData> {
return inputJson as HookData
}

//@ts-ignore
export function writeToResponseFile(filePath: string, message: any): void {
if (!filePath) {
throw new Error(`Expected file path`)
Expand All @@ -32,6 +33,7 @@ export function writeToResponseFile(filePath: string, message: any): void {
})
}

//@ts-ignore
function toCommandValue(input: any): string {
if (input === null || input === undefined) {
return ''
Expand Down
8 changes: 4 additions & 4 deletions packages/k8s/src/hooks/prepare-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
PodPhase
} from '../k8s/utils'
import { JOB_CONTAINER_NAME } from './constants'
import { CoreV1EndpointPort, HttpError } from '@kubernetes/client-node'
import { HttpError } from '@kubernetes/client-node'

export async function prepareJob(
args: prepareJobArgs,
Expand All @@ -28,7 +28,7 @@ export async function prepareJob(
throw new Error('Job Container is required.')
}

core.debug("running prepareJob on version 0.3.8")
core.debug('running prepareJob on version 0.3.9')
core.debug(JSON.stringify(args))

await prunePods()
Expand Down Expand Up @@ -181,9 +181,9 @@ export function createContainerSpec(
if (container.workingDirectory) {
podContainer.workingDir = container.workingDirectory
}

const podCommand = container.entryPoint ? [container.entryPoint] : undefined
if (podCommand !== undefined ){
if (podCommand !== undefined) {
podContainer.command = podCommand
}

Expand Down
14 changes: 7 additions & 7 deletions packages/k8s/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {
import { isAuthPermissionsOK, namespace, requiredPermissions } from './k8s'

async function run(): Promise<void> {
const input = await getInputFromStdin()

const args = input['args']
const command = input['command']
const responseFile = input['responseFile']
const state = input['state']

let exitCode = 0
try {
const input = await getInputFromStdin()

const args = input['args']
const command = input['command']
const responseFile = input['responseFile']
const state = input['state']

if (!(await isAuthPermissionsOK())) {
throw new Error(
`The Service account needs the following permissions ${JSON.stringify(
Expand Down
1 change: 1 addition & 0 deletions packages/k8s/src/k8s/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export async function createPod(
*
* https://lodash.com/docs/4.17.15#mergeWith
*/
//@ts-ignore
function podSpecCustomizer(objValue, srcValue, key): any[] | undefined {
if (['image', 'name', 'command', 'args'].includes(key)) {
return objValue
Expand Down

0 comments on commit 466d3ab

Please sign in to comment.