Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell: Manifest validation upon import #21449

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Dec 18, 2024

@mvollmer mvollmer added the blocked Don't land until something else happens first (see task list) label Dec 18, 2024
@mvollmer mvollmer changed the title Shell validation shell: Manifest validation upon import Dec 18, 2024
@mvollmer
Copy link
Member Author

This is quite WIPy still...

@mvollmer mvollmer added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Dec 18, 2024
Comment on lines +174 to +176
function validation_error(msg: string): never {
console.error(`JSON validation error for ${validation_path.join("")}: ${msg}`);
throw new ValidationError();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 added lines are not executed by any test.

export function import_string(val: JsonValue): string {
if (typeof val == "string")
return val;
validation_error(`Not a string: ${JSON.stringify(val)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

export function import_number(val: JsonValue): number {
if (typeof val == "number")
return val;
validation_error(`Not a number: ${JSON.stringify(val)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

Comment on lines +191 to +194
export function import_boolean(val: JsonValue): boolean {
if (typeof val == "boolean")
return val;
validation_error(`Not a boolean: ${JSON.stringify(val)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 4 added lines are not executed by any test.

export function import_json_object(val: JsonValue): JsonObject {
if (!!val && typeof val == "object" && val.length === undefined)
return val as JsonObject;
validation_error(`Not an object: ${JSON.stringify(val)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

Comment on lines +262 to +265
} catch (e) {
if (!(e instanceof ValidationError))
throw e;
return fallback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 4 added lines are not executed by any test.

if (begin < 0)
begin = all.length - 1;
all[begin].focus();
} else {
let i = all.findIndex(item => item === cur);
i += step;
if (i < 0 || i >= all.length)
document.querySelector("#" + sel + " .pf-v5-c-text-input-group__text-input").focus();
document.querySelector<HTMLElement>("#" + sel + " .pf-v5-c-text-input-group__text-input")?.focus();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

Comment on lines 207 to 211
if (g.action)
this.props.jump(g.action.target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 added lines are not executed by any test.

@@ -140,8 +142,9 @@ export const LangModal = ({ dialogResult }) => {
<MenuList>
{
(() => {
const filteredLocales = Object.keys(manifest.locales || {})
.filter(key => !searchInput || manifest.locales[key].toLowerCase().includes(searchInput.toString().toLowerCase()));
const locales = state.config.manifest.locales || {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

// global documentation for cockpit as a whole
(cockpit.manifests.shell?.docs ?? []).forEach(doc => {
(shell_manifest.docs ?? []).forEach(doc => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

This way, it is only validated once and not on every render.
@mvollmer mvollmer removed the blocked Don't land until something else happens first (see task list) label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-test For doc/workflow changes, or experiments which don't need a full CI run,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants