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
c883fbdcdd4d
Commit
c883fbdcdd4d
authored
1 year ago
by
steeve.chailloux
Browse files
Options
Downloads
Patches
Plain Diff
can now print output to stdout using: -o stdout
parent
32cece3f2c91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/build.go
+2
-2
2 additions, 2 deletions
cmd/build.go
runner/main.go
+20
-11
20 additions, 11 deletions
runner/main.go
with
22 additions
and
13 deletions
cmd/build.go
+
2
−
2
View file @
c883fbdc
...
...
@@ -13,8 +13,8 @@
type
BuildCmd
struct
{
Args
struct
{
DryRun
bool
`short:"d" long:"dry-run" description:"if set only prints commands but do not run them"`
Keep
bool
`short:"k" long:"keep" description
s
:"Keep the temporary files"`
Output
string
`short:"o" long:"output" description
s
:"output directory"`
Keep
bool
`short:"k" long:"keep" description:"Keep the temporary files"`
Output
string
`short:"o" long:"output" description:"output directory
, use \"stdout\" to print to stdout
"`
}
PositionalArgs
struct
{
DirName
string
`required:"yes" positional-arg-name:"directory"`
...
...
This diff is collapsed.
Click to expand it.
runner/main.go
+
20
−
11
View file @
c883fbdc
...
...
@@ -54,11 +54,13 @@
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot list directory: %s - %w"
,
preBuildDir
,
err
)
}
if
err
:=
CleanDir
(
outputDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot clean dir: %s: %w"
,
outputDir
,
err
)
if
outputDir
!=
"stdout"
{
if
err
:=
CleanDir
(
outputDir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot clean dir: %s: %w"
,
outputDir
,
err
)
}
}
variables
,
err
:=
r
.
config
.
prepareVariables
(
true
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot prepare variables: %w"
,
err
)
}
for
_
,
file
:=
range
files
{
...
...
@@ -59,7 +61,9 @@
}
variables
,
err
:=
r
.
config
.
prepareVariables
(
true
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot prepare variables: %w"
,
err
)
}
for
_
,
file
:=
range
files
{
var
outFilePath
string
var
outFile
*
os
.
File
inFilePath
:=
filepath
.
Join
(
preBuildDir
,
file
.
Name
())
...
...
@@ -65,6 +69,16 @@
inFilePath
:=
filepath
.
Join
(
preBuildDir
,
file
.
Name
())
outFilePath
:=
filepath
.
Join
(
outputDir
,
file
.
Name
())
outFile
,
err
:=
os
.
Create
(
outFilePath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot open: %s - %w"
,
outFilePath
,
err
)
if
outputDir
==
"stdout"
{
outFilePath
=
"stdout"
outFile
=
os
.
Stdout
}
else
{
outFilePath
=
filepath
.
Join
(
outputDir
,
file
.
Name
())
outFile
,
err
=
os
.
Create
(
outFilePath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot open: %s - %w"
,
outFilePath
,
err
)
}
defer
func
()
{
if
err
:=
outFile
.
Close
();
err
!=
nil
{
r
.
config
.
Logger
.
Fatal
()
.
Err
(
err
)
.
Msg
(
"cannot close hydrated file"
)
}
}()
}
...
...
@@ -70,9 +84,4 @@
}
defer
func
()
{
if
err
:=
outFile
.
Close
();
err
!=
nil
{
r
.
config
.
Logger
.
Fatal
()
.
Err
(
err
)
.
Msg
(
"cannot close hydrated file"
)
}
}()
if
err
:=
hydrate
(
inFilePath
,
outFile
,
variables
);
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot hydrate: %s - %w"
,
outFilePath
,
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