feat(license_import): Add endpoint to import licenses via a json file #54
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.
Code Overview:
InsertOrUpdateLicenseOnImport
for creating/updating a single license on import. This function will be used in bothPopulatedb
function and /licenses/import endpoint.-
InsertOrUpdateLicenseOnImport
takes input a map of license fields. This was done to accomodate updates of fields with zero values as valid values( ex. Risk can be 0, Active can be false ). GORM doesn't update fields with zero values when updating using a struct.addChangelogsForLicenseUpdate
was kept seperate fromInsertOrUpdateLicenseOnImport
to make the latter generic.Populatedb
won't needaddChangelogsForLicenseUpdate
.NullableAndOptionalData
was introduced to differentiate between fields with zero values and fields with null values/undefined fields in json(in all the cases the unmarshalled struct will have zero values).InsertOrUpdateLicenseOnImport
will be added toPopulatedb
in next PR to keep this PR size manageable.InsertOrUpdateLicenseOnImport
returnserrMessage
andimportStatus
along with some license structs to make it generic. This was done because in endpoint, the relevant data will be added to response body while it will be logged in 'Populatedb'.Behaviour: