Use latest container image when version is empty (#1439)

When using `velero install`, the image used should be a reasonable
default, even if buildinfo.Version is missing (such as when using `go
build` directly).

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
Nolan Brubaker
2019-05-03 14:10:48 -04:00
committed by KubeKween
parent 26d86f514c
commit 884e512f93
3 changed files with 11 additions and 2 deletions

View File

@@ -0,0 +1 @@
Use `latest` image tag if no version information is provided at build time

View File

@@ -70,7 +70,7 @@ func WithRestoreOnly() podTemplateOption {
func Deployment(namespace string, opts ...podTemplateOption) *appsv1beta1.Deployment {
// TODO: Add support for server args
c := &podTemplateConfig{
image: "gcr.io/heptio-images/velero:latest",
image: DefaultImage,
}
for _, opt := range opts {

View File

@@ -28,8 +28,16 @@ import (
"github.com/heptio/velero/pkg/buildinfo"
)
// Use "latest" if the build process didn't supply a version
func imageVersion() string {
if buildinfo.Version == "" {
return "latest"
}
return buildinfo.Version
}
// DefaultImage is the default image to use for the Velero deployment and restic daemonset containers.
var DefaultImage = "gcr.io/heptio-images/velero:" + buildinfo.Version
var DefaultImage = "gcr.io/heptio-images/velero:" + imageVersion()
func labels() map[string]string {
return map[string]string{