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