Documentation ¶
Index ¶
- Variables
- func Converter(input models.LicenseJson) models.LicenseDB
- func GenerateDiffForReplacingLicenses(obligation *models.Obligation, newLicenseAssociations []string, ...)
- func GetAuditEntity(c *gin.Context, audit *models.Audit) error
- func GetKid(token string) (string, error)
- func HashPassword(user *models.User) error
- func ParseIdToInt(c *gin.Context, id string, idType string) (int64, error)
- func PerformObligationMapActions(username string, obligation *models.Obligation, ...) ([]string, []error)
- func Populatedb(datafile string)
- func PreparePaginateResponse(c *gin.Context, query *gorm.DB, responseModel interface{}) models.PaginationInput
- func VerifyPassword(inputPassword, dbPassword string) error
- type LicenseImportStatusCode
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultPage Set default page to 1 DefaultPage int64 = 1 // DefaultLimit Set default max limit to 20 DefaultLimit int64 = 20 )
Functions ¶
func Converter ¶
func Converter(input models.LicenseJson) models.LicenseDB
The Converter function takes an input of type models.LicenseJson and converts it into a corresponding models.LicenseDB object. It performs several field assignments and transformations to create the LicenseDB object, including generating the SpdxId based on the SpdxCompatible field. The resulting LicenseDB object is returned as the output of this function.
func GenerateDiffForReplacingLicenses ¶
func GenerateDiffForReplacingLicenses(obligation *models.Obligation, newLicenseAssociations []string, removeLicenses, insertLicenses *[]string)
GenerateDiffForReplacingLicenses creates list of license associations to be created and deleted such that the list of currently associated licenses to a obligation is overwritten by the list provided in the param newLicenseAssociations
func GetAuditEntity ¶
GetAuditEntity is an utility function to fetch obligation or license associated with an audit
func GetKid ¶
https://github.com/lestrrat-go/jwx/discussions/547 Get kid field value from JWS Header
func HashPassword ¶
HashPassword hashes the password of the user using bcrypt. It also trims the username and escapes the HTML characters.
func ParseIdToInt ¶
ParseIdToInt convert the string ID from gin.Context to an integer and throw error if conversion fails. Also, update the gin.Context with REST API error.
func PerformObligationMapActions ¶
func PerformObligationMapActions(username string, obligation *models.Obligation, removeLicenses, insertLicenses []string) ([]string, []error)
PerformObligationMapActions created associations for licenses in insertLicenses and deletes associations for licenses in removeLicenses. It also calculates changelog for the changes. It returns the final list of associated licenses.
func Populatedb ¶
func Populatedb(datafile string)
Populatedb populates the database with license data from a JSON file.
func PreparePaginateResponse ¶
func PreparePaginateResponse(c *gin.Context, query *gorm.DB, responseModel interface{}) models.PaginationInput
PreparePaginateResponse prepares the pagination response for the API. It gets the count of total rows and sets the pagination parameters, also updates the query limit and offset and update the "paginationMeta" and "responseModel" in gin.Context for middleware to process.
func VerifyPassword ¶
VerifyPassword compares the input password with the password stored in the database. Returns nil on success, or an error on failure.
Types ¶
type LicenseImportStatusCode ¶
type LicenseImportStatusCode int
LicenseImportStatusCode is internally used for checking status of a license import
const ( IMPORT_FAILED LicenseImportStatusCode = iota + 1 IMPORT_LICENSE_CREATED IMPORT_LICENSE_UPDATED IMPORT_LICENSE_UPDATED_EXCEPT_TEXT )
Status codes covering various scenarios that can occur on a license import