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 #1595

Merged
merged 2 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: 2 additions & 2 deletions src/cli/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { buildModule, loadModule } from "./build";
import { RootCmd } from "./root";
import { K8s, kind } from "kubernetes-fluent-client";
import { Store } from "../lib/k8s";
export default function (program: RootCmd) {
export default function (program: RootCmd): void {
program
.command("dev")
.description("Setup a local webhook development environment")
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function (program: RootCmd) {
const store = `pepr-${cfg.pepr.uuid}-store`;

// Run the processed javascript file
const runFork = async () => {
const runFork = async (): Promise<void> => {
console.info(`Running module ${path}`);

// Deploy the webhook with a 30 second timeout for debugging, don't force
Expand Down
4 changes: 2 additions & 2 deletions src/cli/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { RootCmd } from "./root";

export default function (program: RootCmd) {
export default function (program: RootCmd): void {
program
.command("format")
.description("Lint and format this Pepr module")
Expand All @@ -28,7 +28,7 @@
* @param validateOnly
* @returns success
*/
export async function peprFormat(validateOnly: boolean) {
export async function peprFormat(validateOnly: boolean): Promise<boolean> {

Check warning on line 31 in src/cli/format.ts

View workflow job for this annotation

GitHub Actions / format

Async function 'peprFormat' has too many statements (23). Maximum allowed is 20
{
try {
const eslint = new ESLint();
Expand Down
2 changes: 1 addition & 1 deletion src/cli/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { confirm, PromptOptions, walkthrough } from "./walkthrough";
import { ErrorList, Errors } from "../../lib/errors";

export default function (program: RootCmd) {
export default function (program: RootCmd): void {
let response = {} as PromptOptions;
let pkgOverride = "";
program
Expand All @@ -46,7 +46,7 @@
Object.entries(response).map(([key, value]) => thisCommand.setOptionValue(key, value));
}
})
.action(async opts => {

Check warning on line 49 in src/cli/init/index.ts

View workflow job for this annotation

GitHub Actions / format

Async arrow function has too many statements (28). Maximum allowed is 20
const dirName = sanitizeName(response.name);
const packageJSON = genPkgJSON(response, pkgOverride);
const peprTS = genPeprTS();
Expand Down
6 changes: 3 additions & 3 deletions src/cli/init/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { promises as fs } from "fs";
* @param name the user input name
* @returns the sanitized name
*/
export function sanitizeName(name: string) {
export function sanitizeName(name: string): string {
if (typeof name !== "string") {
throw TypeError(
`sanitizeName() was called with a non-string value. The value is: ${name} of type ${typeof name}`,
Expand All @@ -32,7 +32,7 @@ export function sanitizeName(name: string) {
*
* @param dir - The directory to create
*/
export async function createDir(dir: string) {
export async function createDir(dir: string): Promise<void> {
try {
await fs.mkdir(dir);
} catch (err) {
Expand All @@ -51,7 +51,7 @@ export async function createDir(dir: string) {
* @param data - The data to write
* @returns A promise that resolves when the file has been written
*/
export function write(path: string, data: unknown) {
export function write(path: string, data: unknown): Promise<void> {
// If the data is not a string, stringify it
if (typeof data !== "string") {
data = JSON.stringify(data, null, 2);
Expand Down
10 changes: 5 additions & 5 deletions src/lib/assets/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { webhookConfig } from "./webhooks";
import { CapabilityExport, ImagePullSecret } from "../types";

export async function deployImagePullSecret(imagePullSecret: ImagePullSecret, name: string) {
export async function deployImagePullSecret(imagePullSecret: ImagePullSecret, name: string): Promise<void> {
try {
await K8s(kind.Namespace).Get("pepr-system");
} catch {
Expand All @@ -42,7 +42,7 @@
Log.error(e);
}
}
export async function deploy(assets: Assets, force: boolean, webhookTimeout?: number) {
export async function deploy(assets: Assets, force: boolean, webhookTimeout?: number): Promise<void> {

Check warning on line 45 in src/lib/assets/deploy.ts

View workflow job for this annotation

GitHub Actions / format

Async function 'deploy' has too many statements (27). Maximum allowed is 20
Log.info("Establishing connection to Kubernetes");

const { name, host, path } = assets;
Expand Down Expand Up @@ -95,7 +95,7 @@
capabilities: CapabilityExport[],
force: boolean,
config: { rbacMode?: string; rbac?: PolicyRule[] },
) {
): Promise<void> {
const { rbacMode, rbac } = config;

Log.info("Applying cluster role binding");
Expand All @@ -119,7 +119,7 @@
await K8s(kind.RoleBinding).Apply(roleBinding, { force });
}

async function setupController(assets: Assets, code: Buffer, hash: string, force: boolean) {
async function setupController(assets: Assets, code: Buffer, hash: string, force: boolean): Promise<void> {
const { name } = assets;

Log.info("Applying module secret");
Expand All @@ -144,7 +144,7 @@
}

// Setup the watcher deployment and service
async function setupWatcher(assets: Assets, hash: string, force: boolean) {
async function setupWatcher(assets: Assets, hash: string, force: boolean): Promise<void> {
// If the module has a watcher, deploy it
const watchDeployment = getWatcher(assets, hash, assets.buildTimestamp);
if (watchDeployment) {
Expand Down
Loading