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
79f7936d
Commit
79f7936d
authored
Oct 16, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dependency on identifier package, use time ordered UUID [GH-541]
parent
9fa648d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
15 deletions
+33
-15
builder/amazon/common/step_security_group.go
builder/amazon/common/step_security_group.go
+2
-3
builder/digitalocean/step_create_droplet.go
builder/digitalocean/step_create_droplet.go
+2
-3
builder/digitalocean/step_create_ssh_key.go
builder/digitalocean/step_create_ssh_key.go
+2
-3
builder/openstack/step_key_pair.go
builder/openstack/step_key_pair.go
+2
-3
common/uuid/uuid.go
common/uuid/uuid.go
+23
-0
packer/config_template.go
packer/config_template.go
+2
-3
No files found.
builder/amazon/common/step_security_group.go
View file @
79f7936d
package
common
import
(
"cgl.tideland.biz/identifier"
"encoding/hex"
"fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/packer"
"log"
"time"
...
...
@@ -35,7 +34,7 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction {
// Create the group
ui
.
Say
(
"Creating temporary security group for this instance..."
)
groupName
:=
fmt
.
Sprintf
(
"packer %s"
,
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
()
))
groupName
:=
fmt
.
Sprintf
(
"packer %s"
,
uuid
.
TimeOrderedUUID
(
))
log
.
Printf
(
"Temporary group name: %s"
,
groupName
)
group
:=
ec2
.
SecurityGroup
{
Name
:
groupName
,
...
...
builder/digitalocean/step_create_droplet.go
View file @
79f7936d
package
digitalocean
import
(
"cgl.tideland.biz/identifier"
"encoding/hex"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/packer"
)
...
...
@@ -21,7 +20,7 @@ func (s *stepCreateDroplet) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
"Creating droplet..."
)
// Some random droplet name as it's temporary
name
:=
fmt
.
Sprintf
(
"packer-%s"
,
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
()
))
name
:=
fmt
.
Sprintf
(
"packer-%s"
,
uuid
.
TimeOrderedUUID
(
))
// Create the droplet based on configuration
dropletId
,
err
:=
client
.
CreateDroplet
(
name
,
c
.
SizeID
,
c
.
ImageID
,
c
.
RegionID
,
sshKeyId
)
...
...
builder/digitalocean/step_create_ssh_key.go
View file @
79f7936d
package
digitalocean
import
(
"cgl.tideland.biz/identifier"
"code.google.com/p/go.crypto/ssh"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/hex"
"encoding/pem"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/packer"
"log"
)
...
...
@@ -43,7 +42,7 @@ func (s *stepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction {
pub_sshformat
:=
string
(
ssh
.
MarshalAuthorizedKey
(
pub
))
// The name of the public key on DO
name
:=
fmt
.
Sprintf
(
"packer-%s"
,
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
()
))
name
:=
fmt
.
Sprintf
(
"packer-%s"
,
uuid
.
TimeOrderedUUID
(
))
// Create the key!
keyId
,
err
:=
client
.
CreateKey
(
name
,
pub_sshformat
)
...
...
builder/openstack/step_key_pair.go
View file @
79f7936d
package
openstack
import
(
"cgl.tideland.biz/identifier"
"encoding/hex"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/packer"
"github.com/rackspace/gophercloud"
"log"
...
...
@@ -19,7 +18,7 @@ func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction {
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
.
Say
(
"Creating temporary keypair for this instance..."
)
keyName
:=
fmt
.
Sprintf
(
"packer %s"
,
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
()
))
keyName
:=
fmt
.
Sprintf
(
"packer %s"
,
uuid
.
TimeOrderedUUID
(
))
log
.
Printf
(
"temporary keypair name: %s"
,
keyName
)
keyResp
,
err
:=
csp
.
CreateKeyPair
(
gophercloud
.
NewKeyPair
{
Name
:
keyName
})
if
err
!=
nil
{
...
...
common/uuid/uuid.go
0 → 100644
View file @
79f7936d
package
uuid
import
(
"fmt"
"math/rand"
"time"
)
// Generates a time ordered UUID. Top 32 bits are a timestamp,
// bottom 96 are random.
func
TimeOrderedUUID
()
string
{
unix
:=
uint32
(
time
.
Now
()
.
UTC
()
.
Unix
())
rand1
:=
rand
.
Uint32
()
rand2
:=
rand
.
Uint32
()
rand3
:=
rand
.
Uint32
()
return
fmt
.
Sprintf
(
"%08x-%04x-%04x-%04x-%04x%08x"
,
unix
,
uint16
(
rand1
>>
16
),
uint16
(
rand1
&
0xffff
),
uint16
(
rand2
>>
16
),
uint16
(
rand2
&
0xffff
),
rand3
)
}
packer/config_template.go
View file @
79f7936d
...
...
@@ -2,9 +2,8 @@ package packer
import
(
"bytes"
"cgl.tideland.biz/identifier"
"encoding/hex"
"fmt"
"github.com/mitchellh/packer/common/uuid"
"strconv"
"text/template"
"time"
...
...
@@ -94,5 +93,5 @@ func templateTimestamp() string {
}
func
templateUuid
()
string
{
return
hex
.
EncodeToString
(
identifier
.
NewUUID
()
.
Raw
())
return
hex
.
EncodeToString
(
uuid
.
TimeOrderedUUID
())
}
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