Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beaver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
beaver
Commits
e9552392
Commit
e9552392
authored
2 years ago
by
Florent Aide
Browse files
Options
Downloads
Patches
Plain Diff
docstrings and small renamings
parent
5ddd47ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#38194
passed
2 years ago
Stage: test
Stage: lint
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/cmd.go
+1
-1
1 addition, 1 deletion
cmd/cmd.go
runner/main.go
+8
-6
8 additions, 6 deletions
runner/main.go
with
9 additions
and
7 deletions
cmd/cmd.go
+
1
−
1
View file @
e9552392
...
...
@@ -27,7 +27,7 @@
func
Run
()
int
{
if
_
,
err
:=
parser
.
Parse
();
err
!=
nil
{
code
:=
1
if
fe
,
ok
:=
err
.
(
*
flags
.
Error
);
ok
{
if
fe
,
ok
:=
err
.
(
*
flags
.
Error
);
ok
{
// nolint:errorlint
if
fe
.
Type
==
flags
.
ErrHelp
{
code
=
0
// this error actually contains a help message for the user
...
...
This diff is collapsed.
Click to expand it.
runner/main.go
+
8
−
6
View file @
e9552392
...
...
@@ -19,6 +19,7 @@
defaultDirMod
os
.
FileMode
=
0700
)
// Runner is the struct in charge of launching commands
type
Runner
struct
{
config
*
CmdConfig
}
...
...
@@ -129,7 +130,6 @@
Str
(
"stderr"
,
strings
.
Join
(
stdErr
,
"
\n
"
))
.
Msg
(
"failed to run command"
)
// TODO: print error to stderr
// Error message must be pretty printed to end users
fmt
.
Printf
(
"
\n
%s
\n\n
"
,
strings
.
Join
(
stdErr
,
"
\n
"
))
return
fmt
.
Errorf
(
"failed to run command: %w"
,
err
)
...
...
@@ -162,4 +162,6 @@
return
nil
}
// YamlSplit takes a buildDier and an inputFile.
// it returns a list of yaml documents and an eventual error
func
YamlSplit
(
buildDir
,
inputFile
string
)
([]
string
,
error
)
{
...
...
@@ -165,7 +167,7 @@
func
YamlSplit
(
buildDir
,
inputFile
string
)
([]
string
,
error
)
{
var
splitted
[]
string
var
docs
[]
string
var
allResources
[]
map
[
string
]
interface
{}
input
,
err
:=
os
.
ReadFile
(
inputFile
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -167,9 +169,9 @@
var
allResources
[]
map
[
string
]
interface
{}
input
,
err
:=
os
.
ReadFile
(
inputFile
)
if
err
!=
nil
{
return
nil
,
err
}
if
err
:=
U
nmarshalAllResources
(
input
,
&
allResources
);
err
!=
nil
{
if
err
:=
u
nmarshalAllResources
(
input
,
&
allResources
);
err
!=
nil
{
return
nil
,
err
}
for
_
,
resource
:=
range
allResources
{
...
...
@@ -203,6 +205,6 @@
if
err
:=
os
.
WriteFile
(
fPath
,
content
,
defaultFileMod
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot write resource: %w"
,
err
)
}
splitted
=
append
(
splitted
,
fPath
)
docs
=
append
(
docs
,
fPath
)
}
...
...
@@ -207,5 +209,5 @@
}
return
splitted
,
nil
return
docs
,
nil
}
...
...
@@ -210,6 +212,6 @@
}
func
U
nmarshalAllResources
(
in
[]
byte
,
out
*
[]
map
[
string
]
interface
{})
error
{
func
u
nmarshalAllResources
(
in
[]
byte
,
out
*
[]
map
[
string
]
interface
{})
error
{
r
:=
bytes
.
NewReader
(
in
)
decoder
:=
yaml
.
NewDecoder
(
r
)
for
{
...
...
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