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
8dbe0f06
Commit
8dbe0f06
authored
Oct 27, 2014
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove version from "packer" package
parent
bf9e7341
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
119 additions
and
110 deletions
+119
-110
checkpoint.go
checkpoint.go
+10
-9
command/version.go
command/version.go
+79
-0
commands.go
commands.go
+10
-0
common/step_download.go
common/step_download.go
+4
-3
main.go
main.go
+2
-2
packer/plugin/server.go
packer/plugin/server.go
+0
-3
packer/template.go
packer/template.go
+2
-0
packer/version.go
packer/version.go
+0
-93
version.go
version.go
+12
-0
No files found.
checkpoint.go
View file @
8dbe0f06
...
...
@@ -6,11 +6,10 @@ import (
"path/filepath"
"github.com/hashicorp/go-checkpoint"
"github.com/mitchellh/packer/
packer
"
"github.com/mitchellh/packer/
command
"
)
func
init
()
{
packer
.
VersionChecker
=
packerVersionCheck
checkpointResult
=
make
(
chan
*
checkpoint
.
CheckResponse
,
1
)
}
...
...
@@ -33,9 +32,9 @@ func runCheckpoint(c *config) {
return
}
version
:=
packer
.
Version
if
packer
.
VersionPrerelease
!=
""
{
version
+=
fmt
.
Sprintf
(
".%s"
,
packer
.
VersionPrerelease
)
version
:=
Version
if
VersionPrerelease
!=
""
{
version
+=
fmt
.
Sprintf
(
".%s"
,
VersionPrerelease
)
}
signaturePath
:=
filepath
.
Join
(
configDir
,
"checkpoint_signature"
)
...
...
@@ -58,21 +57,23 @@ func runCheckpoint(c *config) {
checkpointResult
<-
resp
}
//
packerVersionCheck implements packer
.VersionCheckFunc and is used
//
commandVersionCheck implements command
.VersionCheckFunc and is used
// as the version checker.
func
packerVersionCheck
(
current
string
)
(
packer
.
VersionCheckInfo
,
error
)
{
func
commandVersionCheck
()
(
command
.
VersionCheckInfo
,
error
)
{
// Wait for the result to come through
info
:=
<-
checkpointResult
if
info
==
nil
{
var
zero
packer
.
VersionCheckInfo
var
zero
command
.
VersionCheckInfo
return
zero
,
nil
}
// Build the alerts that we may have received about our version
alerts
:=
make
([]
string
,
len
(
info
.
Alerts
))
for
i
,
a
:=
range
info
.
Alerts
{
alerts
[
i
]
=
a
.
Message
}
return
packer
.
VersionCheckInfo
{
return
command
.
VersionCheckInfo
{
Outdated
:
info
.
Outdated
,
Latest
:
info
.
CurrentVersion
,
Alerts
:
alerts
,
...
...
command/version.go
0 → 100644
View file @
8dbe0f06
package
command
import
(
"bytes"
"fmt"
)
// VersionCommand is a Command implementation prints the version.
type
VersionCommand
struct
{
Meta
Revision
string
Version
string
VersionPrerelease
string
CheckFunc
VersionCheckFunc
}
// VersionCheckFunc is the callback called by the Version command to
// check if there is a new version of Packer.
type
VersionCheckFunc
func
()
(
VersionCheckInfo
,
error
)
// VersionCheckInfo is the return value for the VersionCheckFunc callback
// and tells the Version command information about the latest version
// of Packer.
type
VersionCheckInfo
struct
{
Outdated
bool
Latest
string
Alerts
[]
string
}
func
(
c
*
VersionCommand
)
Help
()
string
{
return
""
}
func
(
c
*
VersionCommand
)
Run
(
args
[]
string
)
int
{
/*
env.Ui().Machine("version", Version)
env.Ui().Machine("version-prelease", VersionPrerelease)
env.Ui().Machine("version-commit", GitCommit)
*/
var
versionString
bytes
.
Buffer
fmt
.
Fprintf
(
&
versionString
,
"Packer v%s"
,
c
.
Version
)
if
c
.
VersionPrerelease
!=
""
{
fmt
.
Fprintf
(
&
versionString
,
".%s"
,
c
.
VersionPrerelease
)
if
c
.
Revision
!=
""
{
fmt
.
Fprintf
(
&
versionString
,
" (%s)"
,
c
.
Revision
)
}
}
c
.
Ui
.
Output
(
versionString
.
String
())
// If we have a version check function, then let's check for
// the latest version as well.
if
c
.
CheckFunc
!=
nil
{
// Separate the prior output with a newline
c
.
Ui
.
Output
(
""
)
// Check the latest version
info
,
err
:=
c
.
CheckFunc
()
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error checking latest version: %s"
,
err
))
}
if
info
.
Outdated
{
c
.
Ui
.
Output
(
fmt
.
Sprintf
(
"Your version of Packer is out of date! The latest version
\n
"
+
"is %s. You can update by downloading from www.packer.io"
,
info
.
Latest
))
}
}
return
0
}
func
(
c
*
VersionCommand
)
Synopsis
()
string
{
return
"Prints the Packer version"
}
commands.go
View file @
8dbe0f06
...
...
@@ -55,6 +55,16 @@ func init() {
Meta
:
meta
,
},
nil
},
"version"
:
func
()
(
cli
.
Command
,
error
)
{
return
&
command
.
VersionCommand
{
Meta
:
meta
,
Revision
:
GitCommit
,
Version
:
Version
,
VersionPrerelease
:
VersionPrerelease
,
CheckFunc
:
commandVersionCheck
,
},
nil
},
}
}
...
...
common/step_download.go
View file @
8dbe0f06
...
...
@@ -3,10 +3,11 @@ package common
import
(
"encoding/hex"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
"time"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
// StepDownload downloads a remote file using the download client within
...
...
@@ -70,7 +71,7 @@ func (s *StepDownload) Run(state multistep.StateBag) multistep.StepAction {
CopyFile
:
false
,
Hash
:
HashForType
(
s
.
ChecksumType
),
Checksum
:
checksum
,
UserAgent
:
packer
.
VersionString
()
,
UserAgent
:
"Packer"
,
}
path
,
err
,
retry
:=
s
.
download
(
config
,
state
)
...
...
main.go
View file @
8dbe0f06
...
...
@@ -101,8 +101,8 @@ func wrappedMain() int {
log
.
SetOutput
(
os
.
Stderr
)
log
.
Printf
(
"
Packer V
ersion: %s %s %s"
,
packer
.
Version
,
packer
.
VersionPrerelease
,
packer
.
GitCommit
)
"
[INFO] Packer v
ersion: %s %s %s"
,
Version
,
VersionPrerelease
,
GitCommit
)
log
.
Printf
(
"Packer Target OS/Arch: %s %s"
,
runtime
.
GOOS
,
runtime
.
GOARCH
)
log
.
Printf
(
"Built with Go Version: %s"
,
runtime
.
Version
())
...
...
packer/plugin/server.go
View file @
8dbe0f06
...
...
@@ -10,7 +10,6 @@ package plugin
import
(
"errors"
"fmt"
"github.com/mitchellh/packer/packer"
packrpc
"github.com/mitchellh/packer/packer/rpc"
"io/ioutil"
"log"
...
...
@@ -38,8 +37,6 @@ const APIVersion = "4"
// Server waits for a connection to this plugin and returns a Packer
// RPC server that you can use to register components and serve them.
func
Server
()
(
*
packrpc
.
Server
,
error
)
{
log
.
Printf
(
"Plugin build against Packer '%s'"
,
packer
.
GitCommit
)
if
os
.
Getenv
(
MagicCookieKey
)
!=
MagicCookieValue
{
return
nil
,
errors
.
New
(
"Please do not execute plugins directly. Packer will execute these for you."
)
...
...
packer/template.go
View file @
8dbe0f06
...
...
@@ -119,6 +119,8 @@ func ParseTemplate(data []byte, vars map[string]string) (t *Template, err error)
}
if
rawTpl
.
MinimumPackerVersion
!=
""
{
// TODO: NOPE! Replace this
Version
:=
"1.0"
vCur
,
err
:=
version
.
NewVersion
(
Version
)
if
err
!=
nil
{
panic
(
err
)
...
...
packer/version.go
deleted
100644 → 0
View file @
bf9e7341
package
packer
import
(
"bytes"
"fmt"
)
// The git commit that is being compiled. This will be filled in by the
// compiler for source builds.
var
GitCommit
string
// This should be check to a callback to check for the latest version.
//
// The global nature of this variable is dirty, but a version checker
// really shouldn't change anyways.
var
VersionChecker
VersionCheckFunc
// The version of packer.
const
Version
=
"0.7.1"
// Any pre-release marker for the version. If this is "" (empty string),
// then it means that it is a final release. Otherwise, this is the
// pre-release marker.
const
VersionPrerelease
=
""
// VersionCheckFunc is the callback that is called to check the latest
// version of Packer.
type
VersionCheckFunc
func
(
string
)
(
VersionCheckInfo
,
error
)
// VersionCheckInfo is the return value for the VersionCheckFunc that
// contains the latest version information.
type
VersionCheckInfo
struct
{
Outdated
bool
Latest
string
Alerts
[]
string
}
type
versionCommand
byte
func
(
versionCommand
)
Help
()
string
{
return
`usage: packer version
Outputs the version of Packer that is running. There are no additional
command-line flags for this command.`
}
func
(
versionCommand
)
Run
(
env
Environment
,
args
[]
string
)
int
{
env
.
Ui
()
.
Machine
(
"version"
,
Version
)
env
.
Ui
()
.
Machine
(
"version-prelease"
,
VersionPrerelease
)
env
.
Ui
()
.
Machine
(
"version-commit"
,
GitCommit
)
env
.
Ui
()
.
Say
(
VersionString
())
if
VersionChecker
!=
nil
{
current
:=
Version
if
VersionPrerelease
!=
""
{
current
+=
fmt
.
Sprintf
(
".%s"
,
VersionPrerelease
)
}
info
,
err
:=
VersionChecker
(
current
)
if
err
!=
nil
{
env
.
Ui
()
.
Say
(
fmt
.
Sprintf
(
"
\n
Error checking latest version: %s"
,
err
))
}
if
info
.
Outdated
{
env
.
Ui
()
.
Say
(
fmt
.
Sprintf
(
"
\n
Your version of Packer is out of date! The latest version
\n
"
+
"is %s. You can update by downloading from www.packer.io."
,
info
.
Latest
))
}
}
return
0
}
func
(
versionCommand
)
Synopsis
()
string
{
return
"print Packer version"
}
// VersionString returns the Packer version in human-readable
// form complete with pre-release and git commit info if it is
// available.
func
VersionString
()
string
{
var
versionString
bytes
.
Buffer
fmt
.
Fprintf
(
&
versionString
,
"Packer v%s"
,
Version
)
if
VersionPrerelease
!=
""
{
fmt
.
Fprintf
(
&
versionString
,
".%s"
,
VersionPrerelease
)
if
GitCommit
!=
""
{
fmt
.
Fprintf
(
&
versionString
,
" (%s)"
,
GitCommit
)
}
}
return
versionString
.
String
()
}
version.go
0 → 100644
View file @
8dbe0f06
package
main
// The git commit that was compiled. This will be filled in by the compiler.
var
GitCommit
string
// The main version number that is being run at the moment.
const
Version
=
"0.8.0"
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
// such as "dev" (in development), "beta", "rc1", etc.
const
VersionPrerelease
=
"dev"
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