Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
947209a0
Commit
947209a0
authored
May 08, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: PACKER_LOG to toggle logging from an env var [GH-3]
parent
7dfeda35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
packer.go
packer.go
+9
-0
packer/environment.go
packer/environment.go
+4
-0
No files found.
packer.go
View file @
947209a0
...
...
@@ -5,12 +5,21 @@ import (
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer/plugin"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
)
func
main
()
{
if
os
.
Getenv
(
"PACKER_LOG"
)
==
""
{
// If we don't have logging explicitly enabled, then disable it
log
.
SetOutput
(
ioutil
.
Discard
)
}
else
{
// Logging is enabled, make sure it goes to stderr
log
.
SetOutput
(
os
.
Stderr
)
}
defer
plugin
.
CleanupClients
()
commands
:=
map
[
string
]
string
{
...
...
packer/environment.go
View file @
947209a0
...
...
@@ -4,6 +4,7 @@ package packer
import
(
"errors"
"fmt"
"log"
"os"
"sort"
"strings"
...
...
@@ -87,6 +88,8 @@ func (e *coreEnvironment) Builder(name string) (b Builder, err error) {
// Executes a command as if it was typed on the command-line interface.
// The return value is the exit code of the command.
func
(
e
*
coreEnvironment
)
Cli
(
args
[]
string
)
(
result
int
,
err
error
)
{
log
.
Printf
(
"Environment.Cli: %#v
\n
"
,
args
)
if
len
(
args
)
==
0
||
args
[
0
]
==
"--help"
||
args
[
0
]
==
"-h"
{
e
.
printHelp
()
return
1
,
nil
...
...
@@ -115,6 +118,7 @@ func (e *coreEnvironment) Cli(args []string) (result int, err error) {
// If we still don't have a command, show the help.
if
command
==
nil
{
log
.
Printf
(
"Environment.CLI: command not found: %s
\n
"
,
args
[
0
])
e
.
printHelp
()
return
1
,
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment