forked from openebs-archive/maya
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(upgrade): add support for images having more than one ":" (openeb…
…s-archive#1557) * fix(upgarde): add support for images having more than one ":" Signed-off-by: shubham <[email protected]>
- Loading branch information
1 parent
a8602c9
commit 071e801
Showing
2 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
Copyright 2019 The OpenEBS Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func Test_getBaseImage(t *testing.T) { | ||
type args struct { | ||
deployObj *appsv1.Deployment | ||
name string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantErr bool | ||
}{ | ||
// TODO: Add test cases. | ||
{ | ||
name: "Without proxy", | ||
want: "quay.io/openebs/cstor-pool", | ||
wantErr: false, | ||
args: args{ | ||
deployObj: &appsv1.Deployment{ | ||
Spec: appsv1.DeploymentSpec{ | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
corev1.Container{ | ||
Name: "cstor-pool", | ||
Image: "quay.io/openebs/cstor-pool:1.4.0", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
name: "cstor-pool", | ||
}, | ||
}, | ||
{ | ||
name: "With proxy", | ||
want: "fsdepot.evry.com:8085/openebs/cstor-pool", | ||
wantErr: false, | ||
args: args{ | ||
deployObj: &appsv1.Deployment{ | ||
Spec: appsv1.DeploymentSpec{ | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
corev1.Container{ | ||
Name: "cstor-pool", | ||
Image: "fsdepot.evry.com:8085/openebs/cstor-pool:1.4.0", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
name: "cstor-pool", | ||
}, | ||
}, | ||
{ | ||
name: "With no image tag", | ||
want: "", | ||
wantErr: true, | ||
args: args{ | ||
deployObj: &appsv1.Deployment{ | ||
Spec: appsv1.DeploymentSpec{ | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
corev1.Container{ | ||
Name: "cstor-pool", | ||
Image: "quay.io/openebs/cstor-pool", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
name: "cstor-pool", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt // pin it | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := getBaseImage(tt.args.deployObj, tt.args.name) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("getBaseImage() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("getBaseImage() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |