-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fix logging of cascading scan name #923
Conversation
Signed-off-by: Max Maass <max.maass@iteratec.com>
@malexmave |
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? |
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>
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 😄
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.generateName
key. 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 test
runs for the whole project.