-
Notifications
You must be signed in to change notification settings - Fork 25
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
Think about autodiscover material type #816
Comments
Right now all validations are happening on each material type crafter. Such validations are enclosed in the The idea would be to create a new interface o reuse an existing one where it forces a method with the following signature: type CraftableValidation interface {
Validate(filepath string) error
} Having such method can help us to run validations in a cascade way from the most stricter to weaker until one is found: // Test all types of CraftingSchema_Material_MaterialType
resType := schemaapi.CraftingSchema_Material_MATERIAL_TYPE_UNSPECIFIED.String()
crafters := []struct {
crafter CraftableWithValidation
resType string
}{
{&JUnitXMLCrafter{}, schemaapi.CraftingSchema_Material_JUNIT_XML.String()},
{&OpenVEXCrafter{}, schemaapi.CraftingSchema_Material_OPENVEX.String()},
{&HelmChartCrafter{}, schemaapi.CraftingSchema_Material_HELM_CHART.String()},
{&CyclonedxJSONCrafter{}, schemaapi.CraftingSchema_Material_SBOM_CYCLONEDX_JSON.String()},
...
}
for _, entry := range crafters {
if err := entry.crafter.Validate(materialValue); err == nil {
resType = entry.resType
break
}
}
return resType Steps to followThe only input received from the users is the Each branch will have its own order of validating preference. Value not representing a fileTwo options, it can be either a type
Value representing a fileWhen the value is representing a file, the validation start again, from stricter to weaker.
There are though two problems:
|
After a chat with @migmartri we have decided to go for the following:
|
By default |
The goal of the task is to be able to automagically discover the kind of material being added to the attestation. It can be run executed by setting the flag
--auto-discover
(pending to agree the actual name) on theattestation add ...
command.The text was updated successfully, but these errors were encountered: