Skip to content

Commit

Permalink
Merge pull request #19 from permitio/omer/per-7942-golang-sdk-resourc…
Browse files Browse the repository at this point in the history
…e-attributes-type-issue

Fix type hint of User & Resource attributes
  • Loading branch information
omer9564 authored Sep 26, 2023
2 parents 75859e4 + 42259c3 commit 0ef191a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions pkg/enforcement/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ type ResourceI interface {
GetID() string
GetType() string
GetTenant() string
GetAttributes() map[string]string
GetAttributes() map[string]interface{}
GetContext() map[string]string
}

type Resource struct {
Type string `json:"type,omitempty"`
ID string `json:"id,omitempty"`
Tenant string `json:"tenant,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
Context map[string]string `json:"context,omitempty"`
Type string `json:"type,omitempty"`
ID string `json:"id,omitempty"`
Tenant string `json:"tenant,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
Context map[string]string `json:"context,omitempty"`
}

func (r *Resource) GetID() string {
Expand All @@ -28,7 +28,7 @@ func (r *Resource) GetTenant() string {
return r.Tenant
}

func (r *Resource) GetAttributes() map[string]string {
func (r *Resource) GetAttributes() map[string]interface{} {
return r.Attributes
}

Expand All @@ -52,7 +52,7 @@ func (r *Resource) WithTenant(tenant string) *Resource {
return r
}

func (r *Resource) WithAttributes(attributes map[string]string) *Resource {
func (r *Resource) WithAttributes(attributes map[string]interface{}) *Resource {
r.Attributes = attributes
return r
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/enforcement/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ type AssignedRole struct {
}

type User struct {
Key string `json:"key,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Email string `json:"email,omitempty"`
Roles []AssignedRole `json:"roles,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
Key string `json:"key,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Email string `json:"email,omitempty"`
Roles []AssignedRole `json:"roles,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
}

func UserBuilder(key string) *User {
Expand Down Expand Up @@ -40,7 +40,7 @@ func (u *User) WithRoles(roles []AssignedRole) *User {
return u
}

func (u *User) WithAttributes(attributes map[string]string) *User {
func (u *User) WithAttributes(attributes map[string]interface{}) *User {
u.Attributes = attributes
return u
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (m MyResource) GetTenant() string {
return m.Organization
}

func (m MyResource) GetAttributes() map[string]string {
return make(map[string]string)
func (m MyResource) GetAttributes() map[string]interface{} {
return make(map[string]interface{})
}

func (m MyResource) GetContext() map[string]string {
Expand Down

0 comments on commit 0ef191a

Please sign in to comment.