-
Notifications
You must be signed in to change notification settings - Fork 22
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
duplicate detection for add commands #564
Conversation
return list.Result() | ||
} | ||
|
||
func ValdateElementSpecIdentities(kind string, src string, elems []ElementSpec) error { |
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.
typo
func ValdateElementSpecIdentities(kind string, src string, elems []ElementSpec) error { | |
func ValidateElementSpecIdentities(kind string, src string, elems []ElementSpec) error { |
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.
fixed
@@ -279,6 +283,39 @@ func Validate(r *ResourceInput, ctx inputs.Context, inputFilePath string) error | |||
return allErrs.ToAggregate() | |||
} | |||
|
|||
func ValdateElementIdentities(kind string, elems []Element) error { |
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.
typo
func ValdateElementIdentities(kind string, elems []Element) error { | |
func ValidateElementIdentities(kind string, elems []Element) error { |
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.
fixed
return list.Result() | ||
} | ||
|
||
func ValdateElementSpecIdentities(kind string, src string, elems []ElementSpec) error { |
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.
What is the src string
supposed to be?
Please choose a more tangible parameter name or add helpful comments.
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.
added doc to various types and functions
list.Add(addhdlrs.ValdateElementSpecIdentities("resource", elem.Source().String(), generics.ConvertSliceTo[addhdlrs.ElementSpec](r.Resources))) | ||
list.Add(addhdlrs.ValdateElementSpecIdentities("source", elem.Source().String(), generics.ConvertSliceTo[addhdlrs.ElementSpec](r.Sources))) | ||
list.Add(addhdlrs.ValdateElementSpecIdentities("reference", elem.Source().String(), generics.ConvertSliceTo[addhdlrs.ElementSpec](r.References))) |
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.
What is an elements source (elem.Source()
)? Confusing name (especially since "Sources" actually are a core model element - is the core model element related to this function? If so, how?)
The package addhdlrs (where this function is from) contains generally quite generic coding with non-tangible namings and no comments to support the understanding.
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.
added docu
@@ -155,6 +155,10 @@ type ResourceSpec struct { | |||
|
|||
var _ addhdlrs.ElementSpec = (*ResourceSpec)(nil) | |||
|
|||
func (r *ResourceSpec) GetRawIdentity() metav1.Identity { | |||
return metav1.NewIdentity(r.Name, metav1.SystemIdentityVersion, r.Version) |
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.
Why is this constant called SystemIdentityVersion
?
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.
SystemIdentityVersion and SystemIdentityName are the two predefined identity properties use to identify elements (resources, sources, referebces) in CDs.
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.
added docu to their const definitions.
Description
The add commands now check for duplicate ids for resources, sources and references in specs and report
appropriate problems with the location in the source yaml files.
The same check is done for adding multiple components to avoid overwrite of components from the same action.
The CD validation now reports the identity of the validated component version, if the validation fails.
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
What type of PR is this? (check all applicable)
Related Tickets & Documents
Screenshots
Added tests?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Added to documentation?
Checklist: