Skip to content

Commit

Permalink
chore: return types (#1595)
Browse files Browse the repository at this point in the history
## Description

Return types 
## Related Issue

Fixes #1553 
<!-- or -->
Relates to #

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging
- [x] Unit,
[Journey](https://github.com/defenseunicorns/pepr/tree/main/journey),
[E2E Tests](https://github.com/defenseunicorns/pepr-excellent-examples),
[docs](https://github.com/defenseunicorns/pepr/tree/main/docs),
[adr](https://github.com/defenseunicorns/pepr/tree/main/adr) added or
updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed

Signed-off-by: Case Wylie <[email protected]>
  • Loading branch information
cmwylie19 authored Dec 17, 2024
1 parent cc590bf commit 53e2ef9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
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 { format, resolveConfig } from "prettier";

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 @@ export default function (program: RootCmd) {
* @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

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 { createDir, sanitizeName, write } from "./utils";
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 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 { peprStoreCRD } from "./store";
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 @@ export async function deployImagePullSecret(imagePullSecret: ImagePullSecret, na
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

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 @@ async function setupRBAC(
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 @@ async function setupRBAC(
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 @@ async function setupController(assets: Assets, code: Buffer, hash: string, force
}

// 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

0 comments on commit 53e2ef9

Please sign in to comment.