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
d08815fc
Commit
d08815fc
authored
Dec 01, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/push: works
parent
c1fbc473
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
command/push.go
command/push.go
+15
-16
No files found.
command/push.go
View file @
d08815fc
...
...
@@ -7,8 +7,8 @@ import (
"path/filepath"
"strings"
"github.com/hashicorp/
harmony-go
"
"github.com/hashicorp/
harmony
-go/archive"
"github.com/hashicorp/
atlas-go/v1
"
"github.com/hashicorp/
atlas
-go/archive"
"github.com/mitchellh/packer/packer"
)
...
...
@@ -18,7 +18,7 @@ const archiveTemplateEntry = ".packer-template"
type
PushCommand
struct
{
Meta
client
*
harmony
.
Client
client
*
atlas
.
Client
// For tests:
uploadFn
func
(
io
.
Reader
,
*
uploadOpts
)
(
<-
chan
struct
{},
<-
chan
error
,
error
)
...
...
@@ -64,9 +64,9 @@ func (c *PushCommand) Run(args []string) int {
// Build our client
defer
func
()
{
c
.
client
=
nil
}()
c
.
client
=
harmony
.
DefaultClient
()
c
.
client
=
atlas
.
DefaultClient
()
if
tpl
.
Push
.
Address
!=
""
{
c
.
client
,
err
=
harmony
.
NewClient
(
tpl
.
Push
.
Address
)
c
.
client
,
err
=
atlas
.
NewClient
(
tpl
.
Push
.
Address
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error setting up API client: %s"
,
err
))
...
...
@@ -110,7 +110,7 @@ func (c *PushCommand) Run(args []string) int {
}
// Start the archiving process
r
,
archiveErrCh
,
err
:=
archive
.
Archive
(
path
,
&
opts
)
r
,
err
:=
archive
.
Create
Archive
(
path
,
&
opts
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error archiving: %s"
,
err
))
return
1
...
...
@@ -126,8 +126,6 @@ func (c *PushCommand) Run(args []string) int {
err
=
nil
select
{
case
err
=
<-
archiveErrCh
:
err
=
fmt
.
Errorf
(
"Error archiving: %s"
,
err
)
case
err
=
<-
uploadErrCh
:
err
=
fmt
.
Errorf
(
"Error uploading: %s"
,
err
)
case
<-
doneCh
:
...
...
@@ -138,6 +136,7 @@ func (c *PushCommand) Run(args []string) int {
return
1
}
c
.
Ui
.
Output
(
fmt
.
Sprintf
(
"Push successful to '%s'"
,
tpl
.
Push
.
Name
))
return
0
}
...
...
@@ -173,7 +172,7 @@ func (c *PushCommand) create(name string, create bool) error {
}
// Separate the slug into the user and name components
user
,
name
,
err
:=
harmony
.
ParseSlug
(
name
)
user
,
name
,
err
:=
atlas
.
ParseSlug
(
name
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Malformed push name: %s"
,
err
)
}
...
...
@@ -181,7 +180,7 @@ func (c *PushCommand) create(name string, create bool) error {
// Check if it exists. If so, we're done.
if
_
,
err
:=
c
.
client
.
BuildConfig
(
user
,
name
);
err
==
nil
{
return
nil
}
else
if
err
!=
harmony
.
ErrNotFound
{
}
else
if
err
!=
atlas
.
ErrNotFound
{
return
err
}
...
...
@@ -201,13 +200,13 @@ func (c *PushCommand) create(name string, create bool) error {
}
func
(
c
*
PushCommand
)
upload
(
r
io
.
Reader
,
opts
*
uploadOpts
)
(
<-
chan
struct
{},
<-
chan
error
,
error
)
{
r
*
archive
.
Archive
,
opts
*
uploadOpts
)
(
<-
chan
struct
{},
<-
chan
error
,
error
)
{
if
c
.
uploadFn
!=
nil
{
return
c
.
uploadFn
(
r
,
opts
)
}
// Separate the slug into the user and name components
user
,
name
,
err
:=
harmony
.
ParseSlug
(
opts
.
Slug
)
user
,
name
,
err
:=
atlas
.
ParseSlug
(
opts
.
Slug
)
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"upload: %s"
,
err
)
}
...
...
@@ -219,13 +218,13 @@ func (c *PushCommand) upload(
}
// Build the version to send up
version
:=
harmony
.
BuildConfigVersion
{
version
:=
atlas
.
BuildConfigVersion
{
User
:
bc
.
User
,
Name
:
bc
.
Name
,
Builds
:
make
([]
harmony
.
BuildConfigBuild
,
0
,
len
(
opts
.
Builds
)),
Builds
:
make
([]
atlas
.
BuildConfigBuild
,
0
,
len
(
opts
.
Builds
)),
}
for
name
,
t
:=
range
opts
.
Builds
{
version
.
Builds
=
append
(
version
.
Builds
,
harmony
.
BuildConfigBuild
{
version
.
Builds
=
append
(
version
.
Builds
,
atlas
.
BuildConfigBuild
{
Name
:
name
,
Type
:
t
,
})
...
...
@@ -234,7 +233,7 @@ func (c *PushCommand) upload(
// Start the upload
doneCh
,
errCh
:=
make
(
chan
struct
{}),
make
(
chan
error
)
go
func
()
{
err
:=
c
.
client
.
UploadBuildConfigVersion
(
&
version
,
r
)
err
:=
c
.
client
.
UploadBuildConfigVersion
(
&
version
,
r
,
r
.
Size
)
if
err
!=
nil
{
errCh
<-
err
return
...
...
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