Add --plugins flag to velero install (#1930)

* Add plugins flag to install

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
Nolan Brubaker
2019-10-03 16:44:52 -07:00
committed by KubeKween
parent db59d8d4bc
commit f009fe9bd1
7 changed files with 63 additions and 34 deletions
+2 -31
View File
@@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/vmware-tanzu/velero/pkg/builder"
"github.com/vmware-tanzu/velero/pkg/client"
"github.com/vmware-tanzu/velero/pkg/cmd"
"github.com/vmware-tanzu/velero/pkg/cmd/util/flag"
@@ -104,17 +105,7 @@ func NewAddCommand(f client.Factory) *cobra.Command {
}
// add the plugin as an init container
plugin := v1.Container{
Name: getName(args[0]),
Image: args[0],
ImagePullPolicy: v1.PullPolicy(imagePullPolicyFlag.String()),
VolumeMounts: []v1.VolumeMount{
{
Name: pluginsVolumeName,
MountPath: "/target",
},
},
}
plugin := *builder.ForPluginContainer(args[0], v1.PullPolicy(imagePullPolicyFlag.String())).Result()
veleroDeploy.Spec.Template.Spec.InitContainers = append(veleroDeploy.Spec.Template.Spec.InitContainers, plugin)
@@ -134,23 +125,3 @@ func NewAddCommand(f client.Factory) *cobra.Command {
return c
}
// getName returns the 'name' component of a docker
// image (i.e. everything after the last '/' and before
// any subsequent ':')
func getName(image string) string {
slashIndex := strings.LastIndex(image, "/")
colonIndex := strings.LastIndex(image, ":")
start := 0
if slashIndex > 0 {
start = slashIndex + 1
}
end := len(image)
if colonIndex > slashIndex {
end = colonIndex
}
return image[start:end]
}