pepr 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +13 -3
  2. package/codecov.yaml +19 -0
  3. package/dist/cli.js +118 -46
  4. package/dist/controller.js +1 -1
  5. package/dist/lib/assets/deploy.d.ts +1 -1
  6. package/dist/lib/assets/deploy.d.ts.map +1 -1
  7. package/dist/lib/assets/index.d.ts +1 -1
  8. package/dist/lib/assets/index.d.ts.map +1 -1
  9. package/dist/lib/assets/pods.d.ts +18 -0
  10. package/dist/lib/assets/pods.d.ts.map +1 -1
  11. package/dist/lib/helpers.d.ts +2 -0
  12. package/dist/lib/helpers.d.ts.map +1 -1
  13. package/package.json +9 -7
  14. package/src/lib/assets/deploy.ts +22 -22
  15. package/src/lib/assets/index.ts +2 -2
  16. package/src/lib/assets/pods.ts +36 -0
  17. package/src/lib/helpers.ts +42 -0
  18. package/website/.linkinator.config.json +0 -8
  19. package/website/.markdownlint.json +0 -6
  20. package/website/.prettierignore +0 -12
  21. package/website/LICENSE +0 -201
  22. package/website/README.md +0 -50
  23. package/website/archetypes/default.md +0 -6
  24. package/website/assets/img/Pepr.Horizontal.white.svg +0 -144
  25. package/website/assets/img/doug.svg +0 -345
  26. package/website/assets/img/pepr.svg +0 -212
  27. package/website/assets/scss/_styles_project.scss +0 -7
  28. package/website/assets/scss/_variables_project.scss +0 -1
  29. package/website/content/en/docs/OnSchedule.md +0 -86
  30. package/website/content/en/docs/_index.md +0 -9
  31. package/website/content/en/docs/cli.md +0 -83
  32. package/website/content/en/docs/codeSample.txt +0 -31
  33. package/website/content/en/docs/concepts.md +0 -238
  34. package/website/content/en/docs/customresources.md +0 -167
  35. package/website/content/en/docs/diagrams.txt +0 -18
  36. package/website/content/en/docs/metrics.md +0 -113
  37. package/website/content/en/docs/rbac.md +0 -153
  38. package/website/content/en/docs/store.md +0 -48
  39. package/website/content/en/docs/webassembly.md +0 -189
  40. package/website/go.mod +0 -8
  41. package/website/go.sum +0 -4
  42. package/website/package-lock.json +0 -3907
  43. package/website/package.json +0 -30
  44. package/website/renovate.json +0 -16
  45. package/website/static/favicons/android-144x144.png +0 -0
  46. package/website/static/favicons/android-192x192.png +0 -0
  47. package/website/static/favicons/android-36x36.png +0 -0
  48. package/website/static/favicons/android-48x48.png +0 -0
  49. package/website/static/favicons/android-72x72.png +0 -0
  50. package/website/static/favicons/android-96x96.png +0 -0
  51. package/website/static/favicons/android-chrome-192x192.png +0 -0
  52. package/website/static/favicons/android-chrome-512x512.png +0 -0
  53. package/website/static/favicons/android-chrome-maskable-192x192.png +0 -0
  54. package/website/static/favicons/android-chrome-maskable-512x512.png +0 -0
  55. package/website/static/favicons/apple-touch-icon-180x180.png +0 -0
  56. package/website/static/favicons/apple-touch-icon.png +0 -0
  57. package/website/static/favicons/favicon-16x16.png +0 -0
  58. package/website/static/favicons/favicon-32x32.png +0 -0
  59. package/website/static/favicons/favicon.ico +0 -0
  60. package/website/static/img/how-to-use.png +0 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  #### **_Type safe Kubernetes middleware for humans_**
10
10
 
11
- <img align="right" width="40%" src=".images/pepr.png" />
11
+ <img align="right" width="40%" src="_images/pepr.png" />
12
12
 
13
13
  Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating glue code, bash scripts, and other makeshift solutions. As a Kubernetes controller, Pepr empowers you to define Kubernetes transformations using TypeScript, without software development expertise thanks to plain-english configurations. Pepr transforms a patchwork of forks, scripts, overlays, and other chaos into a cohesive, well-structured, and maintainable system. With Pepr, you can seamlessly transition IT ops tribal knowledge into code, simplifying documentation, testing, validation, and coordination of changes for a more predictable outcome.
14
14
 
@@ -133,9 +133,19 @@ See [actions](./docs/actions.md) for more details.
133
133
 
134
134
  ## Logical Pepr Flow
135
135
 
136
- ![Arch Diagram](./.images/pepr-arch.svg)
137
- [Source Diagram](./.images/pepr-arch.svg)
136
+ ![Arch Diagram](./_images/pepr-arch.svg)
137
+ [Source Diagram](_images/pepr-arch.svg)
138
138
 
139
139
  ## TypeScript
140
140
 
141
141
  [TypeScript](https://www.typescriptlang.org/) is a strongly typed, object-oriented programming language built on top of JavaScript. It provides optional static typing and a rich type system, allowing developers to write more robust code. TypeScript is transpiled to JavaScript, enabling it to run in any environment that supports JavaScript. Pepr allows you to use JavaScript or TypeScript to write capabilities, but TypeScript is recommended for its type safety and rich type system. You can learn more about TypeScript [here](https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html).
142
+
143
+ ## Community
144
+
145
+ To join our channel go to [Kubernetes Slack](https://communityinviter.com/apps/kubernetes/community) and join the `#pepr` channel.
146
+
147
+ <a href="https://github.com/defenseunicorns/pepr/graphs/contributors">
148
+ <img src="https://contrib.rocks/image?repo=defenseunicorns/pepr" />
149
+ </a>
150
+
151
+ Made with [contrib.rocks](https://contrib.rocks).
package/codecov.yaml ADDED
@@ -0,0 +1,19 @@
1
+ codecov:
2
+ require_ci_to_pass: yes
3
+
4
+ comment:
5
+ layout: "reach, diff, flags, files"
6
+ behavior: default
7
+ require_changes: no
8
+
9
+
10
+ coverage:
11
+ status:
12
+ project:
13
+ default:
14
+ target: auto
15
+ threshold: 10%
16
+ patch: # Settings for PR patches
17
+ default:
18
+ target: auto
19
+ threshold: 10% # Adjust as needed
package/dist/cli.js CHANGED
@@ -188,7 +188,7 @@ function genCert(key, name2, issuer) {
188
188
  // src/lib/assets/deploy.ts
189
189
  var import_crypto = __toESM(require("crypto"));
190
190
  var import_fs3 = require("fs");
191
- var import_kubernetes_fluent_client2 = require("kubernetes-fluent-client");
191
+ var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
192
192
 
193
193
  // src/lib/logger.ts
194
194
  var import_pino = require("pino");
@@ -335,6 +335,9 @@ function watcher(assets, hash) {
335
335
  },
336
336
  template: {
337
337
  metadata: {
338
+ annotations: {
339
+ buildTimestamp: `${Date.now()}`
340
+ },
338
341
  labels: {
339
342
  app,
340
343
  "pepr.dev/controller": "watcher"
@@ -342,6 +345,12 @@ function watcher(assets, hash) {
342
345
  },
343
346
  spec: {
344
347
  serviceAccountName: name2,
348
+ securityContext: {
349
+ runAsUser: 65532,
350
+ runAsGroup: 65532,
351
+ runAsNonRoot: true,
352
+ fsGroup: 65532
353
+ },
345
354
  containers: [
346
355
  {
347
356
  name: "watcher",
@@ -377,6 +386,15 @@ function watcher(assets, hash) {
377
386
  cpu: "500m"
378
387
  }
379
388
  },
389
+ securityContext: {
390
+ runAsUser: 65532,
391
+ runAsGroup: 65532,
392
+ runAsNonRoot: true,
393
+ allowPrivilegeEscalation: false,
394
+ capabilities: {
395
+ drop: ["ALL"]
396
+ }
397
+ },
380
398
  volumeMounts: [
381
399
  {
382
400
  name: "tls-certs",
@@ -435,6 +453,9 @@ function deployment(assets, hash) {
435
453
  },
436
454
  template: {
437
455
  metadata: {
456
+ annotations: {
457
+ buildTimestamp: `${Date.now()}`
458
+ },
438
459
  labels: {
439
460
  app,
440
461
  "pepr.dev/controller": "admission"
@@ -443,6 +464,12 @@ function deployment(assets, hash) {
443
464
  spec: {
444
465
  priorityClassName: "system-node-critical",
445
466
  serviceAccountName: name2,
467
+ securityContext: {
468
+ runAsUser: 65532,
469
+ runAsGroup: 65532,
470
+ runAsNonRoot: true,
471
+ fsGroup: 65532
472
+ },
446
473
  containers: [
447
474
  {
448
475
  name: "server",
@@ -479,6 +506,15 @@ function deployment(assets, hash) {
479
506
  }
480
507
  },
481
508
  env: genEnv(config),
509
+ securityContext: {
510
+ runAsUser: 65532,
511
+ runAsGroup: 65532,
512
+ runAsNonRoot: true,
513
+ allowPrivilegeEscalation: false,
514
+ capabilities: {
515
+ drop: ["ALL"]
516
+ }
517
+ },
482
518
  volumeMounts: [
483
519
  {
484
520
  name: "tls-certs",
@@ -554,6 +590,7 @@ function genEnv(config, watchMode = false) {
554
590
  }
555
591
 
556
592
  // src/lib/helpers.ts
593
+ var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
557
594
  var import_fs2 = require("fs");
558
595
  var createRBACMap = (capabilities) => {
559
596
  return capabilities.reduce((acc, capability) => {
@@ -633,6 +670,40 @@ function namespaceComplianceValidator(capability, ignoredNamespaces) {
633
670
  );
634
671
  }
635
672
  }
673
+ async function checkDeploymentStatus(namespace2) {
674
+ const deployments = await (0, import_kubernetes_fluent_client.K8s)(import_kubernetes_fluent_client.kind.Deployment).InNamespace(namespace2).Get();
675
+ let status = false;
676
+ let readyCount = 0;
677
+ for (const deployment2 of deployments.items) {
678
+ const readyReplicas = deployment2.status?.readyReplicas ? deployment2.status?.readyReplicas : 0;
679
+ if (deployment2.status?.readyReplicas !== deployment2.spec?.replicas) {
680
+ logger_default.info(
681
+ `Waiting for deployment ${deployment2.metadata?.name} rollout to finish: ${readyReplicas} of ${deployment2.spec?.replicas} replicas are available`
682
+ );
683
+ } else {
684
+ logger_default.info(
685
+ `Deployment ${deployment2.metadata?.name} rolled out: ${readyReplicas} of ${deployment2.spec?.replicas} replicas are available`
686
+ );
687
+ readyCount++;
688
+ }
689
+ }
690
+ if (readyCount === deployments.items.length) {
691
+ status = true;
692
+ }
693
+ return status;
694
+ }
695
+ async function namespaceDeploymentsReady(namespace2 = "pepr-system") {
696
+ logger_default.info(`Checking ${namespace2} deployments status...`);
697
+ let ready = false;
698
+ while (!ready) {
699
+ ready = await checkDeploymentStatus(namespace2);
700
+ if (ready) {
701
+ return ready;
702
+ }
703
+ await new Promise((resolve4) => setTimeout(resolve4, 1e3));
704
+ }
705
+ logger_default.info(`All ${namespace2} deployments are ready`);
706
+ }
636
707
 
637
708
  // src/lib/assets/rbac.ts
638
709
  function clusterRole(name2, capabilities, rbacMode = "") {
@@ -727,19 +798,19 @@ function storeRoleBinding(name2) {
727
798
  }
728
799
 
729
800
  // src/lib/k8s.ts
730
- var import_kubernetes_fluent_client = require("kubernetes-fluent-client");
731
- var PeprStore = class extends import_kubernetes_fluent_client.GenericKind {
801
+ var import_kubernetes_fluent_client2 = require("kubernetes-fluent-client");
802
+ var PeprStore = class extends import_kubernetes_fluent_client2.GenericKind {
732
803
  };
733
804
  var peprStoreGVK = {
734
805
  kind: "PeprStore",
735
806
  version: "v1",
736
807
  group: "pepr.dev"
737
808
  };
738
- (0, import_kubernetes_fluent_client.RegisterKind)(PeprStore, peprStoreGVK);
809
+ (0, import_kubernetes_fluent_client2.RegisterKind)(PeprStore, peprStoreGVK);
739
810
 
740
811
  // src/lib/assets/store.ts
741
- var { group, version, kind } = peprStoreGVK;
742
- var singular = kind.toLocaleLowerCase();
812
+ var { group, version, kind: kind2 } = peprStoreGVK;
813
+ var singular = kind2.toLocaleLowerCase();
743
814
  var plural = `${singular}s`;
744
815
  var name = `${plural}.${group}`;
745
816
  var peprStoreCRD = {
@@ -775,7 +846,7 @@ var peprStoreCRD = {
775
846
  names: {
776
847
  plural,
777
848
  singular,
778
- kind
849
+ kind: kind2
779
850
  }
780
851
  }
781
852
  };
@@ -794,7 +865,7 @@ async function generateWebhookRules(assets, isMutateWebhook) {
794
865
  for (const capability of capabilities) {
795
866
  console.info(`Module ${config.uuid} has capability: ${capability.name}`);
796
867
  for (const binding of capability.bindings) {
797
- const { event, kind: kind4, isMutate, isValidate } = binding;
868
+ const { event, kind: kind5, isMutate, isValidate } = binding;
798
869
  if (isMutateWebhook && !isMutate) {
799
870
  continue;
800
871
  }
@@ -807,10 +878,10 @@ async function generateWebhookRules(assets, isMutateWebhook) {
807
878
  } else {
808
879
  operations.push(event);
809
880
  }
810
- const resource = kind4.plural || `${kind4.kind.toLowerCase()}s`;
881
+ const resource = kind5.plural || `${kind5.kind.toLowerCase()}s`;
811
882
  const ruleObject = {
812
- apiGroups: [kind4.group],
813
- apiVersions: [kind4.version || "*"],
883
+ apiGroups: [kind5.group],
884
+ apiVersions: [kind5.version || "*"],
814
885
  operations,
815
886
  resources: [resource]
816
887
  };
@@ -878,29 +949,29 @@ async function webhookConfig(assets, mutateOrValidate, timeoutSeconds = 10) {
878
949
  }
879
950
 
880
951
  // src/lib/assets/deploy.ts
881
- async function deploy(assets, webhookTimeout) {
952
+ async function deploy(assets, force, webhookTimeout) {
882
953
  logger_default.info("Establishing connection to Kubernetes");
883
954
  const { name: name2, host, path } = assets;
884
955
  logger_default.info("Applying pepr-system namespace");
885
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Namespace).Apply(namespace);
956
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Namespace).Apply(namespace);
886
957
  const mutateWebhook = await webhookConfig(assets, "mutate", webhookTimeout);
887
958
  if (mutateWebhook) {
888
959
  logger_default.info("Applying mutating webhook");
889
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.MutatingWebhookConfiguration).Apply(mutateWebhook);
960
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.MutatingWebhookConfiguration).Apply(mutateWebhook, { force });
890
961
  } else {
891
962
  logger_default.info("Mutating webhook not needed, removing if it exists");
892
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.MutatingWebhookConfiguration).Delete(name2);
963
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.MutatingWebhookConfiguration).Delete(name2);
893
964
  }
894
965
  const validateWebhook = await webhookConfig(assets, "validate", webhookTimeout);
895
966
  if (validateWebhook) {
896
967
  logger_default.info("Applying validating webhook");
897
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.ValidatingWebhookConfiguration).Apply(validateWebhook);
968
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.ValidatingWebhookConfiguration).Apply(validateWebhook, { force });
898
969
  } else {
899
970
  logger_default.info("Validating webhook not needed, removing if it exists");
900
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.ValidatingWebhookConfiguration).Delete(name2);
971
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.ValidatingWebhookConfiguration).Delete(name2);
901
972
  }
902
973
  logger_default.info("Applying the Pepr Store CRD if it doesn't exist");
903
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.CustomResourceDefinition).Apply(peprStoreCRD);
974
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.CustomResourceDefinition).Apply(peprStoreCRD, { force });
904
975
  if (host) {
905
976
  return;
906
977
  }
@@ -909,53 +980,53 @@ async function deploy(assets, webhookTimeout) {
909
980
  if (code.length < 1) {
910
981
  throw new Error("No code provided");
911
982
  }
912
- await setupRBAC(name2, assets.capabilities);
913
- await setupController(assets, code, hash);
914
- await setupWatcher(assets, hash);
983
+ await setupRBAC(name2, assets.capabilities, force);
984
+ await setupController(assets, code, hash, force);
985
+ await setupWatcher(assets, hash, force);
915
986
  }
916
- async function setupRBAC(name2, capabilities) {
987
+ async function setupRBAC(name2, capabilities, force) {
917
988
  logger_default.info("Applying cluster role binding");
918
989
  const crb = clusterRoleBinding(name2);
919
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.ClusterRoleBinding).Apply(crb);
990
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.ClusterRoleBinding).Apply(crb, { force });
920
991
  logger_default.info("Applying cluster role");
921
992
  const cr = clusterRole(name2, capabilities);
922
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.ClusterRole).Apply(cr);
993
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.ClusterRole).Apply(cr, { force });
923
994
  logger_default.info("Applying service account");
924
995
  const sa = serviceAccount(name2);
925
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.ServiceAccount).Apply(sa);
996
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.ServiceAccount).Apply(sa, { force });
926
997
  logger_default.info("Applying store role");
927
998
  const role = storeRole(name2);
928
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Role).Apply(role);
999
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Role).Apply(role, { force });
929
1000
  logger_default.info("Applying store role binding");
930
1001
  const roleBinding = storeRoleBinding(name2);
931
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.RoleBinding).Apply(roleBinding);
1002
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.RoleBinding).Apply(roleBinding, { force });
932
1003
  }
933
- async function setupController(assets, code, hash) {
1004
+ async function setupController(assets, code, hash, force) {
934
1005
  const { name: name2 } = assets;
935
1006
  logger_default.info("Applying module secret");
936
1007
  const mod = moduleSecret(name2, code, hash);
937
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Secret).Apply(mod);
1008
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Secret).Apply(mod, { force });
938
1009
  logger_default.info("Applying controller service");
939
1010
  const svc = service(name2);
940
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Service).Apply(svc);
1011
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Service).Apply(svc, { force });
941
1012
  logger_default.info("Applying TLS secret");
942
1013
  const tls = tlsSecret(name2, assets.tls);
943
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Secret).Apply(tls);
1014
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Secret).Apply(tls, { force });
944
1015
  logger_default.info("Applying API token secret");
945
1016
  const apiToken = apiTokenSecret(name2, assets.apiToken);
946
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Secret).Apply(apiToken);
1017
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Secret).Apply(apiToken, { force });
947
1018
  logger_default.info("Applying deployment");
948
1019
  const dep = deployment(assets, hash);
949
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Deployment).Apply(dep);
1020
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Deployment).Apply(dep, { force });
950
1021
  }
951
- async function setupWatcher(assets, hash) {
1022
+ async function setupWatcher(assets, hash, force) {
952
1023
  const watchDeployment = watcher(assets, hash);
953
1024
  if (watchDeployment) {
954
1025
  logger_default.info("Applying watcher deployment");
955
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Deployment).Apply(watchDeployment);
1026
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Deployment).Apply(watchDeployment, { force });
956
1027
  logger_default.info("Applying watcher service");
957
1028
  const watchSvc = watcherService(assets.name);
958
- await (0, import_kubernetes_fluent_client2.K8s)(import_kubernetes_fluent_client2.kind.Service).Apply(watchSvc);
1029
+ await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Service).Apply(watchSvc, { force });
959
1030
  }
960
1031
  }
961
1032
 
@@ -1065,9 +1136,9 @@ var Assets = class {
1065
1136
  alwaysIgnore;
1066
1137
  capabilities;
1067
1138
  image;
1068
- deploy = async (webhookTimeout) => {
1139
+ deploy = async (force, webhookTimeout) => {
1069
1140
  this.capabilities = await loadCapabilities(this.path);
1070
- await deploy(this, webhookTimeout);
1141
+ await deploy(this, force, webhookTimeout);
1071
1142
  };
1072
1143
  zarfYaml = (path) => zarfYaml(this, path);
1073
1144
  allYaml = async (rbacMode) => {
@@ -1286,7 +1357,7 @@ var gitIgnore = "# Ignore node_modules and Pepr build artifacts\nnode_modules\nd
1286
1357
  var readmeMd = '# Pepr Module\n\nThis is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system.\n\nThe `capabilities` directory contains all the capabilities for this module. By default,\na capability is a single typescript file in the format of `capability-name.ts` that is\nimported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`.\nBecause this is typescript, you can organize this however you choose, e.g. creating a sub-folder\nper-capability or common logic in shared files or folders.\n\nExample Structure:\n\n```\nModule Root\n\u251C\u2500\u2500 package.json\n\u251C\u2500\u2500 pepr.ts\n\u2514\u2500\u2500 capabilities\n \u251C\u2500\u2500 example-one.ts\n \u251C\u2500\u2500 example-three.ts\n \u2514\u2500\u2500 example-two.ts\n```\n';
1287
1358
  var peprTS = 'import { PeprModule } from "pepr";\n// cfg loads your pepr configuration from package.json\nimport cfg from "./package.json";\n\n// HelloPepr is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\nimport { HelloPepr } from "./capabilities/hello-pepr";\n\n/**\n * This is the main entrypoint for this Pepr module. It is run when the module is started.\n * This is where you register your Pepr configurations and capabilities.\n */\nnew PeprModule(cfg, [\n // "HelloPepr" is a demo capability that is included with Pepr. Comment or delete the line below to remove it.\n HelloPepr,\n\n // Your additional capabilities go here\n]);\n';
1288
1359
  var helloPeprTS = 'import {\n Capability,\n K8s,\n Log,\n PeprMutateRequest,\n RegisterKind,\n a,\n fetch,\n fetchStatus,\n kind,\n} from "pepr";\n\n/**\n * The HelloPepr Capability is an example capability to demonstrate some general concepts of Pepr.\n * To test this capability you run `pepr dev`and then run the following command:\n * `kubectl apply -f capabilities/hello-pepr.samples.yaml`\n */\nexport const HelloPepr = new Capability({\n name: "hello-pepr",\n description: "A simple example capability to show how things work.",\n namespaces: ["pepr-demo", "pepr-demo-2"],\n});\n\n// Use the \'When\' function to create a new action, use \'Store\' to persist data\nconst { When, Store } = HelloPepr;\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action removes the label `remove-me` when a Namespace is created.\n * Note we don\'t need to specify the namespace here, because we\'ve already specified\n * it in the Capability definition above.\n */\nWhen(a.Namespace)\n .IsCreated()\n .Mutate(ns => ns.RemoveLabel("remove-me"));\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Watch Action with K8s SSA (Namespace) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action watches for the `pepr-demo-2` namespace to be created, then creates a ConfigMap with\n * the name `pepr-ssa-demo` and adds the namespace UID to the ConfigMap data. Because Pepr uses\n * server-side apply for this operation, the ConfigMap will be created or updated if it already exists.\n */\nWhen(a.Namespace)\n .IsCreated()\n .WithName("pepr-demo-2")\n .Watch(async ns => {\n Log.info("Namespace pepr-demo-2 was created.");\n\n try {\n // Apply the ConfigMap using K8s server-side apply\n await K8s(kind.ConfigMap).Apply({\n metadata: {\n name: "pepr-ssa-demo",\n namespace: "pepr-demo-2",\n },\n data: {\n "ns-uid": ns.metadata.uid,\n },\n });\n } catch (error) {\n // You can use the Log object to log messages to the Pepr controller pod\n Log.error(error, "Failed to apply ConfigMap using server-side apply.");\n }\n\n // You can share data between actions using the Store, including between different types of actions\n Store.setItem("watch-data", "This data was stored by a Watch Action.");\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 1) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is a single action. They can be in the same file or put imported from other files.\n * In this example, when a ConfigMap is created with the name `example-1`, then add a label and annotation.\n *\n * Equivalent to manually running:\n * `kubectl label configmap example-1 pepr=was-here`\n * `kubectl annotate configmap example-1 pepr.dev=annotations-work-too`\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request\n .SetLabel("pepr", "was-here")\n .SetAnnotation("pepr.dev", "annotations-work-too");\n\n // Use the Store to persist data between requests and Pepr controller pods\n Store.setItem("example-1", "was-here");\n\n // This data is written asynchronously and can be read back via `Store.getItem()` or `Store.subscribe()`\n Store.setItem("example-1-data", JSON.stringify(request.Raw.data));\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate & Validate Actions (CM Example 2) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This combines 3 different types of actions: \'Mutate\', \'Validate\', and \'Watch\'. The order\n * of the actions is required, but each action is optional. In this example, when a ConfigMap is created\n * with the name `example-2`, then add a label and annotation, validate that the ConfigMap has the label\n * `pepr`, and log the request.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n // This Mutate Action will mutate the request before it is persisted to the cluster\n\n // Use `request.Merge()` to merge the new data with the existing data\n request.Merge({\n metadata: {\n labels: {\n pepr: "was-here",\n },\n annotations: {\n "pepr.dev": "annotations-work-too",\n },\n },\n });\n })\n .Validate(request => {\n // This Validate Action will validate the request before it is persisted to the cluster\n\n // Approve the request if the ConfigMap has the label \'pepr\'\n if (request.HasLabel("pepr")) {\n return request.Approve();\n }\n\n // Otherwise, deny the request with an error message (optional)\n return request.Deny("ConfigMap must have label \'pepr\'");\n })\n .Watch((cm, phase) => {\n // This Watch Action will watch the ConfigMap after it has been persisted to the cluster\n Log.info(cm, `ConfigMap was ${phase} with the name example-2`);\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 2a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action shows a simple validation that will deny any ConfigMap that has the\n * annotation `evil`. Note that the `Deny()` function takes an optional second parameter that is a\n * user-defined status code to return.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .Validate(request => {\n if (request.HasAnnotation("evil")) {\n return request.Deny("No evil CM annotations allowed.", 400);\n }\n\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 3) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action combines different styles. Unlike the previous actions, this one will look\n * for any ConfigMap in the `pepr-demo` namespace that has the label `change=by-label` during either\n * CREATE or UPDATE. Note that all conditions added such as `WithName()`, `WithLabel()`, `InNamespace()`,\n * are ANDs so all conditions must be true for the request to be processed.\n */\nWhen(a.ConfigMap)\n .IsCreatedOrUpdated()\n .WithLabel("change", "by-label")\n .Mutate(request => {\n // The K8s object e are going to mutate\n const cm = request.Raw;\n\n // Get the username and uid of the K8s request\n const { username, uid } = request.Request.userInfo;\n\n // Store some data about the request in the configmap\n cm.data["username"] = username;\n cm.data["uid"] = uid;\n\n // You can still mix other ways of making changes too\n request.SetAnnotation("pepr.dev", "making-waves");\n });\n\n// This action validates the label `change=by-label` is deleted\nWhen(a.ConfigMap)\n .IsDeleted()\n .WithLabel("change", "by-label")\n .Validate(request => {\n // Log and then always approve the request\n Log.info("CM with label \'change=by-label\' was deleted.");\n return request.Approve();\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action show how you can use the `Mutate()` function without an inline function.\n * This is useful if you want to keep your actions small and focused on a single task,\n * or if you want to reuse the same function in multiple actions.\n */\nWhen(a.ConfigMap).IsCreated().WithName("example-4").Mutate(example4Cb);\n\n// This function uses the complete type definition, but is not required.\nfunction example4Cb(cm: PeprMutateRequest<a.ConfigMap>) {\n cm.SetLabel("pepr.dev/first", "true");\n cm.SetLabel("pepr.dev/second", "true");\n cm.SetLabel("pepr.dev/third", "true");\n}\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 4a) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This is the same as Example 4, except this only operates on a CM in the `pepr-demo-2` namespace.\n * Note because the Capability defines namespaces, the namespace specified here must be one of those.\n * Alternatively, you can remove the namespace from the Capability definition and specify it here.\n */\nWhen(a.ConfigMap)\n .IsCreated()\n .InNamespace("pepr-demo-2")\n .WithName("example-4a")\n .Mutate(example4Cb);\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (CM Example 5) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This action is a bit more complex. It will look for any ConfigMap in the `pepr-demo`\n * namespace that has the label `chuck-norris` during CREATE. When it finds one, it will fetch a\n * random Chuck Norris joke from the API and add it to the ConfigMap. This is a great example of how\n * you can use Pepr to make changes to your K8s objects based on external data.\n *\n * Note the use of the `async` keyword. This is required for any action that uses `await` or `fetch()`.\n *\n * Also note we are passing a type to the `fetch()` function. This is optional, but it will help you\n * avoid mistakes when working with the data returned from the API. You can also use the `as` keyword to\n * cast the data returned from the API.\n *\n * These are equivalent:\n * ```ts\n * const joke = await fetch<TheChuckNorrisJoke>("https://api.chucknorris.io/jokes/random?category=dev");\n * const joke = await fetch("https://api.chucknorris.io/jokes/random?category=dev") as TheChuckNorrisJoke;\n * ```\n *\n * Alternatively, you can drop the type completely:\n *\n * ```ts\n * fetch("https://api.chucknorris.io/jokes/random?category=dev")\n * ```\n */\ninterface TheChuckNorrisJoke {\n icon_url: string;\n id: string;\n url: string;\n value: string;\n}\n\nWhen(a.ConfigMap)\n .IsCreated()\n .WithLabel("chuck-norris")\n .Mutate(async change => {\n // Try/catch is not needed as a response object will always be returned\n const response = await fetch<TheChuckNorrisJoke>(\n "https://api.chucknorris.io/jokes/random?category=dev",\n );\n\n // Instead, check the `response.ok` field\n if (response.ok) {\n // Add the Chuck Norris joke to the configmap\n change.Raw.data["chuck-says"] = response.data.value;\n return;\n }\n\n // You can also assert on different HTTP response codes\n if (response.status === fetchStatus.NOT_FOUND) {\n // Do something else\n return;\n }\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Secret Base64 Handling) *\n * ---------------------------------------------------------------------------------------------------\n *\n * The K8s JS client provides incomplete support for base64 encoding/decoding handling for secrets,\n * unlike the GO client. To make this less painful, Pepr automatically handles base64 encoding/decoding\n * secret data before and after the action is executed.\n */\nWhen(a.Secret)\n .IsCreated()\n .WithName("secret-1")\n .Mutate(request => {\n const secret = request.Raw;\n\n // This will be encoded at the end of all processing back to base64: "Y2hhbmdlLXdpdGhvdXQtZW5jb2Rpbmc="\n secret.data.magic = "change-without-encoding";\n\n // You can modify the data directly, and it will be encoded at the end of all processing\n secret.data.example += " - modified by Pepr";\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Untyped Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * Out of the box, Pepr supports all the standard Kubernetes objects. However, you can also create\n * your own types. This is useful if you are working with an Operator that creates custom resources.\n * There are two ways to do this, the first is to use the `When()` function with a `GenericKind`,\n * the second is to create a new class that extends `GenericKind` and use the `RegisterKind()` function.\n *\n * This example shows how to use the `When()` function with a `GenericKind`. Note that you\n * must specify the `group`, `version`, and `kind` of the object (if applicable). This is how Pepr knows\n * if the action should be triggered or not. Since we are using a `GenericKind`,\n * Pepr will not be able to provide any intellisense for the object, so you will need to refer to the\n * Kubernetes API documentation for the object you are working with.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-1\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```\n */\nWhen(a.GenericKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n})\n .IsCreated()\n .WithName("example-1")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr without type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * ---------------------------------------------------------------------------------------------------\n * Mutate Action (Typed Custom Resource) *\n * ---------------------------------------------------------------------------------------------------\n *\n * This example shows how to use the `RegisterKind()` function to create a new type. This is useful\n * if you are working with an Operator that creates custom resources and you want to have intellisense\n * for the object. Note that you must specify the `group`, `version`, and `kind` of the object (if applicable)\n * as this is how Pepr knows if the action should be triggered or not.\n *\n * Once you register a new Kind with Pepr, you can use the `When()` function with the new Kind. Ideally,\n * you should register custom Kinds at the top of your Capability file or Pepr Module so they are available\n * to all actions, but we are putting it here for demonstration purposes.\n *\n * You will need to wait for the CRD in `hello-pepr.samples.yaml` to be created, then you can apply\n *\n * ```yaml\n * apiVersion: pepr.dev/v1\n * kind: Unicorn\n * metadata:\n * name: example-2\n * namespace: pepr-demo\n * spec:\n * message: replace-me\n * counter: 0\n * ```*\n */\nclass UnicornKind extends a.GenericKind {\n spec: {\n /**\n * JSDoc comments can be added to explain more details about the field.\n *\n * @example\n * ```ts\n * request.Raw.spec.message = "Hello Pepr!";\n * ```\n * */\n message: string;\n counter: number;\n };\n}\n\nRegisterKind(UnicornKind, {\n group: "pepr.dev",\n version: "v1",\n kind: "Unicorn",\n});\n\nWhen(UnicornKind)\n .IsCreated()\n .WithName("example-2")\n .Mutate(request => {\n request.Merge({\n spec: {\n message: "Hello Pepr with type data!",\n counter: Math.random(),\n },\n });\n });\n\n/**\n * A callback function that is called once the Pepr Store is fully loaded.\n */\nStore.onReady(data => {\n Log.info(data, "Pepr Store Ready");\n});\n';
1289
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.21.1", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.9", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.1.0", pino: "8.17.2", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.4.3", "@commitlint/config-conventional": "18.4.3", "@jest/globals": "29.7.0", "@types/eslint": "8.56.0", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.10", "@types/prompts": "2.4.9", "@types/uuid": "9.0.7", jest: "29.7.0", nock: "13.4.0", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
1360
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.22.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "git clone https://github.com/defenseunicorns/pepr-upgrade-test.git", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.9", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.1.0", pino: "8.17.2", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.4.4", "@commitlint/config-conventional": "18.4.4", "@jest/globals": "29.7.0", "@types/eslint": "8.56.2", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.7", jest: "29.7.0", nock: "13.4.0", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
1290
1361
 
1291
1362
  // src/templates/pepr.code-snippets.json
1292
1363
  var pepr_code_snippets_default = {
@@ -1698,7 +1769,7 @@ async function buildModule(reloader, entryPoint = peprTS2, embed = true) {
1698
1769
  // src/cli/deploy.ts
1699
1770
  var import_prompts = __toESM(require("prompts"));
1700
1771
  function deploy_default(program2) {
1701
- program2.command("deploy").description("Deploy a Pepr Module").option("-i, --image [image]", "Override the image tag").option("--confirm", "Skip confirmation prompt").action(async (opts) => {
1772
+ program2.command("deploy").description("Deploy a Pepr Module").option("-i, --image [image]", "Override the image tag").option("--confirm", "Skip confirmation prompt").option("--force", "Force deploy the module, override manager field").action(async (opts) => {
1702
1773
  if (!opts.confirm) {
1703
1774
  const confirm2 = await (0, import_prompts.default)({
1704
1775
  type: "confirm",
@@ -1721,10 +1792,11 @@ function deploy_default(program2) {
1721
1792
  webhook.image = opts.image;
1722
1793
  }
1723
1794
  try {
1724
- await webhook.deploy();
1795
+ await webhook.deploy(opts.force);
1796
+ await namespaceDeploymentsReady();
1725
1797
  console.info(`\u2705 Module deployed successfully`);
1726
1798
  } catch (e) {
1727
- console.error(`Error deploying module: ${e}`);
1799
+ console.error(`Error deploying module: ${e.data.message}`);
1728
1800
  process.exit(1);
1729
1801
  }
1730
1802
  });
@@ -1761,7 +1833,7 @@ function dev_default(program2) {
1761
1833
  let program3;
1762
1834
  const runFork = async () => {
1763
1835
  console.info(`Running module ${path}`);
1764
- await webhook.deploy(30);
1836
+ await webhook.deploy(false, 30);
1765
1837
  program3 = (0, import_child_process3.fork)(path, {
1766
1838
  env: {
1767
1839
  ...process.env,
@@ -1788,7 +1860,7 @@ function dev_default(program2) {
1788
1860
  }
1789
1861
  });
1790
1862
  } catch (e) {
1791
- console.error(`Error deploying module: ${e}`);
1863
+ console.error(`Error deploying module: ${e.data.message}`);
1792
1864
  process.exit(1);
1793
1865
  }
1794
1866
  });
@@ -1796,7 +1868,7 @@ function dev_default(program2) {
1796
1868
 
1797
1869
  // src/cli/monitor.ts
1798
1870
  var import_client_node3 = require("@kubernetes/client-node");
1799
- var import_kubernetes_fluent_client3 = require("kubernetes-fluent-client");
1871
+ var import_kubernetes_fluent_client4 = require("kubernetes-fluent-client");
1800
1872
  var import_stream = __toESM(require("stream"));
1801
1873
  function monitor_default(program2) {
1802
1874
  program2.command("monitor <module-uuid>").description("Monitor a Pepr Module").action(async (uuid) => {
@@ -1804,7 +1876,7 @@ function monitor_default(program2) {
1804
1876
  console.error("Module UUID is required");
1805
1877
  process.exit(1);
1806
1878
  }
1807
- const pods = await (0, import_kubernetes_fluent_client3.K8s)(import_kubernetes_fluent_client3.kind.Pod).InNamespace("pepr-system").WithLabel("app", `pepr-${uuid}`).Get();
1879
+ const pods = await (0, import_kubernetes_fluent_client4.K8s)(import_kubernetes_fluent_client4.kind.Pod).InNamespace("pepr-system").WithLabel("app", `pepr-${uuid}`).Get();
1808
1880
  const podNames = pods.items.flatMap((pod) => pod.metadata.name);
1809
1881
  if (podNames.length < 1) {
1810
1882
  console.error(`No pods found for module ${uuid}`);
@@ -48,7 +48,7 @@ if (process.env.LOG_LEVEL) {
48
48
  var logger_default = Log;
49
49
 
50
50
  // src/templates/data.json
51
- var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.21.1", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.9", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.1.0", pino: "8.17.2", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.4.3", "@commitlint/config-conventional": "18.4.3", "@jest/globals": "29.7.0", "@types/eslint": "8.56.0", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.10", "@types/prompts": "2.4.9", "@types/uuid": "9.0.7", jest: "29.7.0", nock: "13.4.0", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
51
+ var packageJSON = { name: "pepr", description: "Kubernetes application engine", author: "Defense Unicorns", homepage: "https://github.com/defenseunicorns/pepr", license: "Apache-2.0", bin: "dist/cli.js", repository: "defenseunicorns/pepr", engines: { node: ">=18.0.0" }, version: "0.22.0", main: "dist/lib.js", types: "dist/lib.d.ts", scripts: { "gen-data-json": "node hack/build-template-data.js", prebuild: "rm -fr dist/* && npm run gen-data-json", build: "tsc && node build.mjs", test: "npm run test:unit && npm run test:journey", "test:unit": "npm run gen-data-json && jest src --coverage --detectOpenHandles --coverageDirectory=./coverage", "test:journey": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run", "test:journey:prep": "git clone https://github.com/defenseunicorns/pepr-upgrade-test.git", "test:journey-wasm": "npm run test:journey:k3d && npm run test:journey:build && npm run test:journey:image && npm run test:journey:run-wasm", "test:journey:k3d": "k3d cluster delete pepr-dev && k3d cluster create pepr-dev --k3s-arg '--debug@server:0' --wait && kubectl rollout status deployment -n kube-system", "test:journey:build": "npm run build && npm pack", "test:journey:image": "docker buildx build --tag pepr:dev . && k3d image import pepr:dev -c pepr-dev", "test:journey:run": "jest --detectOpenHandles journey/entrypoint.test.ts && npm run test:journey:prep && npm run test:journey:upgrade", "test:journey:run-wasm": "jest --detectOpenHandles journey/entrypoint-wasm.test.ts", "test:journey:upgrade": "npm run test:journey:k3d && npm run test:journey:image && jest --detectOpenHandles journey/pepr-upgrade.test.ts", "format:check": "eslint src && prettier src --check", "format:fix": "eslint src --fix && prettier src --write" }, dependencies: { "@types/ramda": "0.29.9", express: "4.18.2", "fast-json-patch": "3.1.1", "kubernetes-fluent-client": "2.1.0", pino: "8.17.2", "pino-pretty": "10.3.1", "prom-client": "15.1.0", ramda: "0.29.1" }, devDependencies: { "@commitlint/cli": "18.4.4", "@commitlint/config-conventional": "18.4.4", "@jest/globals": "29.7.0", "@types/eslint": "8.56.2", "@types/express": "4.17.21", "@types/node": "18.x.x", "@types/node-forge": "1.3.11", "@types/prompts": "2.4.9", "@types/uuid": "9.0.7", jest: "29.7.0", nock: "13.4.0", "ts-jest": "29.1.1" }, peerDependencies: { "@typescript-eslint/eslint-plugin": "6.15.0", "@typescript-eslint/parser": "6.15.0", commander: "11.1.0", esbuild: "0.19.10", eslint: "8.56.0", "node-forge": "1.3.1", prettier: "3.1.1", prompts: "2.4.2", typescript: "5.3.3", uuid: "9.0.1" } };
52
52
 
53
53
  // src/runtime/controller.ts
54
54
  var { version } = packageJSON;
@@ -1,3 +1,3 @@
1
1
  import { Assets } from ".";
2
- export declare function deploy(assets: Assets, webhookTimeout?: number): Promise<void>;
2
+ export declare function deploy(assets: Assets, force: boolean, webhookTimeout?: number): Promise<void>;
3
3
  //# sourceMappingURL=deploy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAS3B,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,iBA8CnE"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/deploy.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAS3B,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,iBA8CnF"}
@@ -13,7 +13,7 @@ export declare class Assets {
13
13
  capabilities: CapabilityExport[];
14
14
  image: string;
15
15
  constructor(config: ModuleConfig, path: string, host?: string | undefined);
16
- deploy: (webhookTimeout?: number) => Promise<void>;
16
+ deploy: (force: boolean, webhookTimeout?: number) => Promise<void>;
17
17
  zarfYaml: (path: string) => string;
18
18
  allYaml: (rbacMode: string) => Promise<string>;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAMvC,qBAAa,MAAM;IAUf,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,CAAC;IAXhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAG,aAAa,CAAC;IACtC,YAAY,EAAG,gBAAgB,EAAE,CAAC;IAElC,KAAK,EAAE,MAAM,CAAC;gBAGH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,oBAAQ;IAaxB,MAAM,oBAA2B,MAAM,mBAGrC;IAEF,QAAQ,SAAU,MAAM,YAA0B;IAElD,OAAO,aAAoB,MAAM,qBAQ/B;CACH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAMvC,qBAAa,MAAM;IAUf,QAAQ,CAAC,MAAM,EAAE,YAAY;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,CAAC;IAXhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAG,aAAa,CAAC;IACtC,YAAY,EAAG,gBAAgB,EAAE,CAAC;IAElC,KAAK,EAAE,MAAM,CAAC;gBAGH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,oBAAQ;IAaxB,MAAM,UAAiB,OAAO,mBAAmB,MAAM,mBAGrD;IAEF,QAAQ,SAAU,MAAM,YAA0B;IAElD,OAAO,aAAoB,MAAM,qBAQ/B;CACH"}
@@ -28,6 +28,9 @@ export declare function watcher(assets: Assets, hash: string): {
28
28
  };
29
29
  template: {
30
30
  metadata: {
31
+ annotations: {
32
+ buildTimestamp: string;
33
+ };
31
34
  labels: {
32
35
  app: string;
33
36
  "pepr.dev/controller": string;
@@ -35,6 +38,12 @@ export declare function watcher(assets: Assets, hash: string): {
35
38
  };
36
39
  spec: {
37
40
  serviceAccountName: string;
41
+ securityContext: {
42
+ runAsUser: number;
43
+ runAsGroup: number;
44
+ runAsNonRoot: boolean;
45
+ fsGroup: number;
46
+ };
38
47
  containers: {
39
48
  name: string;
40
49
  image: string;
@@ -67,6 +76,15 @@ export declare function watcher(assets: Assets, hash: string): {
67
76
  cpu: string;
68
77
  };
69
78
  };
79
+ securityContext: {
80
+ runAsUser: number;
81
+ runAsGroup: number;
82
+ runAsNonRoot: boolean;
83
+ allowPrivilegeEscalation: boolean;
84
+ capabilities: {
85
+ drop: string[];
86
+ };
87
+ };
70
88
  volumeMounts: {
71
89
  name: string;
72
90
  mountPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B,yCAAyC;AACzC,eAAO,MAAM,SAAS,EAAE,IAAI,CAAC,SAI5B,CAAC;AAEF,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA0HnD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAgHxE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAgBlF"}
1
+ {"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../../src/lib/assets/pods.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAI3B,yCAAyC;AACzC,eAAO,MAAM,SAAS,EAAE,IAAI,CAAC,SAI5B,CAAC;AAEF,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA4InD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,CAkIxE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAgBlF"}
@@ -14,5 +14,7 @@ export declare function ignoredNamespaceConflict(ignoreNamespaces: string[], bin
14
14
  export declare function bindingAndCapabilityNSConflict(bindingNamespaces: string[], capabilityNamespaces: string[]): boolean;
15
15
  export declare function generateWatchNamespaceError(ignoredNamespaces: string[], bindingNamespaces: string[], capabilityNamespaces: string[]): string;
16
16
  export declare function namespaceComplianceValidator(capability: CapabilityExport, ignoredNamespaces?: string[]): void;
17
+ export declare function checkDeploymentStatus(namespace: string): Promise<boolean>;
18
+ export declare function namespaceDeploymentsReady(namespace?: string): Promise<true | undefined>;
17
19
  export {};
18
20
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,KAAK,OAAO,GAAG;IACb,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,EAAE,QAAQ,MAAM,SAI/D,CAAC;AAEF,eAAO,MAAM,aAAa,iBAAkB,gBAAgB,EAAE,KAAG,OAoBhE,CAAC;AAEF,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,iBAU5D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAMpE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAMlE;AAED,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAE/F;AAED,wBAAgB,8BAA8B,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAKzG;AAED,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,MAAM,EAAE,UAoB/B;AAGD,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,QActG"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,KAAK,OAAO,GAAG;IACb,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,EAAE,QAAQ,MAAM,SAI/D,CAAC;AAEF,eAAO,MAAM,aAAa,iBAAkB,gBAAgB,EAAE,KAAG,OAoBhE,CAAC;AAEF,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,iBAU5D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAMpE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAMlE;AAED,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,WAE/F;AAED,wBAAgB,8BAA8B,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAKzG;AAED,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,MAAM,EAAE,UAoB/B;AAGD,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,QActG;AAID,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,oBAsB5D;AAGD,wBAAsB,yBAAyB,CAAC,SAAS,GAAE,MAAsB,6BAWhF"}