Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
b7c26151
Commit
b7c26151
authored
4 months ago
by
Semyon Krestyaninov
Browse files
Options
Downloads
Patches
Plain Diff
fix linter
parent
d04b3223
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/schema/executor/executor.go
+26
-17
26 additions, 17 deletions
pkg/schema/executor/executor.go
pkg/schema/executor/template_executor.go
+5
-2
5 additions, 2 deletions
pkg/schema/executor/template_executor.go
pkg/schema/schema.go
+1
-2
1 addition, 2 deletions
pkg/schema/schema.go
with
32 additions
and
21 deletions
pkg/schema/executor/executor.go
+
26
−
17
View file @
b7c26151
...
@@ -38,11 +38,17 @@ func ExecuteAll(ctx context.Context, exec Executor, inputs []string) ([]string,
...
@@ -38,11 +38,17 @@ func ExecuteAll(ctx context.Context, exec Executor, inputs []string) ([]string,
}
}
func
Execute
(
ctx
context
.
Context
,
w
field
.
Walker
,
exec
Executor
)
error
{
func
Execute
(
ctx
context
.
Context
,
w
field
.
Walker
,
exec
Executor
)
error
{
_
,
_
,
err
:=
w
.
Walk
(
ctx
,
nil
,
func
(
ctx
context
.
Context
,
fld
*
field
.
Field
,
_
any
)
(
res
field
.
WalkFuncResult
,
err
error
)
{
_
,
_
,
err
:=
w
.
Walk
(
ctx
,
nil
,
func
(
ctx
context
.
Context
,
fld
*
field
.
Field
,
_
any
)
(
field
.
WalkFuncResult
,
error
)
{
var
(
result
field
.
WalkFuncResult
err
error
)
enabled
,
_
:=
fld
.
IsEnabled
(
ctx
)
enabled
,
_
:=
fld
.
IsEnabled
(
ctx
)
if
!
enabled
{
if
!
enabled
{
res
.
Stop
=
true
res
ult
.
Stop
=
true
return
return
result
,
err
}
}
for
_
,
op
:=
range
fld
.
Options
{
for
_
,
op
:=
range
fld
.
Options
{
...
@@ -52,16 +58,19 @@ func Execute(ctx context.Context, w field.Walker, exec Executor) error {
...
@@ -52,16 +58,19 @@ func Execute(ctx context.Context, w field.Walker, exec Executor) error {
}
}
err
=
executable
.
Execute
(
ctx
,
exec
,
fld
)
err
=
executable
.
Execute
(
ctx
,
exec
,
fld
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
result
,
err
}
}
}
}
return
return
result
,
err
},
field
.
WalkSchema
())
},
field
.
WalkSchema
(),
)
return
err
return
err
}
}
//nolint:gochecknoinits // init нужен для регистрации опций
func
init
()
{
func
init
()
{
field
.
RegisterOption
(
CollectionFilter
{})
field
.
RegisterOption
(
CollectionFilter
{})
field
.
RegisterOption
(
ItemFilter
{})
field
.
RegisterOption
(
ItemFilter
{})
...
...
This diff is collapsed.
Click to expand it.
pkg/schema/executor/template_executor.go
+
5
−
2
View file @
b7c26151
...
@@ -65,6 +65,7 @@ func (exec *TemplateExecutor) errorFunc(text string) (string, error) {
...
@@ -65,6 +65,7 @@ func (exec *TemplateExecutor) errorFunc(text string) (string, error) {
return
""
,
errors
.
New
(
text
)
return
""
,
errors
.
New
(
text
)
}
}
//nolint:gochecknoglobals // Доступ к пулу необходим на глобальном уровне.
var
bufferPool
=
&
sync
.
Pool
{
var
bufferPool
=
&
sync
.
Pool
{
New
:
func
()
any
{
New
:
func
()
any
{
return
new
(
bytes
.
Buffer
)
return
new
(
bytes
.
Buffer
)
...
@@ -72,11 +73,13 @@ var bufferPool = &sync.Pool{
...
@@ -72,11 +73,13 @@ var bufferPool = &sync.Pool{
}
}
func
getBuffer
()
*
bytes
.
Buffer
{
func
getBuffer
()
*
bytes
.
Buffer
{
return
bufferPool
.
Get
()
.
(
*
bytes
.
Buffer
)
buf
,
_
:=
bufferPool
.
Get
()
.
(
*
bytes
.
Buffer
)
return
buf
}
}
func
releaseBuffer
(
buf
*
bytes
.
Buffer
)
{
func
releaseBuffer
(
buf
*
bytes
.
Buffer
)
{
if
buf
.
Cap
()
>
1024
{
const
maxBufCap
=
1024
if
buf
.
Cap
()
>
maxBufCap
{
return
return
}
}
buf
.
Reset
()
buf
.
Reset
()
...
...
This diff is collapsed.
Click to expand it.
pkg/schema/schema.go
+
1
−
2
View file @
b7c26151
...
@@ -34,7 +34,6 @@ var (
...
@@ -34,7 +34,6 @@ var (
Modify
=
modify
.
Modify
Modify
=
modify
.
Modify
Validate
=
validate
.
Validate
Validate
=
validate
.
Validate
Evaluate
=
field
.
Evaluate
Evaluate
=
field
.
Evaluate
Execute
=
executor
.
Execute
)
)
func
(
s
*
Schema
)
Clone
(
reset
bool
)
*
Schema
{
func
(
s
*
Schema
)
Clone
(
reset
bool
)
*
Schema
{
...
@@ -274,7 +273,7 @@ func (s *Schema) Execute(ctx context.Context, exec executor.Executor) (*Schema,
...
@@ -274,7 +273,7 @@ func (s *Schema) Execute(ctx context.Context, exec executor.Executor) (*Schema,
}
}
var
clone
=
s
.
Clone
(
false
)
var
clone
=
s
.
Clone
(
false
)
err
:=
Execute
(
ctx
,
clone
,
exec
)
err
:=
executor
.
Execute
(
ctx
,
clone
,
exec
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment