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

chore: return types for logger,tls,validate-request #1588

Merged
merged 5 commits into from
Dec 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
4 changes: 3 additions & 1 deletion src/lib/telemetry/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
const transport = isPrettyLog ? pretty : undefined;
// epochTime is the pino default
const pinoTimeFunction =
process.env.PINO_TIME_STAMP === "iso" ? () => stdTimeFunctions.isoTime() : () => stdTimeFunctions.epochTime();
process.env.PINO_TIME_STAMP === "iso"
? (): string => stdTimeFunctions.isoTime()

Check warning on line 22 in src/lib/telemetry/logger.ts

View check run for this annotation

Codecov / codecov/patch

src/lib/telemetry/logger.ts#L22

Added line #L22 was not covered by tests
: (): string => stdTimeFunctions.epochTime();
const Log = pino({
transport,
timestamp: pinoTimeFunction,
Expand Down
6 changes: 5 additions & 1 deletion src/lib/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export function genTLS(name: string): TLSOut {
return { ca, key, crt, pem };
}

function genCert(key: forge.pki.rsa.KeyPair, name: string, issuer: forge.pki.CertificateField[]) {
function genCert(
key: forge.pki.rsa.KeyPair,
name: string,
issuer: forge.pki.CertificateField[],
): forge.pki.Certificate {
const crt = forge.pki.createCertificate();
crt.publicKey = key.publicKey;
crt.serialNumber = "01";
Expand Down
8 changes: 4 additions & 4 deletions src/lib/validate-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export class PeprValidateRequest<T extends KubernetesObject> {
* Provides access to the old resource in the request if available.
* @returns The old Kubernetes resource object or null if not available.
*/
get OldResource() {
get OldResource(): KubernetesObject | undefined {
return this.#input.oldObject;
}

/**
* Provides access to the request object.
* @returns The request object containing the Kubernetes resource.
*/
get Request() {
get Request(): AdmissionRequest<KubernetesObject> {
return this.#input;
}

Expand Down Expand Up @@ -61,7 +61,7 @@ export class PeprValidateRequest<T extends KubernetesObject> {
* @param key the label key to check
* @returns
*/
HasLabel = (key: string) => {
HasLabel = (key: string): boolean => {
return this.Raw.metadata?.labels?.[key] !== undefined;
};

Expand All @@ -71,7 +71,7 @@ export class PeprValidateRequest<T extends KubernetesObject> {
* @param key the annotation key to check
* @returns
*/
HasAnnotation = (key: string) => {
HasAnnotation = (key: string): boolean => {
return this.Raw.metadata?.annotations?.[key] !== undefined;
};

Expand Down
Loading