mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-20 06:54:32 +00:00
Rename Ark to Velero!!!
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
committed by
Andy Goldstein
parent
bbc6caf7fe
commit
43714caaec
+15
-15
@@ -28,15 +28,15 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/ark/pkg/cmd/util/flag"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/cmd/util/flag"
|
||||
)
|
||||
|
||||
const (
|
||||
pluginsVolumeName = "plugins"
|
||||
arkDeployment = "ark"
|
||||
arkContainer = "ark"
|
||||
veleroDeployment = "velero"
|
||||
veleroContainer = "velero"
|
||||
)
|
||||
|
||||
func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
@@ -55,17 +55,17 @@ func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
arkDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(arkDeployment, metav1.GetOptions{})
|
||||
veleroDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(veleroDeployment, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
original, err := json.Marshal(arkDeploy)
|
||||
original, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
// ensure the plugins volume & mount exist
|
||||
volumeExists := false
|
||||
for _, volume := range arkDeploy.Spec.Template.Spec.Volumes {
|
||||
for _, volume := range veleroDeploy.Spec.Template.Spec.Volumes {
|
||||
if volume.Name == pluginsVolumeName {
|
||||
volumeExists = true
|
||||
break
|
||||
@@ -85,19 +85,19 @@ func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
MountPath: "/plugins",
|
||||
}
|
||||
|
||||
arkDeploy.Spec.Template.Spec.Volumes = append(arkDeploy.Spec.Template.Spec.Volumes, volume)
|
||||
veleroDeploy.Spec.Template.Spec.Volumes = append(veleroDeploy.Spec.Template.Spec.Volumes, volume)
|
||||
|
||||
containers := arkDeploy.Spec.Template.Spec.Containers
|
||||
containers := veleroDeploy.Spec.Template.Spec.Containers
|
||||
containerIndex := -1
|
||||
for x, container := range containers {
|
||||
if container.Name == arkContainer {
|
||||
if container.Name == veleroContainer {
|
||||
containerIndex = x
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if containerIndex < 0 {
|
||||
cmd.CheckError(errors.New("ark container not found in ark deployment"))
|
||||
cmd.CheckError(errors.New("velero container not found in velero deployment"))
|
||||
}
|
||||
|
||||
containers[containerIndex].VolumeMounts = append(containers[containerIndex].VolumeMounts, volumeMount)
|
||||
@@ -116,16 +116,16 @@ func NewAddCommand(f client.Factory) *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
arkDeploy.Spec.Template.Spec.InitContainers = append(arkDeploy.Spec.Template.Spec.InitContainers, plugin)
|
||||
veleroDeploy.Spec.Template.Spec.InitContainers = append(veleroDeploy.Spec.Template.Spec.InitContainers, plugin)
|
||||
|
||||
// create & apply the patch
|
||||
updated, err := json.Marshal(arkDeploy)
|
||||
updated, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
patchBytes, err := jsonpatch.CreateMergePatch(original, updated)
|
||||
cmd.CheckError(err)
|
||||
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(arkDeploy.Namespace).Patch(arkDeploy.Name, types.MergePatchType, patchBytes)
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(veleroDeploy.Namespace).Patch(veleroDeploy.Name, types.MergePatchType, patchBytes)
|
||||
cmd.CheckError(err)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package plugin
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
)
|
||||
|
||||
func NewCommand(f client.Factory) *cobra.Command {
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/heptio/ark/pkg/client"
|
||||
"github.com/heptio/ark/pkg/cmd"
|
||||
"github.com/heptio/velero/pkg/client"
|
||||
"github.com/heptio/velero/pkg/cmd"
|
||||
)
|
||||
|
||||
func NewRemoveCommand(f client.Factory) *cobra.Command {
|
||||
@@ -40,16 +40,16 @@ func NewRemoveCommand(f client.Factory) *cobra.Command {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
arkDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(arkDeployment, metav1.GetOptions{})
|
||||
veleroDeploy, err := kubeClient.AppsV1beta1().Deployments(f.Namespace()).Get(veleroDeployment, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
cmd.CheckError(err)
|
||||
}
|
||||
|
||||
original, err := json.Marshal(arkDeploy)
|
||||
original, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
var (
|
||||
initContainers = arkDeploy.Spec.Template.Spec.InitContainers
|
||||
initContainers = veleroDeploy.Spec.Template.Spec.InitContainers
|
||||
index = -1
|
||||
)
|
||||
|
||||
@@ -61,18 +61,18 @@ func NewRemoveCommand(f client.Factory) *cobra.Command {
|
||||
}
|
||||
|
||||
if index == -1 {
|
||||
cmd.CheckError(errors.Errorf("init container %s not found in Ark server deployment", args[0]))
|
||||
cmd.CheckError(errors.Errorf("init container %s not found in Velero server deployment", args[0]))
|
||||
}
|
||||
|
||||
arkDeploy.Spec.Template.Spec.InitContainers = append(initContainers[0:index], initContainers[index+1:]...)
|
||||
veleroDeploy.Spec.Template.Spec.InitContainers = append(initContainers[0:index], initContainers[index+1:]...)
|
||||
|
||||
updated, err := json.Marshal(arkDeploy)
|
||||
updated, err := json.Marshal(veleroDeploy)
|
||||
cmd.CheckError(err)
|
||||
|
||||
patchBytes, err := jsonpatch.CreateMergePatch(original, updated)
|
||||
cmd.CheckError(err)
|
||||
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(arkDeploy.Namespace).Patch(arkDeploy.Name, types.MergePatchType, patchBytes)
|
||||
_, err = kubeClient.AppsV1beta1().Deployments(veleroDeploy.Namespace).Patch(veleroDeploy.Name, types.MergePatchType, patchBytes)
|
||||
cmd.CheckError(err)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user