proper
This commit is contained in:
@@ -52,7 +52,7 @@ func (d *DynamicResource) SetAllowedInstances(request *tools.APIRequest, instanc
|
|||||||
if d.Type != k {
|
if d.Type != k {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
access := NewAccessor[*DynamicResource](k, request)
|
access := d.getResAccessor(k, request)
|
||||||
m := map[string]interface{}{}
|
m := map[string]interface{}{}
|
||||||
b, _ := json.Marshal(d.Filters)
|
b, _ := json.Marshal(d.Filters)
|
||||||
json.Unmarshal(b, &m)
|
json.Unmarshal(b, &m)
|
||||||
@@ -80,6 +80,22 @@ func (d *DynamicResource) SetAllowedInstances(request *tools.APIRequest, instanc
|
|||||||
return d.Instances
|
return d.Instances
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DynamicResource) getResAccessor(dt tools.DataType, request *tools.APIRequest) utils.Accessor {
|
||||||
|
switch dt {
|
||||||
|
case tools.COMPUTE_RESOURCE:
|
||||||
|
return NewAccessor[*ComputeResource](dt, request)
|
||||||
|
case tools.PROCESSING_RESOURCE:
|
||||||
|
return NewAccessor[*ProcessingResource](dt, request)
|
||||||
|
case tools.DATA_RESOURCE:
|
||||||
|
return NewAccessor[*DataResource](dt, request)
|
||||||
|
case tools.STORAGE_RESOURCE:
|
||||||
|
return NewAccessor[*ServiceResource](dt, request)
|
||||||
|
case tools.WORKFLOW_RESOURCE:
|
||||||
|
return NewAccessor[*WorkflowResource](dt, request)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DynamicResource) AddInstances(instance ResourceInstanceITF) {
|
func (d *DynamicResource) AddInstances(instance ResourceInstanceITF) {
|
||||||
d.Instances = append(d.Instances, instance)
|
d.Instances = append(d.Instances, instance)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,9 +234,7 @@ func (r *AbstractInstanciatedResource[T]) GetSelectedInstance(selected *int) Res
|
|||||||
|
|
||||||
func (abs *AbstractInstanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest, instanceID ...string) []ResourceInstanceITF {
|
func (abs *AbstractInstanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest, instanceID ...string) []ResourceInstanceITF {
|
||||||
if !((request != nil && request.PeerID == abs.CreatorID && request.PeerID != "") || request.Admin) {
|
if !((request != nil && request.PeerID == abs.CreatorID && request.PeerID != "") || request.Admin) {
|
||||||
|
|
||||||
abs.Instances = VerifyAuthAction(abs.Instances, request, instanceID...)
|
abs.Instances = VerifyAuthAction(abs.Instances, request, instanceID...)
|
||||||
fmt.Println("Not Admin", abs.Name, abs.Instances)
|
|
||||||
// Filter AEs: only return AEs visible to the requesting peer.
|
// Filter AEs: only return AEs visible to the requesting peer.
|
||||||
if request != nil {
|
if request != nil {
|
||||||
abs.FilterExploitationAuthorizations(request.PeerID, request.Admin)
|
abs.FilterExploitationAuthorizations(request.PeerID, request.Admin)
|
||||||
|
|||||||
Reference in New Issue
Block a user