forked from TrueCloudLab/policy-engine
54 lines
1 KiB
Go
54 lines
1 KiB
Go
|
package testutil
|
||
|
|
||
|
import (
|
||
|
resourcepkg "git.frostfs.info/TrueCloudLab/policy-engine/pkg/resource"
|
||
|
)
|
||
|
|
||
|
type Resource struct {
|
||
|
name string
|
||
|
properties map[string]string
|
||
|
}
|
||
|
|
||
|
func (r *Resource) Name() string {
|
||
|
return r.name
|
||
|
}
|
||
|
|
||
|
func (r *Resource) Property(name string) string {
|
||
|
return r.properties[name]
|
||
|
}
|
||
|
|
||
|
func NewResource(name string, properties map[string]string) *Resource {
|
||
|
if properties == nil {
|
||
|
properties = make(map[string]string)
|
||
|
}
|
||
|
return &Resource{name: name, properties: properties}
|
||
|
}
|
||
|
|
||
|
type Request struct {
|
||
|
operation string
|
||
|
properties map[string]string
|
||
|
resource *Resource
|
||
|
}
|
||
|
|
||
|
var _ resourcepkg.Request = (*Request)(nil)
|
||
|
|
||
|
func (r *Request) Operation() string {
|
||
|
return r.operation
|
||
|
}
|
||
|
|
||
|
func (r *Request) Resource() resourcepkg.Resource {
|
||
|
return r.resource
|
||
|
}
|
||
|
|
||
|
func (r *Request) Property(name string) string {
|
||
|
return r.properties[name]
|
||
|
}
|
||
|
|
||
|
func NewRequest(op string, r *Resource, properties map[string]string) *Request {
|
||
|
return &Request{
|
||
|
operation: op,
|
||
|
properties: properties,
|
||
|
resource: r,
|
||
|
}
|
||
|
}
|