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
f8c87777
Commit
f8c87777
authored
May 28, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'f-packer-push-name'
parents
da694a6e
344c7416
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
4 deletions
+54
-4
command/push.go
command/push.go
+13
-2
command/push_test.go
command/push_test.go
+36
-0
template/parse.go
template/parse.go
+1
-1
template/template.go
template/template.go
+1
-1
website/source/docs/command-line/push.html.markdown
website/source/docs/command-line/push.html.markdown
+3
-0
No files found.
command/push.go
View file @
f8c87777
...
...
@@ -34,6 +34,7 @@ type pushUploadFn func(
func
(
c
*
PushCommand
)
Run
(
args
[]
string
)
int
{
var
token
string
var
message
string
var
name
string
var
create
bool
f
:=
flag
.
NewFlagSet
(
"push"
,
flag
.
ContinueOnError
)
...
...
@@ -41,6 +42,7 @@ func (c *PushCommand) Run(args []string) int {
f
.
StringVar
(
&
token
,
"token"
,
""
,
"token"
)
f
.
StringVar
(
&
message
,
"m"
,
""
,
"message"
)
f
.
StringVar
(
&
message
,
"message"
,
""
,
"message"
)
f
.
StringVar
(
&
name
,
"name"
,
""
,
"name"
)
f
.
BoolVar
(
&
create
,
"create"
,
false
,
"create (deprecated)"
)
if
err
:=
f
.
Parse
(
args
);
err
!=
nil
{
return
1
...
...
@@ -65,11 +67,17 @@ func (c *PushCommand) Run(args []string) int {
return
1
}
// If we didn't pass name from the CLI, use the template
if
name
==
""
{
name
=
tpl
.
Push
.
Name
}
// Validate some things
if
tpl
.
Push
==
nil
||
tpl
.
Push
.
N
ame
==
""
{
if
n
ame
==
""
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"The 'push' section must be specified in the template with
\n
"
+
"at least the 'name' option set."
))
"at least the 'name' option set. Alternatively, you can pass the
\n
"
+
"name parameter from the CLI."
))
return
1
}
...
...
@@ -245,6 +253,9 @@ Options:
-m, -message=<detail> A message to identify the purpose or changes in this
Packer template much like a VCS commit message
-name=<name> The destination build in Atlas. This is in a format
"username/name".
-token=<token> The access token to use to when uploading
`
...
...
command/push_test.go
View file @
f8c87777
...
...
@@ -120,6 +120,42 @@ func TestPush_noName(t *testing.T) {
}
}
func
TestPush_cliName
(
t
*
testing
.
T
)
{
var
actual
[]
string
var
actualOpts
*
uploadOpts
uploadFn
:=
func
(
r
io
.
Reader
,
opts
*
uploadOpts
)
(
<-
chan
struct
{},
<-
chan
error
,
error
)
{
actual
=
testArchive
(
t
,
r
)
actualOpts
=
opts
doneCh
:=
make
(
chan
struct
{})
close
(
doneCh
)
return
doneCh
,
nil
,
nil
}
c
:=
&
PushCommand
{
Meta
:
testMeta
(
t
),
uploadFn
:
uploadFn
,
}
args
:=
[]
string
{
"-name=foo/bar"
,
filepath
.
Join
(
testFixture
(
"push-no-name"
),
"template.json"
),
}
if
code
:=
c
.
Run
(
args
);
code
!=
0
{
fatalCommand
(
t
,
c
.
Meta
)
}
expected
:=
[]
string
{
archiveTemplateEntry
,
"template.json"
,
}
if
!
reflect
.
DeepEqual
(
actual
,
expected
)
{
t
.
Fatalf
(
"bad: %#v"
,
actual
)
}
}
func
TestPush_uploadError
(
t
*
testing
.
T
)
{
uploadFn
:=
func
(
r
io
.
Reader
,
opts
*
uploadOpts
)
(
<-
chan
struct
{},
<-
chan
error
,
error
)
{
return
nil
,
nil
,
fmt
.
Errorf
(
"bad"
)
...
...
template/parse.go
View file @
f8c87777
...
...
@@ -187,7 +187,7 @@ func (r *rawTemplate) Template() (*Template, error) {
"push: %s"
,
err
))
}
result
.
Push
=
&
p
result
.
Push
=
p
}
// If we have errors, return those with a nil result
...
...
template/template.go
View file @
f8c87777
...
...
@@ -18,7 +18,7 @@ type Template struct {
Builders
map
[
string
]
*
Builder
Provisioners
[]
*
Provisioner
PostProcessors
[][]
*
PostProcessor
Push
*
Push
Push
Push
// RawContents is just the raw data for this template
RawContents
[]
byte
...
...
website/source/docs/command-line/push.html.markdown
View file @
f8c87777
...
...
@@ -33,6 +33,9 @@ must be completed within the template.
service such as Atlas. This can also be specified within the push
configuration in the template.
*
`-name`
- The name of the build in the service. This typically
looks like
`hashicorp/precise64`
.
## Examples
Push a Packer template:
...
...
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