@@ -17,26 +17,27 @@ func TestEnvs(t *testing.T) {
1717 RunSpecs (t , "Environment Suite" )
1818}
1919
20- var _ = Describe ("Images.GetHub " , func () {
20+ var _ = Describe ("Images.GetHubAndImageTag " , func () {
2121 type fields struct {
2222 Pilot images.Image
2323 InstallCNI images.Image
2424 ProxyV2 images.Image
2525 Ztunnel images.Image
2626 }
2727
28- DescribeTable ("GetHub " ,
29- func (f fields , want string , wantErr bool , err error ) {
28+ DescribeTable ("GetHubAndImageTag " ,
29+ func (f fields , want images. HubTag , wantErr bool , expErr error ) {
3030 e := & images.Images {
3131 Pilot : f .Pilot ,
3232 InstallCNI : f .InstallCNI ,
3333 ProxyV2 : f .ProxyV2 ,
3434 Ztunnel : f .Ztunnel ,
3535 }
36- got , err := e .GetHub ()
36+ got , err := e .GetHubAndImageTag ()
3737 if wantErr {
3838 Expect (err ).To (HaveOccurred ())
3939 Expect (err .Error ()).To (ContainSubstring ("image" ))
40+ Expect (err .Error ()).To (ContainSubstring (expErr .Error ()))
4041 } else {
4142 Expect (err ).NotTo (HaveOccurred ())
4243 Expect (got ).To (Equal (want ))
@@ -49,39 +50,61 @@ var _ = Describe("Images.GetHub", func() {
4950 ProxyV2 : "docker.io/istio/proxyv2:1.10.0" ,
5051 Ztunnel : "docker.io/istio/ztunnel:1.10.0" ,
5152 },
52- "docker.io/istio" ,
53+ images. HubTag { Hub : "docker.io/istio" , Tag : "1.10.0" } ,
5354 false ,
5455 nil ,
5556 ),
56- Entry ("invalid image format " ,
57+ Entry ("invalid image hub " ,
5758 fields {
5859 Pilot : "pilot:1.10.0" ,
5960 InstallCNI : "docker.io/istio/cni:1.10.0" ,
6061 ProxyV2 : "docker.io/istio/proxyv2:1.10.0" ,
6162 Ztunnel : "docker.io/istio/ztunnel:1.10.0" ,
6263 },
63- "" ,
64+ images. HubTag {} ,
6465 true ,
6566 fmt .Errorf ("image pilot:1.10.0 does not contain a valid hub URL" ),
6667 ),
68+ Entry ("missing image tag" ,
69+ fields {
70+ Pilot : "docker.io/istio/pilot1.10.0" ,
71+ InstallCNI : "docker.io/istio/cni:1.10.0" ,
72+ ProxyV2 : "docker.io/istio/proxyv2:1.10.0" ,
73+ Ztunnel : "docker.io/istio/ztunnel:1.10.0" ,
74+ },
75+ images.HubTag {},
76+ true ,
77+ fmt .Errorf ("image docker.io/istio/pilot1.10.0 does not contain a valid tag" ),
78+ ),
6779 Entry ("images from different hubs" ,
6880 fields {
6981 Pilot : "docker.io/istio/pilot:1.10.0" ,
7082 InstallCNI : "docker.io/istio/cni:1.10.0" ,
7183 ProxyV2 : "foo.bar/istio/proxyv2:1.10.0" ,
7284 Ztunnel : "docker.io/istio/ztunnel:1.10.0" ,
7385 },
74- "" ,
86+ images. HubTag {} ,
7587 true ,
7688 fmt .Errorf ("image foo.bar/istio/proxyv2:1.10.0 is not from the same hub as docker.io/istio/pilot:1.10.0" ),
7789 ),
90+ Entry ("images with different tags" ,
91+ fields {
92+ Pilot : "docker.io/istio/pilot:1.10.0" ,
93+ InstallCNI : "docker.io/istio/cni:1.10.0" ,
94+ ProxyV2 : "docker.io/istio/proxyv2:1.11.0" ,
95+ Ztunnel : "docker.io/istio/ztunnel:1.10.0" ,
96+ },
97+ images.HubTag {},
98+ true ,
99+ fmt .Errorf ("image docker.io/istio/proxyv2:1.11.0 does not have the same tag as docker.io/istio/pilot:1.10.0" ),
100+ ),
78101 Entry ("empty image" ,
79102 fields {
80103 Pilot : "" ,
81104 InstallCNI : "docker.io/istio/cni:1.10.0" ,
82105 ProxyV2 : "docker.io/istio/proxyv2:1.10.0" ,
83106 },
84- "" ,
107+ images. HubTag {} ,
85108 true ,
86109 fmt .Errorf ("image can not be empty" ),
87110 ),
0 commit comments