Skip to content

Commit 89107ba

Browse files
committed
address comments
1 parent bf84dc3 commit 89107ba

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

action.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ runs:
157157
# github
158158
GITHUB_REF_NAME: "${{ github.ref_name }}"
159159
GITHUB_REPOSITORY: "${{ github.repository }}"
160-
GITHUB_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}"
161-
GITHUB_PAYLOAD_MESSAGE: "${{ github.event.client_payload.message }}"
162160
GITHUB_WORKFLOW_NAME: "${{ github.repository }}/${{ github.run_id }}"
163161
GITHUB_WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
164162

src/__tests__/validate.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('client report-image validation', () => {
66
try {
77
validate({ ENV1: '1', someVal: 'ignored' })
88
} catch (error) {
9-
const expectedErrorMsg = 'Validation Error: ["CF_API_KEY must be provided as environment variable.","CF_IMAGE must be provided as environment variable.","CF_RUNTIME_NAME must be provided as environment variable."]'
9+
const expectedErrorMsg = '["CF_API_KEY must be provided as environment variable.","CF_IMAGE must be provided as environment variable.","CF_RUNTIME_NAME must be provided as environment variable."]'
1010
expect(error.message).toBe(expectedErrorMsg)
1111
return
1212
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import EventSource from 'eventsource'
22

33
import { validate } from './validate'
4-
import { Utils } from './utils'
4+
import { Utils } from './utils'
55
import { errors } from './errors'
66
import { logger, workflowLogger } from './logger'
77

src/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { GraphQLClient, gql } from 'graphql-request'
22
import { get } from 'lodash'
33

44
import { errors } from './errors'
5-
export class Utils {
5+
6+
export namespace Utils {
67
/**
78
* Build image-report url and headers
89
* @param payload
910
*/
10-
static async buildUrlHeaders(payload: Record<string, string | undefined>): Promise<{ url: string, headers: { authorization: string } }> {
11+
export async function buildUrlHeaders(payload: Record<string, string | undefined>): Promise<{ url: string, headers: { authorization: string } }> {
1112
const esc = encodeURIComponent
1213
const headers = { 'authorization': payload['CF_API_KEY']! }
1314
const runtimeName = payload['CF_RUNTIME_NAME']
@@ -16,7 +17,7 @@ export class Utils {
1617
host = payload['CF_HOST']
1718
delete payload['CF_HOST']
1819
} else {
19-
host = await this.getRuntimeIngressHost(runtimeName, headers)
20+
host = await Utils.getRuntimeIngressHost(runtimeName, headers)
2021
delete payload['CF_RUNTIME_NAME']
2122
}
2223
delete payload['CF_API_KEY']
@@ -28,7 +29,7 @@ export class Utils {
2829
return { url, headers }
2930
}
3031

31-
static async getRuntimeIngressHost(runtimeName: string, headers: Record<string, string>, platformHost = 'https://g.codefresh.io'): Promise<string> {
32+
export async function getRuntimeIngressHost(runtimeName: string, headers: Record<string, string>, platformHost = 'https://g.codefresh.io'): Promise<string> {
3233
const graphQLClient = new GraphQLClient(`${platformHost}/2.0/api/graphql`, {
3334
headers
3435
})
@@ -44,12 +45,12 @@ export class Utils {
4445
const ingressHost = get(res, 'runtime.ingressHost')
4546
if (!ingressHost) {
4647
const message = res.runtime ? `ingress host is not defined on your '${runtimeName}' runtime` : `runtime '${runtimeName}' does not exist`
47-
throw new errors.ValidationError(`Validation Error: ${message}`)
48+
throw new errors.ValidationError(message)
4849
}
4950
return ingressHost
5051
}
5152

52-
static tryParseJson = (str: string) => {
53+
export function tryParseJson (str: string) {
5354
try {
5455
return JSON.parse(str)
5556
} catch {

src/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function validate(payload: Record<string, string|undefined>): Record<stri
1919
messages.push(`You can only specify CF_RUNTIME_NAME or CF_HOST. please delete one of them.`)
2020
}
2121
if (messages.length > 0) {
22-
throw new errors.ValidationError(`Validation Error: ${JSON.stringify(messages)}`)
22+
throw new errors.ValidationError(`${JSON.stringify(messages)}`)
2323
}
2424

2525
return filtered

0 commit comments

Comments
 (0)