Skip to content

Commit

Permalink
chore: document sdk (#919)
Browse files Browse the repository at this point in the history
## Description

Adds documentation around importing the `sdk` package from Pepr.

## Related Issue

Fixes #914
<!-- 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] Test, docs, 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 <cmwylie19@defenseunicorns.com>
  • Loading branch information
cmwylie19 authored Jun 27, 2024
1 parent d256b62 commit 8cb9051
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/030_user-guide/015_sdk.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Pepr SDK

To use, import the `sdk` from the `pepr` package:

```typescript
import { sdk } from "pepr";
```

## `containers`

Returns list of all containers in a pod. Accepts the following parameters:
Expand All @@ -12,24 +18,28 @@ Returns list of all containers in a pod. Accepts the following parameters:
**_Get all containers_**

```typescript
const { containers } = sdk;
let result = containers(peprValidationRequest)
```

**_Get only the standard containers_**

```typescript
const { containers } = sdk;
let result = containers(peprValidationRequest, "containers")
```

**_Get only the init containers_**

```typescript
const { containers } = sdk;
let result = containers(peprValidationRequest, "initContainers")
```

**_Get only the ephemeral containers_**

```typescript
const { containers } = sdk;
let result = containers(peprValidationRequest, "ephemeralContainers")
```

Expand All @@ -44,6 +54,7 @@ Returns the owner reference for a Kubernetes resource. Accepts the following par
**Usage:**

```typescript
const { getOwnerRefFrom } = sdk;
const ownerRef = getOwnerRefFrom(kubernetesResource);
```

Expand All @@ -63,6 +74,7 @@ Write a K8s event for a CRD. Accepts the following parameters:
**Usage:**

```typescript
const { writeEvent } = sdk;
writeEvent(
kubernetesResource,
event,
Expand All @@ -84,6 +96,7 @@ Returns a sanitized resource name to make the given name a valid Kubernetes reso
**Usage:**

```typescript
const { sanitizeResourceName } = sdk;
const sanitizedResourceName = sanitizeResourceName(resourceName)
```

Expand Down

0 comments on commit 8cb9051

Please sign in to comment.