Fix logging of cascading scan name#923
Merged
Merged
Conversation
Signed-off-by: Max Maass <max.maass@iteratec.com>
Contributor
|
@malexmave |
Member
Author
|
Thanks for the info - but it is only called after the first relevant logging statement, and the second log is only printed if the call failed, so I am not sure if that is a good approach 😅 - or am I misunderstanding something somewhere? |
Contributor
|
Yeah it wouldn't work with the current logs, but you could do something like console.log(`Creating Scan ${scan.metadata.generateName}...`);
try {
// Submitting the Scan to the kubernetes api
const scan = await k8sApiCRD.createNamespacedCustomObject(
"execution.securecodebox.io",
"v1",
namespace,
"scans",
scan,
"false"
);
console.log(`-> Created scan ${scan.metadata.name}`)
} catch (error) {
console.error(`Failed to create Scan ${scan.metadata.generateName}`);
console.error(error);
} |
Signed-off-by: Max Maass <max.maass@iteratec.com>
Member
Author
|
Ah, I see. Okay, I implemented this change, with a small change because the IDE did not believe me that the object would have the expected format, so I had to use the bracket syntax instead of the dot syntax. Thank you again for the proposal. |
J12934
approved these changes
Jan 11, 2022
This was referenced Jan 6, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cascading hook had a problem with logging the name of the cascaded scan (it was using a key that was undefined at the time it was used). This PR switches it to use the
metadata.generateNamekey. The disadvantage of this approach is that it does not show the suffix that Kubernetes generates for the scan name - it will only log the combined scan name from parent and cascaded scan, but not the four-letter suffixes that are appended automatically. If there is a way to get these into the name as well, let me know, but I don't think there is (and, judging from the Git history, this was also the behavior before it broke).Closes #921.
Checklist
npm testruns for the whole project.