summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
d019988)
Issue-ID: NONRTRIC-814
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Ib1548369492338f8d660e5dd7890d967da1e24dc
}
func checkCommType(resources *[]publishapi.Resource, commType *publishapi.CommunicationType) bool {
}
func checkCommType(resources *[]publishapi.Resource, commType *publishapi.CommunicationType) bool {
- match := false
- if commType != nil {
- for _, resource := range *resources {
- if resource.CommType == *commType {
- match = true
- break
- }
+ for _, resource := range *resources {
+ if resource.CommType == *commType {
+ return true
- } else {
- match = true
}
// This function wraps sending of an error in the Error format, and
}
// This function wraps sending of an error in the Error format, and
return sendCoreError(ctx, http.StatusBadRequest, "Invalid format for invoker")
}
return sendCoreError(ctx, http.StatusBadRequest, "Invalid format for invoker")
}
- coreError := im.validateInvoker(newInvoker, ctx)
- if coreError != nil {
+ shouldReturn, coreError := im.validateInvoker(newInvoker, ctx)
+ if shouldReturn {
return sendCoreError(ctx, http.StatusBadRequest, "Invoker ApiInvokerId not matching")
}
return sendCoreError(ctx, http.StatusBadRequest, "Invoker ApiInvokerId not matching")
}
- coreError := im.validateInvoker(invoker, ctx)
- if coreError != nil {
+ shouldReturn, coreError := im.validateInvoker(invoker, ctx)
+ if shouldReturn {
return ctx.NoContent(http.StatusNotImplemented)
}
return ctx.NoContent(http.StatusNotImplemented)
}
-func (im *InvokerManager) validateInvoker(invoker invokerapi.APIInvokerEnrolmentDetails, ctx echo.Context) error {
+func (im *InvokerManager) validateInvoker(invoker invokerapi.APIInvokerEnrolmentDetails, ctx echo.Context) (bool, error) {
if invoker.NotificationDestination == "" {
if invoker.NotificationDestination == "" {
- return sendCoreError(ctx, http.StatusBadRequest, "Invoker missing required NotificationDestination")
+ return true, sendCoreError(ctx, http.StatusBadRequest, "Invoker missing required NotificationDestination")
}
if invoker.OnboardingInformation.ApiInvokerPublicKey == "" {
}
if invoker.OnboardingInformation.ApiInvokerPublicKey == "" {
- return sendCoreError(ctx, http.StatusBadRequest, "Invoker missing required OnboardingInformation.ApiInvokerPublicKey")
+ return true, sendCoreError(ctx, http.StatusBadRequest, "Invoker missing required OnboardingInformation.ApiInvokerPublicKey")
}
if !im.areAPIsRegistered(invoker.ApiList) {
}
if !im.areAPIsRegistered(invoker.ApiList) {
- return sendCoreError(ctx, http.StatusBadRequest, "Some APIs needed by invoker are not registered")
+ return true, sendCoreError(ctx, http.StatusBadRequest, "Some APIs needed by invoker are not registered")
}
func (im *InvokerManager) areAPIsRegistered(apis *invokerapi.APIList) bool {
}
func (im *InvokerManager) areAPIsRegistered(apis *invokerapi.APIList) bool {