-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 1340-assets-circular
- Loading branch information
Showing
10 changed files
with
154 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors | ||
|
||
import { describe, jest } from "@jest/globals"; | ||
|
||
import { describe, jest } from "@jest/globals"; | ||
import { peprBuild } from "./pepr-build-wasm"; | ||
|
||
|
||
// Unmock unit test things | ||
jest.deepUnmock("pino"); | ||
|
||
|
||
// Allow 5 minutes for the tests to run | ||
jest.setTimeout(1000 * 60 * 5); | ||
|
||
describe("Journey: `npx pepr build -r gchr.io/defenseunicorns --rbac-mode scoped -o dist/pepr-test-module/child/folder`", peprBuild); | ||
describe( | ||
"Journey: `npx pepr build -r gchr.io/defenseunicorns -o dist/pepr-test-module/child/folder`", | ||
peprBuild, | ||
); |
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,29 @@ | ||
rbac: | ||
- apiGroups: | ||
- 'pepr.dev' | ||
resources: | ||
- 'peprstores' | ||
verbs: | ||
- 'create' | ||
- 'get' | ||
- 'patch' | ||
- 'watch' | ||
- apiGroups: | ||
- 'apiextensions.k8s.io' | ||
resources: | ||
- 'customresourcedefinitions' | ||
verbs: | ||
- 'patch' | ||
- 'create' | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- 'namespaces' | ||
verbs: | ||
- 'watch' | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- 'configmaps' | ||
verbs: | ||
- 'watch' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,28 @@ | ||
/** | ||
* Determine the RBAC mode based on the CLI options and the module's config | ||
* @param opts CLI options | ||
* @param cfg Module's config | ||
* @returns The determined RBAC mode | ||
* @example | ||
* const opts = { rbacMode: "admin" }; | ||
* const cfg = { pepr: { rbacMode: "scoped" } }; | ||
* const result = determineRbacMode(opts, cfg); | ||
* console.log(result); // "admin" | ||
*/ | ||
export function determineRbacMode( | ||
opts: { rbacMode?: string }, | ||
cfg: { pepr: { rbacMode?: string } }, | ||
): string { | ||
// CLI overrides the module's config | ||
if (opts.rbacMode) { | ||
return opts.rbacMode; | ||
} | ||
|
||
// if rbacMode is defined and not scoped, return admin | ||
if (cfg.pepr.rbacMode && cfg.pepr.rbacMode !== "scoped") { | ||
return "admin"; | ||
} | ||
|
||
// if nothing is defined return admin, else return scoped | ||
return cfg.pepr.rbacMode || "admin"; | ||
} |
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,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023-Present The Pepr Authors | ||
|
||
import { determineRbacMode } from "./build.helpers"; | ||
|
||
import { expect, describe, test } from "@jest/globals"; | ||
|
||
describe("determineRbacMode", () => { | ||
test("should allow CLI options to overwrite module config", () => { | ||
const opts = { rbacMode: "admin" }; | ||
const cfg = { pepr: { rbacMode: "scoped" } }; | ||
const result = determineRbacMode(opts, cfg); | ||
expect(result).toBe("admin"); | ||
}); | ||
|
||
test('should return "admin" when cfg.pepr.rbacMode is provided and not "scoped"', () => { | ||
const opts = {}; | ||
const cfg = { pepr: { rbacMode: "admin" } }; | ||
const result = determineRbacMode(opts, cfg); | ||
expect(result).toBe("admin"); | ||
}); | ||
|
||
test('should return "scoped" when cfg.pepr.rbacMode is "scoped"', () => { | ||
const opts = {}; | ||
const cfg = { pepr: { rbacMode: "scoped" } }; | ||
const result = determineRbacMode(opts, cfg); | ||
expect(result).toBe("scoped"); | ||
}); | ||
|
||
test("should default to admin when neither option is provided", () => { | ||
const opts = {}; | ||
const cfg = { pepr: {} }; | ||
const result = determineRbacMode(opts, cfg); | ||
expect(result).toBe("admin"); | ||
}); | ||
}); |
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