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
cbe6e83b
Commit
cbe6e83b
authored
May 27, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/docker-*: fix compilation errors
parent
c3b75f4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
136 deletions
+46
-136
post-processor/docker-import/post-processor.go
post-processor/docker-import/post-processor.go
+11
-34
post-processor/docker-push/post-processor.go
post-processor/docker-push/post-processor.go
+12
-34
post-processor/docker-save/post-processor.go
post-processor/docker-save/post-processor.go
+12
-34
post-processor/docker-tag/post-processor.go
post-processor/docker-tag/post-processor.go
+11
-34
No files found.
post-processor/docker-import/post-processor.go
View file @
cbe6e83b
...
...
@@ -2,9 +2,12 @@ package dockerimport
import
(
"fmt"
"github.com/mitchellh/packer/builder/docker"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
)
const
BuilderId
=
"packer.post-processor.docker-import"
...
...
@@ -15,7 +18,7 @@ type Config struct {
Repository
string
`mapstructure:"repository"`
Tag
string
`mapstructure:"tag"`
tpl
*
packer
.
ConfigTemplate
ctx
interpolate
.
Context
}
type
PostProcessor
struct
{
...
...
@@ -23,41 +26,15 @@ type PostProcessor struct {
}
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
_
,
err
:=
common
.
DecodeConfig
(
&
p
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
(
)
err
:=
config
.
Decode
(
&
p
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{},
},
},
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
.
UserVars
=
p
.
config
.
PackerUserVars
// Accumulate any errors
errs
:=
new
(
packer
.
MultiError
)
templates
:=
map
[
string
]
*
string
{
"repository"
:
&
p
.
config
.
Repository
,
"tag"
:
&
p
.
config
.
Tag
,
}
for
key
,
ptr
:=
range
templates
{
if
*
ptr
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"%s must be set"
,
key
))
}
*
ptr
,
err
=
p
.
config
.
tpl
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
key
,
err
))
}
}
if
len
(
errs
.
Errors
)
>
0
{
return
errs
}
return
nil
...
...
@@ -76,7 +53,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
importRepo
+=
":"
+
p
.
config
.
Tag
}
driver
:=
&
docker
.
DockerDriver
{
Tpl
:
p
.
config
.
tpl
,
Ui
:
ui
}
driver
:=
&
docker
.
DockerDriver
{
Ctx
:
&
p
.
config
.
ctx
,
Ui
:
ui
}
ui
.
Message
(
"Importing image: "
+
artifact
.
Id
())
ui
.
Message
(
"Repository: "
+
importRepo
)
...
...
post-processor/docker-push/post-processor.go
View file @
cbe6e83b
...
...
@@ -2,12 +2,15 @@ package dockerpush
import
(
"fmt"
"strings"
"github.com/mitchellh/packer/builder/docker"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/post-processor/docker-import"
"github.com/mitchellh/packer/post-processor/docker-tag"
"
strings
"
"
github.com/mitchellh/packer/template/interpolate
"
)
type
Config
struct
{
...
...
@@ -19,7 +22,7 @@ type Config struct {
LoginPassword
string
`mapstructure:"login_password"`
LoginServer
string
`mapstructure:"login_server"`
tpl
*
packer
.
ConfigTemplate
ctx
interpolate
.
Context
}
type
PostProcessor
struct
{
...
...
@@ -29,40 +32,15 @@ type PostProcessor struct {
}
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
_
,
err
:=
common
.
DecodeConfig
(
&
p
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
(
)
err
:=
config
.
Decode
(
&
p
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{},
},
},
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
.
UserVars
=
p
.
config
.
PackerUserVars
// Accumulate any errors
errs
:=
new
(
packer
.
MultiError
)
// Process templates
templates
:=
map
[
string
]
*
string
{
"login_email"
:
&
p
.
config
.
LoginEmail
,
"login_username"
:
&
p
.
config
.
LoginUsername
,
"login_password"
:
&
p
.
config
.
LoginPassword
,
"login_server"
:
&
p
.
config
.
LoginServer
,
}
for
n
,
ptr
:=
range
templates
{
var
err
error
*
ptr
,
err
=
p
.
config
.
tpl
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
n
,
err
))
}
}
if
len
(
errs
.
Errors
)
>
0
{
return
errs
}
return
nil
}
...
...
@@ -79,7 +57,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
driver
:=
p
.
Driver
if
driver
==
nil
{
// If no driver is set, then we use the real driver
driver
=
&
docker
.
DockerDriver
{
Tpl
:
p
.
config
.
tpl
,
Ui
:
ui
}
driver
=
&
docker
.
DockerDriver
{
Ctx
:
&
p
.
config
.
ctx
,
Ui
:
ui
}
}
if
p
.
config
.
Login
{
...
...
post-processor/docker-save/post-processor.go
View file @
cbe6e83b
...
...
@@ -2,11 +2,14 @@ package dockersave
import
(
"fmt"
"os"
"github.com/mitchellh/packer/builder/docker"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/post-processor/docker-import"
"
os
"
"
github.com/mitchellh/packer/template/interpolate
"
)
const
BuilderId
=
"packer.post-processor.docker-save"
...
...
@@ -16,7 +19,7 @@ type Config struct {
Path
string
`mapstructure:"path"`
tpl
*
packer
.
ConfigTemplate
ctx
interpolate
.
Context
}
type
PostProcessor
struct
{
...
...
@@ -26,40 +29,15 @@ type PostProcessor struct {
}
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
_
,
err
:=
common
.
DecodeConfig
(
&
p
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
(
)
err
:=
config
.
Decode
(
&
p
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{},
},
},
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
.
UserVars
=
p
.
config
.
PackerUserVars
// Accumulate any errors
errs
:=
new
(
packer
.
MultiError
)
templates
:=
map
[
string
]
*
string
{
"path"
:
&
p
.
config
.
Path
,
}
for
key
,
ptr
:=
range
templates
{
if
*
ptr
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"%s must be set"
,
key
))
}
*
ptr
,
err
=
p
.
config
.
tpl
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
key
,
err
))
}
}
if
len
(
errs
.
Errors
)
>
0
{
return
errs
}
return
nil
...
...
@@ -85,7 +63,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
driver
:=
p
.
Driver
if
driver
==
nil
{
// If no driver is set, then we use the real driver
driver
=
&
docker
.
DockerDriver
{
Tpl
:
p
.
config
.
tpl
,
Ui
:
ui
}
driver
=
&
docker
.
DockerDriver
{
Ctx
:
&
p
.
config
.
ctx
,
Ui
:
ui
}
}
ui
.
Message
(
"Saving image: "
+
artifact
.
Id
())
...
...
post-processor/docker-tag/post-processor.go
View file @
cbe6e83b
...
...
@@ -2,10 +2,13 @@ package dockertag
import
(
"fmt"
"github.com/mitchellh/packer/builder/docker"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/post-processor/docker-import"
"github.com/mitchellh/packer/template/interpolate"
)
const
BuilderId
=
"packer.post-processor.docker-tag"
...
...
@@ -16,7 +19,7 @@ type Config struct {
Repository
string
`mapstructure:"repository"`
Tag
string
`mapstructure:"tag"`
tpl
*
packer
.
ConfigTemplate
ctx
interpolate
.
Context
}
type
PostProcessor
struct
{
...
...
@@ -26,41 +29,15 @@ type PostProcessor struct {
}
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
_
,
err
:=
common
.
DecodeConfig
(
&
p
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
(
)
err
:=
config
.
Decode
(
&
p
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{},
},
},
raws
...
)
if
err
!=
nil
{
return
err
}
p
.
config
.
tpl
.
UserVars
=
p
.
config
.
PackerUserVars
// Accumulate any errors
errs
:=
new
(
packer
.
MultiError
)
templates
:=
map
[
string
]
*
string
{
"repository"
:
&
p
.
config
.
Repository
,
"tag"
:
&
p
.
config
.
Tag
,
}
for
key
,
ptr
:=
range
templates
{
if
*
ptr
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"%s must be set"
,
key
))
}
*
ptr
,
err
=
p
.
config
.
tpl
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
key
,
err
))
}
}
if
len
(
errs
.
Errors
)
>
0
{
return
errs
}
return
nil
...
...
@@ -77,7 +54,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
driver
:=
p
.
Driver
if
driver
==
nil
{
// If no driver is set, then we use the real driver
driver
=
&
docker
.
DockerDriver
{
Tpl
:
p
.
config
.
tpl
,
Ui
:
ui
}
driver
=
&
docker
.
DockerDriver
{
Ctx
:
&
p
.
config
.
ctx
,
Ui
:
ui
}
}
importRepo
:=
p
.
config
.
Repository
...
...
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