Skip to content

Commit

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

Create return types on SDK, removed a frivolous log that does not
provide any good info to a user.

End to End Test:  <!-- if applicable -->  
(See [Pepr Excellent
Examples](https://github.com/defenseunicorns/pepr-excellent-examples))

## Related Issue

Fixes #1452 
<!-- 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 5, 2024
1 parent 72ed2ef commit 7aaeb5d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

import { PeprValidateRequest } from "../lib/validate-request";
import { PeprMutateRequest } from "../lib/mutate-request";
import { V1OwnerReference } from "@kubernetes/client-node";
import { GenericKind } from "kubernetes-fluent-client";
import { K8s, kind } from "kubernetes-fluent-client";
import Log from "../lib/logger";
import { V1OwnerReference, V1Container } from "@kubernetes/client-node";
import { GenericKind, K8s, kind } from "kubernetes-fluent-client";

/**
* Returns all containers in a pod
Expand All @@ -17,7 +15,7 @@ import Log from "../lib/logger";
export function containers(
request: PeprValidateRequest<kind.Pod> | PeprMutateRequest<kind.Pod>,
containerType?: "containers" | "initContainers" | "ephemeralContainers",
) {
): V1Container[] {
const containers = request.Raw.spec?.containers || [];
const initContainers = request.Raw.spec?.initContainers || [];
const ephemeralContainers = request.Raw.spec?.ephemeralContainers || [];
Expand All @@ -44,16 +42,15 @@ export function containers(
* @param reportingComponent The component that is reporting the event, for example "uds.dev/operator"
* @param reportingInstance The instance of the component that is reporting the event, for example process.env.HOSTNAME
*/

export async function writeEvent(
cr: GenericKind,
event: Partial<kind.CoreEvent>,
eventType: string,
eventReason: string,
reportingComponent: string,
reportingInstance: string,
) {
Log.debug(cr.metadata, `Writing event: ${event.message}`);

): Promise<void> {
await K8s(kind.CoreEvent).Create({
type: eventType,
reason: eventReason,
Expand Down Expand Up @@ -109,7 +106,7 @@ export function getOwnerRefFrom(
* @param name the name of the resource to sanitize
* @returns the sanitized resource name
*/
export function sanitizeResourceName(name: string) {
export function sanitizeResourceName(name: string): string {
return (
name
// The name must be lowercase
Expand Down

0 comments on commit 7aaeb5d

Please sign in to comment.