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
1ee2b014
Commit
1ee2b014
authored
May 27, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: remove Ui/Cache from CoreConfig
parent
1d3a4d6a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
47 deletions
+33
-47
command/build.go
command/build.go
+1
-1
command/meta.go
command/meta.go
+1
-0
commands.go
commands.go
+9
-18
config.go
config.go
+0
-3
main.go
main.go
+22
-7
packer/core.go
packer/core.go
+0
-15
packer/testing.go
packer/testing.go
+0
-3
No files found.
command/build.go
View file @
1ee2b014
...
...
@@ -149,7 +149,7 @@ func (c BuildCommand) Run(args []string) int {
name
:=
b
.
Name
()
log
.
Printf
(
"Starting build run: %s"
,
name
)
ui
:=
buildUis
[
name
]
runArtifacts
,
err
:=
b
.
Run
(
ui
,
c
.
C
oreConfig
.
C
ache
)
runArtifacts
,
err
:=
b
.
Run
(
ui
,
c
.
Cache
)
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Build '%s' errored: %s"
,
name
,
err
))
...
...
command/meta.go
View file @
1ee2b014
...
...
@@ -26,6 +26,7 @@ const (
// Packer command inherits.
type
Meta
struct
{
CoreConfig
*
packer
.
CoreConfig
Cache
packer
.
Cache
Ui
packer
.
Ui
// These are set by command-line flags
...
...
commands.go
View file @
1ee2b014
...
...
@@ -6,62 +6,53 @@ import (
"github.com/mitchellh/cli"
"github.com/mitchellh/packer/command"
"github.com/mitchellh/packer/packer"
)
// Commands is the mapping of all the available Terraform commands.
var
Commands
map
[
string
]
cli
.
CommandFactory
// Ui is the cli.Ui used for communicating to the outside world.
var
Ui
cli
.
Ui
// CommandMeta is the Meta to use for the commands. This must be written
// before the CLI is started.
var
CommandMeta
*
command
.
Meta
const
ErrorPrefix
=
"e:"
const
OutputPrefix
=
"o:"
func
init
()
{
meta
:=
command
.
Meta
{
CoreConfig
:
&
CoreConfig
,
Ui
:
&
packer
.
BasicUi
{
Reader
:
os
.
Stdin
,
Writer
:
os
.
Stdout
,
ErrorWriter
:
os
.
Stdout
,
},
}
Commands
=
map
[
string
]
cli
.
CommandFactory
{
"build"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
BuildCommand
{
Meta
:
m
eta
,
Meta
:
*
CommandM
eta
,
},
nil
},
"fix"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
FixCommand
{
Meta
:
m
eta
,
Meta
:
*
CommandM
eta
,
},
nil
},
"inspect"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
InspectCommand
{
Meta
:
m
eta
,
Meta
:
*
CommandM
eta
,
},
nil
},
"push"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
PushCommand
{
Meta
:
m
eta
,
Meta
:
*
CommandM
eta
,
},
nil
},
"validate"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
ValidateCommand
{
Meta
:
m
eta
,
Meta
:
*
CommandM
eta
,
},
nil
},
"version"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
VersionCommand
{
Meta
:
m
eta
,
Meta
:
*
CommandM
eta
,
Revision
:
GitCommit
,
Version
:
Version
,
VersionPrerelease
:
VersionPrerelease
,
...
...
config.go
View file @
1ee2b014
...
...
@@ -13,9 +13,6 @@ import (
"github.com/mitchellh/packer/packer/plugin"
)
// CoreConfig is the global CoreConfig we use to initialize the CLI.
var
CoreConfig
packer
.
CoreConfig
type
config
struct
{
DisableCheckpoint
bool
`json:"disable_checkpoint"`
DisableCheckpointSignature
bool
`json:"disable_checkpoint_signature"`
...
...
main.go
View file @
1ee2b014
...
...
@@ -12,6 +12,7 @@ import (
"sync"
"github.com/mitchellh/cli"
"github.com/mitchellh/packer/command"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer/plugin"
"github.com/mitchellh/panicwrap"
...
...
@@ -139,14 +140,14 @@ func wrappedMain() int {
defer
plugin
.
CleanupClients
()
//
Create the environment configuration
CoreConfig
.
Cache
=
cache
CoreConfig
.
Components
.
Builder
=
config
.
LoadBuilder
CoreConfig
.
Components
.
Hook
=
config
.
LoadHook
CoreConfig
.
Components
.
PostProcessor
=
config
.
LoadPostProcessor
CoreConfig
.
Components
.
Provisioner
=
config
.
LoadProvisioner
//
Setup the UI if we're being machine-readable
var
ui
packer
.
Ui
=
&
packer
.
BasicUi
{
Reader
:
os
.
Stdin
,
Writer
:
os
.
Stdout
,
ErrorWriter
:
os
.
Stdout
,
}
if
machineReadable
{
CoreConfig
.
U
i
=
&
packer
.
MachineReadableUi
{
u
i
=
&
packer
.
MachineReadableUi
{
Writer
:
os
.
Stdout
,
}
...
...
@@ -158,6 +159,20 @@ func wrappedMain() int {
}
}
// Create the CLI meta
CommandMeta
=
&
command
.
Meta
{
CoreConfig
:
&
packer
.
CoreConfig
{
Components
:
packer
.
ComponentFinder
{
Builder
:
config
.
LoadBuilder
,
Hook
:
config
.
LoadHook
,
PostProcessor
:
config
.
LoadPostProcessor
,
Provisioner
:
config
.
LoadProvisioner
,
},
},
Cache
:
cache
,
Ui
:
ui
,
}
//setupSignalHandlers(env)
cli
:=
&
cli
.
CLI
{
...
...
packer/core.go
View file @
1ee2b014
...
...
@@ -2,7 +2,6 @@ package packer
import
(
"fmt"
"os"
"sort"
"github.com/hashicorp/go-multierror"
...
...
@@ -13,9 +12,7 @@ import (
// Core is the main executor of Packer. If Packer is being used as a
// library, this is the struct you'll want to instantiate to get anything done.
type
Core
struct
{
cache
Cache
components
ComponentFinder
ui
Ui
template
*
template
.
Template
variables
map
[
string
]
string
builds
map
[
string
]
*
template
.
Builder
...
...
@@ -24,9 +21,7 @@ type Core struct {
// CoreConfig is the structure for initializing a new Core. Once a CoreConfig
// is used to initialize a Core, it shouldn't be re-used or modified again.
type
CoreConfig
struct
{
Cache
Cache
Components
ComponentFinder
Ui
Ui
Template
*
template
.
Template
Variables
map
[
string
]
string
}
...
...
@@ -55,14 +50,6 @@ type ComponentFinder struct {
// NewCore creates a new Core.
func
NewCore
(
c
*
CoreConfig
)
(
*
Core
,
error
)
{
if
c
.
Ui
==
nil
{
c
.
Ui
=
&
BasicUi
{
Reader
:
os
.
Stdin
,
Writer
:
os
.
Stdout
,
ErrorWriter
:
os
.
Stdout
,
}
}
// Go through and interpolate all the build names. We shuld be able
// to do this at this point with the variables.
builds
:=
make
(
map
[
string
]
*
template
.
Builder
)
...
...
@@ -80,9 +67,7 @@ func NewCore(c *CoreConfig) (*Core, error) {
}
return
&
Core
{
cache
:
c
.
Cache
,
components
:
c
.
Components
,
ui
:
c
.
Ui
,
template
:
c
.
Template
,
variables
:
c
.
Variables
,
builds
:
builds
,
...
...
packer/testing.go
View file @
1ee2b014
...
...
@@ -3,7 +3,6 @@ package packer
import
(
"bytes"
"io/ioutil"
"os"
"testing"
)
...
...
@@ -20,9 +19,7 @@ func TestCoreConfig(t *testing.T) *CoreConfig {
}
return
&
CoreConfig
{
Cache
:
&
FileCache
{
CacheDir
:
os
.
TempDir
()},
Components
:
components
,
Ui
:
TestUi
(
t
),
}
}
...
...
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