Skip to content

Commit

Permalink
Merge pull request #431 from deepakkinni/xport-4
Browse files Browse the repository at this point in the history
[Crossport]Rely on only container name while parsing feature flags (#422)
  • Loading branch information
Lintong Jiang committed Dec 7, 2021
2 parents 7f18e9e + 83e8195 commit b8ffd5c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func GetVeleroFeatureFlags(kubeClient kubernetes.Interface, ns string) ([]string
func GetFeatureFlagsFromImage(containers []v1.Container, containerName string) ([]string, error) {
var containerArgs = []string{}
for _, container := range containers {
if containerName == container.Name && containerName == utils.GetComponentFromImage(container.Image, constants.ImageContainerComponent) {
if containerName == container.Name {
containerArgs = container.Args[1:]
break
}
Expand Down
54 changes: 54 additions & 0 deletions pkg/cmd/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,60 @@ func TestGetVeleroFeatureFlags(t *testing.T) {
expectedFeatureFlags: []string{},
expectedError: nil,
},
{
name: "VeleroImageWithSha256",
veleroDeployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "velero",
Name: constants.VeleroDeployment,
},
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "velero",
Image: "velero/velero@sha256:934dae8b2e17b4298bca95f45ec3620a283647297fb8ba8c0f5977e8238a97ee",
Args: []string{
"server",
"--features=EnableLocalMode",
},
},
},
},
},
},
},
expectedFeatureFlags: []string{"EnableLocalMode"},
expectedError: nil,
},
{
name: "VeleroImageWithSha256MultipleFlags",
veleroDeployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "velero",
Name: constants.VeleroDeployment,
},
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "velero",
Image: "velero/velero@sha256:934dae8b2e17b4298bca95f45ec3620a283647297fb8ba8c0f5977e8238a97ee",
Args: []string{
"server",
"--features=EnableVSphereItemActionPlugin,EnableLocalMode",
},
},
},
},
},
},
},
expectedFeatureFlags: []string{"EnableVSphereItemActionPlugin", "EnableLocalMode"},
expectedError: nil,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down

0 comments on commit b8ffd5c

Please sign in to comment.