Skip to content

Commit c79715a

Browse files
authored
Merge pull request #263 from ydb-platform/scheme-put-permissions
Refactored of making permissions from scheme entry
2 parents 5ff3cad + 1c9bc44 commit c79715a

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Refactored of making permissions from scheme entry
2+
13
## v3.26.1
24
* Removed deprecated traces
35

scheme/scheme.go

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,12 @@ func (e *Entry) IsCoordinationNode() bool {
9494
}
9595

9696
func (e *Entry) From(y *Ydb_Scheme.Entry) {
97-
var (
98-
n = len(y.Permissions)
99-
m = len(y.EffectivePermissions)
100-
p = make([]Permissions, n+m)
101-
)
102-
putPermissions(p[:n], y.Permissions)
103-
putPermissions(p[n:], y.EffectivePermissions)
10497
*e = Entry{
10598
Name: y.Name,
10699
Owner: y.Owner,
107100
Type: entryType(y.Type),
108-
Permissions: p[0:n],
109-
EffectivePermissions: p[n:m],
101+
Permissions: makePermissions(y.Permissions),
102+
EffectivePermissions: makePermissions(y.EffectivePermissions),
110103
}
111104
}
112105

@@ -131,9 +124,17 @@ func entryType(t Ydb_Scheme.Entry_Type) EntryType {
131124
}
132125
}
133126

134-
func putPermissions(dst []Permissions, src []*Ydb_Scheme.Permissions) {
135-
for i, p := range src {
136-
(dst[i]).from(p)
127+
func makePermissions(src []*Ydb_Scheme.Permissions) (dst []Permissions) {
128+
for _, p := range src {
129+
dst = append(dst, from(p))
130+
}
131+
return dst
132+
}
133+
134+
func from(y *Ydb_Scheme.Permissions) (p Permissions) {
135+
return Permissions{
136+
Subject: y.Subject,
137+
PermissionNames: y.PermissionNames,
137138
}
138139
}
139140

@@ -147,13 +148,6 @@ func (p Permissions) To(y *Ydb_Scheme.Permissions) {
147148
y.PermissionNames = p.PermissionNames
148149
}
149150

150-
func (p *Permissions) from(y *Ydb_Scheme.Permissions) {
151-
*p = Permissions{
152-
Subject: y.Subject,
153-
PermissionNames: y.PermissionNames,
154-
}
155-
}
156-
157151
func InnerConvertEntry(y *Ydb_Scheme.Entry) *Entry {
158152
res := &Entry{}
159153
res.From(y)

0 commit comments

Comments
 (0)