mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 05:46:37 +00:00
use Ark version as the tag for the restore-helper image in init container
Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package restore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
@@ -25,20 +27,33 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
api "github.com/heptio/ark/pkg/apis/ark/v1"
|
||||
"github.com/heptio/ark/pkg/buildinfo"
|
||||
"github.com/heptio/ark/pkg/restic"
|
||||
"github.com/heptio/ark/pkg/util/kube"
|
||||
)
|
||||
|
||||
type resticRestoreAction struct {
|
||||
logger logrus.FieldLogger
|
||||
logger logrus.FieldLogger
|
||||
initContainerImage string
|
||||
}
|
||||
|
||||
func NewResticRestoreAction(logger logrus.FieldLogger) ItemAction {
|
||||
return &resticRestoreAction{
|
||||
logger: logger,
|
||||
logger: logger,
|
||||
initContainerImage: initContainerImage(),
|
||||
}
|
||||
}
|
||||
|
||||
func initContainerImage() string {
|
||||
tag := buildinfo.Version
|
||||
if tag == "" {
|
||||
tag = "latest"
|
||||
}
|
||||
|
||||
// TODO allow full image URL to be overriden via CLI flag.
|
||||
return fmt.Sprintf("gcr.io/heptio-images/ark-restic-restore-helper:%s", tag)
|
||||
}
|
||||
|
||||
func (a *resticRestoreAction) AppliesTo() (ResourceSelector, error) {
|
||||
return ResourceSelector{
|
||||
IncludedResources: []string{"pods"},
|
||||
@@ -65,11 +80,8 @@ func (a *resticRestoreAction) Execute(obj runtime.Unstructured, restore *api.Res
|
||||
log.Info("Restic snapshot ID annotations found")
|
||||
|
||||
initContainer := corev1.Container{
|
||||
Name: restic.InitContainer,
|
||||
// TODO don't hardcode the tag as "latest". We should probably be defaulting
|
||||
// to a tag that matches the Ark binary version, and possibly allowing it to
|
||||
// be overriden via cmd-line flag to Ark.
|
||||
Image: "gcr.io/heptio-images/ark-restic-restore-helper:latest",
|
||||
Name: restic.InitContainer,
|
||||
Image: a.initContainerImage,
|
||||
Args: []string{string(restore.UID)},
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user