This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
4,250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"env": { | ||
"browser": false, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": [ | ||
"./tsconfig.json" | ||
], | ||
"ecmaVersion": 2022 | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"ignorePatterns": [ | ||
"node_modules", | ||
"dist" | ||
], | ||
"root": true, | ||
"rules": { | ||
"@typescript-eslint/no-floating-promises": [ | ||
"error" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore node_modules and Pepr build artifacts | ||
node_modules | ||
dist | ||
insecure* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"bracketSameLine": false, | ||
"bracketSpacing": true, | ||
"embeddedLanguageFormatting": "auto", | ||
"insertPragma": false, | ||
"printWidth": 80, | ||
"quoteProps": "as-needed", | ||
"requirePragma": false, | ||
"semi": true, | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"Create a new Pepr capability": { | ||
"prefix": "create pepr capability", | ||
"body": [ | ||
"import { Capability, a } from 'pepr';", | ||
"", | ||
"export const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} = new Capability({", | ||
"\tname: '${TM_FILENAME_BASE}',", | ||
"\tdescription: '${1:A brief description of this capability.}',", | ||
"\tnamespaces: [${2:}],", | ||
"});", | ||
"", | ||
"// Use the 'When' function to create a new action", | ||
"const { When } = ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/};", | ||
"", | ||
"// When(a.<Kind>).Is<Event>().Then(change => change.<changes>", | ||
"When(${3:})" | ||
], | ||
"description": "Creates a new Pepr capability with a specified description, optional namespaces, and adds a When statement for the specified value." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"debug.javascript.terminalOptions": { | ||
"enableTurboSourcemaps": true, | ||
"resolveSourceMapLocations": [ | ||
"${workspaceFolder}/**", | ||
"node_modules/pepr/**" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Pepr Module | ||
|
||
This is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system. | ||
|
||
The `capabilities` directory contains all the capabilities for this module. By default, | ||
a capability is a single typescript file in the format of `capability-name.ts` that is | ||
imported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`. | ||
Because this is typescript, you can organize this however you choose, e.g. creating a sub-folder | ||
per-capability or common logic in shared files or folders. | ||
|
||
Example Structure: | ||
|
||
``` | ||
Module Root | ||
├── package.json | ||
├── pepr.ts | ||
└── capabilities | ||
├── example-one.ts | ||
├── example-three.ts | ||
└── example-two.ts | ||
``` |
45 changes: 45 additions & 0 deletions
45
test/flux-resources-bump/capabilities/flux-resources-bump.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Capability, a } from "pepr"; | ||
|
||
export const BumpFluxResources = new Capability({ | ||
name: "annotate-lb", | ||
description: | ||
"Add annotation to all services of type loadbalancer so that they are provisioned with NLB instead of ELB", | ||
namespaces: [], | ||
}); | ||
|
||
const { When } = BumpFluxResources; | ||
|
||
const fluxResourcesBurstable = { | ||
requests: { | ||
cpu: "1000m", | ||
memory: "512Mi", | ||
}, | ||
limits: { | ||
cpu: "3000m", | ||
memory: "3Gi", | ||
}, | ||
}; | ||
|
||
When(a.Pod) | ||
.IsCreated() | ||
.InNamespace("flux-system") | ||
.WithLabel("app", "source-controller") | ||
.Mutate(pod => { | ||
pod.Raw.spec.containers[0].resources = fluxResourcesBurstable; | ||
}); | ||
|
||
When(a.Pod) | ||
.IsCreated() | ||
.InNamespace("flux-system") | ||
.WithLabel("app", "helm-controller") | ||
.Mutate(pod => { | ||
pod.Raw.spec.containers[0].resources = fluxResourcesBurstable; | ||
}); | ||
|
||
When(a.Pod) | ||
.IsCreated() | ||
.InNamespace("flux-system") | ||
.WithLabel("app", "kustomize-controller") | ||
.Mutate(pod => { | ||
pod.Raw.spec.containers[0].resources = fluxResourcesBurstable; | ||
}); |
Oops, something went wrong.