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
+33
View File
@@ -17,6 +17,8 @@ limitations under the License.
package builder
import (
"strings"
corev1api "k8s.io/api/core/v1"
)
@@ -35,6 +37,32 @@ func ForContainer(name, image string) *ContainerBuilder {
}
}
// ForPluginContainer is a helper builder specifically for plugin init containers
func ForPluginContainer(image string, pullPolicy corev1api.PullPolicy) *ContainerBuilder {
volumeMount := ForVolumeMount("plugins", "/target").Result()
return ForContainer(getName(image), image).PullPolicy(pullPolicy).VolumeMounts(volumeMount)
}
// 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]
}
// Result returns the built Container.
func (b *ContainerBuilder) Result() *corev1api.Container {
return b.object
@@ -66,3 +94,8 @@ func (b *ContainerBuilder) Env(vars ...*corev1api.EnvVar) *ContainerBuilder {
}
return b
}
func (b *ContainerBuilder) PullPolicy(pullPolicy corev1api.PullPolicy) *ContainerBuilder {
b.object.ImagePullPolicy = pullPolicy
return b
}